Created
August 26, 2014 07:11
-
-
Save Caerostris/83fcda921ebf8e3df9fd to your computer and use it in GitHub Desktop.
This is a bash script for Ubuntu which registers a keyboard shortcut.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ "$#" -ne 3 ]; then | |
echo "Usage: $0 name command binding" | |
echo "Example: $0 \"screenshot\" \"gnome-screenshot\" \"<Primary><Alt>s\"" | |
exit | |
fi | |
GSETTINGS_PATH="org.gnome.settings-daemon.plugins.media-keys" | |
KEY_PATH="/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings" | |
GSETTINGS="gsettings set $GSETTINGS_PATH.custom-keybinding:$KEY_PATH" | |
i=0 | |
while [ "$(gsettings get $GSETTINGS_PATH.custom-keybinding:$KEY_PATH/custom$i/ name)" != "''" ] | |
do | |
i=$(( $i + 1 )) | |
done | |
CK=$(gsettings get $GSETTINGS_PATH custom-keybindings) | |
if [ "$CK" == "@as []" ]; then | |
gsettings set $GSETTINGS_PATH custom-keybindings "['$KEY_PATH/custom0/']" | |
else | |
gsettings set $GSETTINGS_PATH custom-keybindings "${CK%]}, '$KEY_PATH/custom$i/']" | |
fi | |
$GSETTINGS/custom$i/ name "$1" | |
$GSETTINGS/custom$i/ command "$2" | |
$GSETTINGS/custom$i/ binding "$3" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment