Similar to this question from 2012, I'm looking for a way to automate the setup of a key combinations that should trigger the execution of a command the same way as setting it in the gui does. (example usage)
I'm on Ubuntu 18.04 and the linked answer's gsettings schema does not seem to exist:
$ gsettings list-schemas | grep keyboard
org.gnome.settings-daemon.plugins.keyboard
org.gnome.settings-daemon.plugins.a11y-keyboard
org.gnome.shell.keyboard
org.gnome.settings-daemon.peripherals.keyboard
org.gnome.libgnomekbd.keyboard
com.canonical.indicator.keyboard
org.gnome.desktop.peripherals.keyboard
org.gnome.desktop.a11y.keyboard
How can I use bash to set it up as if I went in the GNOME GUI to Settings > Devices > Keyboard
and set it up manually?
After the comment
I have looked at the following links:
My laptop on which this is already set up using the GUI, I ran a few queries to know what output I should aim for.
On my testing device (different from the previous laptop), querying
org.gnome.settings-daemon.plugins.media-keys custom-keybindings
returned an empty string array (@as []
).On my testing device, I tried to set a binding:
In
/usr/share/glib-2.0/schemas/org.gnome.settings-daemon.plugins.media-keys.custom-keybindings.gschema.xml
on the testing device is a schema defined fororg.gnome.settings-daemon.plugins.media-keys.custom-keybinding
(without trailing s). There I can see that the types ofname
,binding
, andcommand
are alls
for string. So I dropped the trailing s in theid
but not thepath
and now setting and querying them again works.I then added my custom command path to the previously empty list. (I think this overwrites the whole list, so beware!)
I proceeded to reload gnome by entering
r
into the popup that comes when I press AltF2.I moved a window to a second workspace and tried whether it works. It does not - nothing happens.
I changed the command to
echo test > ~/testing.txt
and tried again, but still - nothing happens. The file is not created.The problem here was the same as in my linked example usage with the GUI:
I've authored a script for this purpose. It will fail without printing an error if attempting to override an existing default shortcut.
Here a exaple how to create keyboard shortcut to suspend the system by pressing
<Super> + p
keys: