Question

How do you add a shortcut by commandline?

If we do it by hand (Keyboard > Custom Shortcuts) it works as it is supposed to do.

When we want to do it by commandline (in a bashscript as example)

gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ name "killscript"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ command "pkill chromium"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ binding "<Primary><Alt>X"

This doesn't work.. When I'll check the shortcut by the dconfeditor I see that it has the proper name, binding and command set up.

Any ideas how I could get this fixed?

No correct solution

OTHER TIPS

You can always change the settings in the GUI and watch the changes in the terminal using:

dconf watch /

You will notice that there are 4 commands the 3 you already have to set name, binding, and command and a 4th that adds the command to an array:

/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/binding
  '<Primary>1'

/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/name
  'test'

/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/command
  'test'

/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings
  ['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/']

So to add your custom0 command to the array use this command and then it works

gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/']"

Also, check this detailed answer on how to manipulate the array
https://askubuntu.com/a/597414

I'm not sure how you would make a custom keybaord shortcut (like a hotkey or something) but if you're working from the commandline and want to make a long command shorter, you could use an alias in your .bashrc or .bash_profile file

alias ls='ls -la'

if it's more complicated, you make a bash script and make it executable and, if you want to access it from wherever you are, add the folder it's in to your PATH varible

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top