dconf load / < [...]
단축키를 사용하는 방법이 있나요? 하지만강제로 다시 로그인할 필요가 없습니다.사용자? 그리고/또는 관리자 권한이 없을 수도 있나요?
다음과 같은 입력 파일을 사용하고 있습니다.
[org/gnome/settings-daemon/plugins/media-keys]
custom-keybindings=['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/']
[org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0]
binding='<Super>c'
command='gnome-calculator'
name='Calculator'
[org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1]
binding='<Super>z'
command='gnome-system-monitor'
name='System Monitor'
이러한 설정은 새 세션이 시작될 때까지 적용되지 않습니다.
답변1
GSettings를 사용할 수 있습니다.
간단한 스크립트:
#!/bin/bash
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/', '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/']"
# Keybind 0
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ binding "<Super>c"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ command "gnome-calculator"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ name "Calculator"
# Keybind 1
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ binding "<Super>z"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ command "gnome-system-monitor"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ name "System Monitor"
답변2
이 목적을 위해 사용자 정의 스크립트를 작성했습니다.
용법:
add_keyboard_shortcut "MyShortcut#1" "gedit" "<Control>F8"
스크립트는 다음과 같습니다.
#!/bin/bash
has_gsettings=$(which gsettings)
if [[ ! -z "$has_gsettings" ]]; then
function add_keyboard_shortcut ()
{
existing_shortcut_string=$(gsettings get org.gnome.settings-daemon.plugins.media-keys custom-keybindings)
exst_str_len=$((${#existing_shortcut_string}))
if (( $exst_str_len < 9 )); then
existing_shortcut_count=0
else
IFS=', ' read -ra existing_shortcut_array <<< "$existing_shortcut_string"
existing_shortcut_count="${#existing_shortcut_array[@]}"
fi
new_shortcut_index=$(("$existing_shortcut_count"))
declaration_string=' ['
for (( i=0; i<="$existing_shortcut_count"; i++ )); do
if (( $i == 0 ))
then
declaration_string="$declaration_string""'/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom$i/'"
else
declaration_string="$declaration_string"", '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom$i/'"
fi
done
declaration_string="$declaration_string"']'
if [[ ! -z "$1" ]] && [[ ! -z "$2" ]] && [[ ! -z "$3" ]]; then
printf "\nFound %s existing custom shortcuts.\n\n" "$existing_shortcut_count"
printf 'Setting new custom keyboard shortcut "%s" => %s' "$1" "$2"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom$new_shortcut_index/ name "$1"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom$new_shortcut_index/ command "$2"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom$new_shortcut_index/ binding "$3"
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "${declaration_string}"
else
printf "\n\nYou are missing input arguments.\n\nThis command requires 3 arguments...\n\nSyntax is add_keyboard_shortcut 'Name' 'Command' 'Shorcut'\n\n\nFor example\n\n add_keyboard_shortcut 'Open Nautilus' 'nautilus' '<Control>F3'\n\n\n\n\n\nCommon Key Abbreviations:\n\n";
printf 'Super key: <Super>\nControl key: <Primary> or <Control>\nAlt key: <Alt>\nShift key: <Shift>\nnumbers: 1 (just the number)\nSpacebar: space\nSlash key: slash\nAsterisk key: asterisk (so it would need `<Shift>` as well)\nAmpersand key: ampersand (so it would need <Shift> as well)\n\na few numpad keys:\nNumpad divide key (`/`): KP_Divide\nNumpad multiply (Asterisk):KP_Multiply\nNumpad number key(s): KP_1\nNumpad `-`: KP_Subtract\n\n\n\nList all gsettings keys:\n gsettings list-recursively';
return -1;
fi
}
fi
답변3
다시 시작할 수도 있습니다 gnome-settings-daemon
. 다시 시작한 후에 새 매개변수가 고려됩니다.