![将命令行绑定到按键](https://linux22.com/image/840109/%E5%B0%86%E5%91%BD%E4%BB%A4%E8%A1%8C%E7%BB%91%E5%AE%9A%E5%88%B0%E6%8C%89%E9%94%AE.png)
有没有办法让我每次按下某个按钮时都激活这个命令行?
xdotool key XF86MonBrightnessDown
我的意思是我该如何将它绑定到按键上?另外,哪一个键码很重要,绑定时需要使用?扫描码键码还是按键编号?
答案1
如果您转到系统▸偏好设置▸键盘快捷键,您应该能够添加您的命令并设置键绑定。
替代方法 - 将其制作成脚本
首先,打开一个终端(Ctrl++ Alt)T
sudo touch /bin/anyName
sudo chmod +x /bin/anyName
sudo gedit /bin/anyName
将其放置在 anyName 文件中:
#!/bin/bash
xdotool key XF86MonBrightnessDown
打开键盘快捷键应用程序。
创建一个新的自定义快捷键。
将命令设置为“anyName”,然后选择组合键(这可以通过按下键来完成,Ubuntu 将识别您按下了哪个键。您不必担心扫描码或键码;只需输入您想要激活命令的组合键即可)。
希望这可以帮助。
答案2
对我来说根据http://ubuntuforums.org/archive/index.php/t-1680158.html该接收器有效:
xdotool key --clearmodifiers XF86MonBrightnessDown
而从man xdtool
它的含义来看:
CLEARMODIFIERS
Any command taking the --clearmodifiers flag will attempt to clear any
active input modifiers during the command and restore them afterwards.
For example, if you were to run this command:
xdotool key a
The result would be 'a' or 'A' depending on whether or not you were
holding the shift key on your keyboard. Often it is undesirable to have
any modifiers active, so you can tell xdotool to clear any active
modifiers.
The order of operations if you hold shift while running 'xdotool key
--clearmodifiers a' is this:
1. Query for all active modifiers (finds shift, in this case)
2. Try to clear shift by sending 'key up' for the shift key
3. Runs normal 'xdotool key a'
4. Restore shift key by sending 'key down' for shift
The --clearmodifiers flag can currently clear of the following:
· any key in your active keymap that has a modifier associated with
it. (See xmodmap(1)'s 'xmodmap -pm' output)
· mouse buttons (1, 2, 3, 4, and 5)
· caps lock