Skip to content

Instantly share code, notes, and snippets.

@tcely
Created March 10, 2016 18:54
Show Gist options
  • Save tcely/c743b51c7919db9adad4 to your computer and use it in GitHub Desktop.
Save tcely/c743b51c7919db9adad4 to your computer and use it in GitHub Desktop.
Clear shortcuts from Alt+Fn keys in GNOME
#!/bin/bash
# Inspiration from: http://askubuntu.com/questions/126817/how-to-disable-alt-f1-alt-f2-shortcuts
unset -v _key _value _schema
_schema='org.gnome.desktop.wm.keybindings'
while IFS= read -r _key; do
_value="$(gsettings get "$_schema" "$_key")"
while [[ "$_value" =~ \''<Alt>F'[1-9]\' ]] || [[ "$_value" =~ \''<Alt>F1'[0-2]\' ]]; do
#_value="$(sed -e "s/\(, \)\?${BASH_REMATCH[0]}\(, \)\?//;s/''/', '/;" <<<"$_value")"
_value=${_value/"${BASH_REMATCH[0]}"}
_value=${_value/, ,/,}
_value=${_value/, ]/]}
_value=${_value/[, /[}
gsettings set "$_schema" "$_key" "$_value"
printf -- 'Set "%s:%s" to "%s"\n' "$_schema" "$_key" "$_value" ;
done
done < <(gsettings list-keys "$_schema")
unset -v _key _value _schema
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment