Skip to content

Instantly share code, notes, and snippets.

@sintezoid
Created May 21, 2020 19:58
Show Gist options
  • Save sintezoid/3c63097bb2bd2730b7fbf9cbd4f38262 to your computer and use it in GitHub Desktop.
Save sintezoid/3c63097bb2bd2730b7fbf9cbd4f38262 to your computer and use it in GitHub Desktop.
#Принудительно меняем раскладу для 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