Created
May 21, 2020 19:58
-
-
Save sintezoid/3c63097bb2bd2730b7fbf9cbd4f38262 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Принудительно меняем раскладу для Konsole и kitty | |
#Для телеграм меняем на Русский | |
#Для всего остального меняю на английский | |
from i3ipc import Connection, Event | |
import subprocess,os | |
# Create the Connection object that can be used to send commands and subscribe | |
# to events. | |
i3 = Connection() | |
# Print the name of the focused window | |
def on_window_focus(i3, e): | |
focused = i3.get_tree().find_focused() | |
if focused.app_id == "kitty" or focused.app_id == "org.kde.konsole": | |
os.system("swaymsg input \* xkb_switch_layout 0") | |
elif focused.app_id == "telegramdesktop": | |
os.system("swaymsg input \* xkb_switch_layout 1") | |
#В телеграм я обычно пишу на русском, поэтому переключаем принудительно. | |
else: | |
os.system("swaymsg input \* xkb_switch_layout 0") | |
#Если необходимо закостылить еще что-то, то ищем app_id приложения | |
#print("app_id", focused.app_id) | |
# Subscribe to events | |
i3.on(Event.WINDOW_FOCUS, on_window_focus) | |
# Start the main loop and wait for events to come in. | |
i3.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment