feat(gnome): create custom keyboard shortcuts
Add script to automate creation of GNOME custom keyboard shortcuts. - Detect existing custom keybindings - Find the next available custom shortcut slot - Register new custom-keybinding entries automatically - Configure shortcut name, command, and key combination - Preserve existing GNOME keyboard shortcuts - Add usage documentation and examples - Include helper notes for discovering key names with xev - Simplify scripting and workstation setup automation
This commit is contained in:
1 parent
fbcbf008ea
commit
8d98c134d0
2 files changed
+124
-39
No files matched your search
@@ -1,39 +0,0 @@
|
||||
#!/bin/bash
|
||||
if [ $# -lt 3 ]; then
|
||||
echo "Usage <new_name> <new_cmd> <key_combo>"
|
||||
exit 1;
|
||||
fi
|
||||
counter=0;
|
||||
list="["
|
||||
num=0
|
||||
while read -r line; do
|
||||
list="$list$(echo $line | sed 's/\]//g' | sed 's/\[//g'), "
|
||||
ret="$(printf "%s\n" "$line" | grep "custom$counter")"
|
||||
if [ "$ret" == "" ]; then
|
||||
num=$counter
|
||||
break;
|
||||
else
|
||||
(( counter++ ))
|
||||
num=$counter;
|
||||
fi
|
||||
done < <(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings | sed 's/, /\n/g')
|
||||
key="org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:"
|
||||
custom="/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom$num/"
|
||||
if [[ $list = *"@as"* ]]; then
|
||||
list="['$custom']"
|
||||
else
|
||||
list="$list'$custom']"
|
||||
fi
|
||||
echo $list
|
||||
new_name=$1
|
||||
new_cmd=$2
|
||||
key_combo=$3
|
||||
echo "$key$custom $new_name $new_cmd $key_combo"
|
||||
|
||||
#key_str="$(xev)"
|
||||
#echo $key_str | sed 's/KeyRelease/\nKeyRelease/g' | sed 's/KeyPress/\nKeyPress/g' | grep KeyPress | sed 's/keysym/\nkeysym/g'| sed 's/same_screen/\nsame_screen/g' | grep keysym | grep -o -P '(?<=, ).*(?=\),)' | sed 's/_L//g' | sed 's/_R//g'
|
||||
#exit
|
||||
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "$list"
|
||||
gsettings set $key$custom name "$new_name"
|
||||
gsettings set $key$custom command "$new_cmd"
|
||||
gsettings set $key$custom binding "$key_combo"
|
||||
Reference in new issue
Block a user