我正在学习 bash 脚本,通过编写一个脚本来设置我的所有(或大部分)Ubuntu 18.04 自定义。其中一个是我的键盘快捷键。
我在用着这个答案配置热键的策略。但是我发现它只接受我设置的前 8 个自定义快捷键。我的意思是,我存储在custom0
和custom7
插槽之间的热键已被保存,但其他所有热键都被忽略了。
有人知道可能发生了什么吗?
这是我正在使用的脚本:
# Terminal
$(dconf write /org/gnome/terminal/legacy/keybindings/next-tab "'<Alt>w'")
$(dconf write /org/gnome/terminal/legacy/keybindings/prev-tab "'<Alt>a'")
# Music
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/play "'<Super>KP_Separator'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/next "'<Super>KP_Decimal'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/previous "'<Super>KP_Divide'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/volume-up "'<Super>KP_Add'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/volume-down "'<Super>KP_Subtract'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/volume-mute "'<Super>KP_Multiply'")
# Launch
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/www "'<Primary><Alt>c'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/home "'<Primary><Alt>f'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/binding "'<Primary><Alt>k'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/command "'gnome-control-center keyboard'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/name "'Shortcuts settings'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/binding "'<Primary><Alt>equal'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/command "'env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/gnome-calculator_gnome-calculator.desktop /snap/bin/gnome-calculator %U'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/name "'Calculator'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3/binding "'<Primary><Alt>a'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3/command "'atom ~/.fragatron'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3/name "'Atom'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom4/binding "'<Primary><Alt>y'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom4/command "'/opt/google/chrome/google-chrome --profile-directory=Default --app-id=eeaafbmfeofhhjpjklgoobllogkjdgap'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom4/name "'YouTube Music'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom5/binding "'<Primary><Alt>z'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom5/command "'/opt/google/chrome/google-chrome --profile-directory=Default --app-id=lilmhcaoekddncecbphbjdbjccdbneij'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom5/name "'Google Tradutor'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom6/binding "'<Primary><Alt>g'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom6/command "'/opt/google/chrome/google-chrome --profile-directory=Default --app-id=mmlonmkggdiafehdajlempfflcdfddna'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom6/name "'GitHub'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom7/binding "'<Primary><Alt>KP_Separator'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom7/command "'toggle-sound-output'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom7/name "'Toggle sound-output'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom8/binding "'<Primary><Shift>KP_1'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom8/command "'profile-info name'")
$(dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom8/name "'Profile Name'")
答案1
好吧,答案比想象的要简单。出于某种原因,在 Ubuntu 18.04 LTS Bionic Beaver 中,我无法设置超过 9 个自定义快捷方式,只能像图中这样书写。
为了解决这个问题,只需custom-keybindings
用整个自定义快捷方式列表覆盖该属性:
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "[\
'/org/gnome/settings-daemon/plugins/media-keys/custom-keybinding/custom1/', \
'/org/gnome/settings-daemon/plugins/media-keys/custom-keybinding/custom2/', \
'/org/gnome/settings-daemon/plugins/media-keys/custom-keybinding/custom3/', \
'/org/gnome/settings-daemon/plugins/media-keys/custom-keybinding/custom4/', \
'/org/gnome/settings-daemon/plugins/media-keys/custom-keybinding/custom5/', \
'/org/gnome/settings-daemon/plugins/media-keys/custom-keybinding/custom6/', \
'/org/gnome/settings-daemon/plugins/media-keys/custom-keybinding/custom7/', \
'/org/gnome/settings-daemon/plugins/media-keys/custom-keybinding/custom8/' \
]"
我尝试过每个自定义键绑定使用不同的名称(非编号),并且没有任何问题。
我在这里注册希望它能够帮助到别人!