如何在 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']"

相關內容