如何在 GNOME 3 中分配用于切换工作空间的冗余快捷键?

如何在 GNOME 3 中分配用于切换工作空间的冗余快捷键?

我想将Super+1Super+绑定Home为 GNOME 3 中“切换到工作区 1”操作的快捷方式。有没有办法做到这一点?

我认为要实现这一目标,必须有一种方法可以将多个键盘快捷键分配给同一操作,或者必须有一种方法可以通过命令行操作切换工作区(这可以让我为其创建一个快捷方式)在“自定义快捷方式”部分)。但我不确定这些是否可能......

答案1

是的,这是一个dconf设置,值是一个字符串数组,这意味着它接受多个快捷方式。dconf-editor如果您导航到, 您可以通过以下方式做到这一点

/org/gnome/desktop/wm/keybindings/switch-to-workspace-1

并转动使用默认值 OFF然后插入定制值:['<Super>Home', '<Super>1']

在此输入图像描述


或者,如果您更喜欢 CLI,您可以使用dconfgsettings例如

gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-1 "['<Super>Home', '<Super>1']"

请记住,这些值必须用引号引起来并用逗号+空格分隔。

答案2

添加Super+1和好友以进行工作区切换dconf

dconf write /org/gnome/desktop/wm/keybindings/switch-to-workspace-1 "['<Super>Home', '<Super>1']"
dconf write /org/gnome/desktop/wm/keybindings/switch-to-workspace-2 "['<Super>2']"
dconf write /org/gnome/desktop/wm/keybindings/switch-to-workspace-3 "['<Super>3']"
dconf write /org/gnome/desktop/wm/keybindings/switch-to-workspace-4 "['<Super>4']"

它不会在 Gnome 3 中创建工作区,而 Gnome 3 会在前一个工作区上存在窗口时动态创建工作区。

答案3

在这里分享我的脚本:

# script from https://unix.stackexchange.com/questions/361551/how-can-i-assign-redundant-shortcuts-for-switching-workspaces-in-gnome-3
# disable unnecessary dock app launch shortcuts
# https://ask.fedoraproject.org/t/super-1-keyboard-shortcuts-not-working/15187
for i in {1..9}; do gsettings set org.gnome.shell.keybindings switch-to-application-$i "[]"; done

for i in $(seq 1 9); do dconf write /org/gnome/desktop/wm/keybindings/switch-to-workspace-$i "['<Super>$i', '<Control><Alt>$i']"; done
# And a similar snippet for moving to nth workspace:
for i in $(seq 1 9); do dconf write /org/gnome/desktop/wm/keybindings/move-to-workspace-$i "['<Super><Shift>$i','<Control><Shift>$i']"; done

# in the end clean it up.
dconf write /org/gnome/desktop/wm/keybindings/switch-to-workspace-1 "['<Super>Home','<Super>1', '<Control><Alt>1']" 
# caused by gesttings  set org.gnome.shell.keybindings switch-to-application-1
# replace '<Super>1'  with '<Super>0' since it always pops up nautilus.
dconf write /org/gnome/desktop/wm/keybindings/move-to-workspace-1 "['<Super><Shift>Home', '<Super><Shift>1','<Control><Shift>1']"

dconf write /org/gnome/desktop/wm/keybindings/switch-to-workspace-last "['<Super>End', '<Control><Alt>End']"
dconf write /org/gnome/desktop/wm/keybindings/move-to-workspace-last "['<Super><Shift>End','<Control><Shift>End']"

相关内容