Skip to main content
Tweeted twitter.com/#!/StackUnix/status/388367608875331586
added 637 characters in body
Source Link
Radu Rădeanu
  • 1.8k
  • 2
  • 24
  • 47

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.

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?

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.

Source Link
Radu Rădeanu
  • 1.8k
  • 2
  • 24
  • 47

How do I run a script when I switch between keyboard layouts

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?