I use more than one keyboard layout, and I would like to find a way to run a script when I switch between them.
Is this possible?
So far, I can assign a shortcut for a script like this:
#!/bin/bash
#switch between two layouts (English and Greek in this case)
current_layouts=$(gsettings get org.gnome.libgnomekbd.keyboard layouts)
if [ "$current_layouts" = "us" ]; then
gsettings set org.gnome.libgnomekbd.keyboard layouts "['gr']"
else
gsettings set org.gnome.libgnomekbd.keyboard layouts "['us']"
fi
exec /path/to/another/script
But using this method, I can use only that shortcut to switch between layouts and the keyboard indicator will disappear from the status menu, what is unpleasantly.