我正在尝试设置一些肉桂键盘快捷键:
gsettings set org.cinnamon.desktop.keybindings custom-list \
"['custom0', \
'custom1', \
'custom2', \
'custom3', \
'custom4']"
## browser
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ name "browser"
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ command "/home/kaiyin/workspace/bash_scripts/focusRun.sh chromium-browser"
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ binding "['<Primary><Shift><Alt>b']"
## file manager
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ name "fileManager"
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ command "/home/kaiyin/workspace/bash_scripts/focusRun.sh nemo"
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ binding "<Primary><Shift><Alt>f"
## terminal
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/ name "terminal"
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/ command "/home/kaiyin/workspace/bash_scripts/focusRun.sh gnome-terminal"
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2/ binding "<Primary><Shift><Alt>t"
## gmrun
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3/ name "runDialog"
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3/ command "/home/kaiyin/workspace/bash_scripts/focusRun.sh gmrun"
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom3/ binding "<Primary><Shift><Alt>g"但这没有任何效果。我用的是肉桂2.4.5在ubuntu 14.04上。
我知道这可以通过对话框来完成,但是我想在命令行上这样做(更好的自动化选择)。
发布于 2015-04-30 12:29:26
我在Ubuntu14.10下完成了这个任务。这是将创建自定义键绑定“槽”的命令。
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/']"然后设置名称、命令和绑定值。
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ name "shutter"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ command "shutter -s"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/ binding "Print"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ name "shutter"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ command "shutter -f"
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/ binding "<Ctrl>Print"如果我把这与你的肉桂问题进行比较,我猜问题很可能是,你必须用完整的路径完全限定你要添加的每一个项目,如下所示:
gsettings set org.cinnamon.desktop.keybindings custom-list \
"['/org/cinnamon/desktop/keybindings/custom0', \
'/org/cinnamon/desktop/keybindings/custom1', \
'/org/cinnamon/desktop/keybindings/custom2', \
'/org/cinnamon/desktop/keybindings/custom3', \
'/org/cinnamon/desktop/keybindings/custom4']"发布于 2018-03-15 13:19:28
这对我有用(肉桂3.2.7,Debian 9.4):
gsettings set org.cinnamon.desktop.keybindings custom-list \
"['custom0', \
'custom1', \
'custom2', \
'custom3', \
'custom4']"
## browser
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/cinnamon/desktop/keybindings/custom-keybindings/custom0/ name "browser"
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/cinnamon/desktop/keybindings/custom-keybindings/custom0/ command "/home/kaiyin/workspace/bash_scripts/focusRun.sh chromium-browser"
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/cinnamon/desktop/keybindings/custom-keybindings/custom0/ binding "['<Primary><Shift><Alt>b']"
## file manager
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/cinnamon/desktop/keybindings/custom-keybindings/custom1/ name "fileManager"
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/cinnamon/desktop/keybindings/custom-keybindings/custom1/ command "/home/kaiyin/workspace/bash_scripts/focusRun.sh nemo"
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/cinnamon/desktop/keybindings/custom-keybindings/custom1/ binding "['<Primary><Shift><Alt>f']"
## terminal
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/cinnamon/desktop/keybindings/custom-keybindings/custom2/ name "terminal"
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/cinnamon/desktop/keybindings/custom-keybindings/custom2/ command "/home/kaiyin/workspace/bash_scripts/focusRun.sh gnome-terminal"
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/cinnamon/desktop/keybindings/custom-keybindings/custom2/ binding "['<Primary><Shift><Alt>t']"
## gmrun
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/cinnamon/desktop/keybindings/custom-keybindings/custom3/ name "runDialog"
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/cinnamon/desktop/keybindings/custom-keybindings/custom3/ command "/home/kaiyin/workspace/bash_scripts/focusRun.sh gmrun"
gsettings set org.cinnamon.desktop.keybindings.custom-keybinding:/org/cinnamon/desktop/keybindings/custom-keybindings/custom3/ binding "['<Primary><Shift><Alt>g']"通过运行以下命令来验证您的自定义键绑定是否已设置:
dconf dump /org/cinnamon/新绑定也可以在设置GUI中看到
发布于 2015-11-07 19:21:41
我观察到,在我的例子中,用“that”设置快捷方式(/org/cinnamon/desktop/keybindings/custom-keybindings没有(直接)效果。只有当我在GUI中做了一些(甚至是不相关的)更改时,这些快捷方式才会被刷新。
我编写了一个Python程序(基于肉桂GUI的代码),它切换快捷键一个脚本(在F21和Multi_key之间)并具有直接的效果。我想将其修改到您的特定用例应该不会太难。
#!/usr/bin/env python2
import subprocess
from gi.repository import Notify
from gi.repository import Gio, Gdk
CUSTOM_KEYS_PARENT_SCHEMA = "org.cinnamon.desktop.keybindings"
CUSTOM_KEYS_BASENAME = "/org/cinnamon/desktop/keybindings/custom-keybindings"
CUSTOM_KEYS_SCHEMA = "org.cinnamon.desktop.keybindings.custom-keybinding"
curr_shortcut = subprocess.check_output(['gsettings','get', 'org.cinnamon.desktop.keybindings.custom-keybinding:/org/cinnamon/desktop/keybindings/custom-keybindings/custom0/', 'binding'])
custom_num=0
def remove_custom():
keybinding_path='custom0'
custom_path = CUSTOM_KEYS_BASENAME + "/" + keybinding_path + "/"
custom_schema = Gio.Settings.new_with_path(CUSTOM_KEYS_SCHEMA, custom_path)
custom_schema.delay()
custom_schema.reset("name")
custom_schema.reset("command")
custom_schema.reset("binding")
custom_schema.apply()
Gio.Settings.sync()
parent_settings = Gio.Settings(CUSTOM_KEYS_PARENT_SCHEMA)
array = parent_settings.get_strv("custom-list")
existing = False
for entry in array:
if keybinding_path == entry:
existing = True
break
if existing:
array.remove(keybinding_path)
parent_settings.set_strv("custom-list", array)
def add_custom(key):
parent = Gio.Settings.new(CUSTOM_KEYS_PARENT_SCHEMA)
array = parent.get_strv("custom-list")
new_str = "custom" + str(custom_num)
array.append(new_str)
parent.set_strv("custom-list", array)
new_path = CUSTOM_KEYS_BASENAME + "/custom" + str(custom_num) + "/"
new_schema = Gio.Settings.new_with_path(CUSTOM_KEYS_SCHEMA, new_path)
new_schema.delay()
new_schema.set_string("name", 'command_name')
new_schema.set_string("command",'/path/to/script')
new_schema.set_strv("binding",[key])
new_schema.apply()
Gio.Settings.sync()
if 'Multi_key' in curr_shortcut:
remove_custom()
add_custom('F21')
Notify.init ("Shortcut disabled")
SC_ON=Notify.Notification.new ("Shortcut","Shortcut disabled","dialog-information")
SC_ON.set_urgency(0)
SC_ON.show()
else:
remove_custom()
add_custom('Multi_key')
Notify.init ("Shortcut enabled")
SC_OFF=Notify.Notification.new ("Shortcut","Shortcut enabled","dialog-information")
SC_OFF.set_urgency(0)
SC_OFF.show()https://unix.stackexchange.com/questions/174683
复制相似问题