Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###Example Script for Changing Keyboard Layout for Specific Application in Focus
- from subprocess import PIPE, Popen
- from time import sleep
- from os import system
- title = ''
- root_check = ''
- while True:
- sleep(0.6)
- root = Popen(['xprop', '-root'], stdout=PIPE)
- if root.stdout != root_check:
- root_check = root.stdout
- for i in root.stdout:
- if '_NET_ACTIVE_WINDOW(WINDOW):' in i:
- id_ = i.split()[4]
- id_w = Popen(['xprop', '-id', id_], stdout=PIPE)
- for j in id_w.stdout:
- if 'WM_ICON_NAME(STRING)' in j:
- if title != j.split()[2]:
- title = j.split()[2]
- if title = "Google Chrome":
- system('gsettings set org.gnome.desktop.input-sources current 0')
- if title = "Geogebra":
- system('gsettings set org.gnome.desktop.input-sources current 1')
- ###The numbers in each line correspond to the indexed keyboard number in your input-sources list in Gnome settings.
Advertisement
Add Comment
Please, Sign In to add comment