Add custom keybindings for any command
This document (7023429) is provided subject to the disclaimer at the end of this document.
Need to script the process to provide the key binding to other systems.
The graphic method in Gnome is to select from the menu 'System Tools --> Settings' then under 'Hardware' select 'Keyboard'.
In the Keyboard settings select 'Custom Shortcuts' on the left and click the + button near the bottom. Enter a name for the shortcut (let's use 'File Browser') and what command to run which in this case is 'nautilus'. Click on Add to save the settings.
Finally, to the right of the new entry click directly on 'Disabled' then press the key combination to assign to this key binding. In this case it would be 'Super Key-e'. The key binding takes effect immediately. Press the key combination to check the results. The Nautilus file browser should pop up.
To perform the same process via command line do the following. These steps assume that there are no other custom key bindings assigned. If there are, or could be, then an additional step should be taken to list the current custom key binding entries and then add this one with the appropriate number assigned. Further explanation below.
The following commands must be run as the user.
Command to create the 'custom0' key binding:
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/']"
Command to enter the name of the binding:
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ name 'File Browser'
Command to enter the command to run:
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ command 'nautilus'
Command to enter the key combination that will run the command:
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ binding '<Super>s'
The key binding should be in effect after entering the last command. If it is not working try logging out and back in again.
If other key combinations are wanted, the key names in the standard key bindings can used as an example. For example, Alt, Ctrl, Shift, Left, Right, Up, Down, Page Up, Page Down, etc. To use Ctrl+F1 it would be entered '<Ctrl>F1'.
gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings
If no custom key bindings exist the value returned will be "@as ". If one or more exists then it will return what we entered above and may include additional entries similar to this:
If an additional key binding needs to be added in addition to what is there then the script will need to write the current value along with a new entry for custom#, in this case custom2. Then the other commands above would need to run for the same custom#.
This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.
- Document ID:7023429
- Creation Date: 09-Oct-2018
- Modified Date:03-Mar-2020
- SUSE Linux Enterprise Desktop
- SUSE Linux Enterprise Server
For questions or concerns with the SUSE Knowledgebase please contact: firstname.lastname@example.org