如何使用 xset 点亮 Caps Lock 指示灯?
我编写了一个小 fetchmail 脚本,用于检查远程服务器并在收到新邮件时播放音频文件。我还想在邮件可用时点亮我的键盘灯之一,但我遇到了问题。我可以用这个点亮滚动锁定灯:
/usr/bin/xset led named "Scroll Lock"
但我不能以同样的方式点亮大写锁定:
/usr/bin/xset led named "Caps Lock"
我尝试用数字(1-6)指定按键,但尽管更改了神秘的“LED面罩” (用“xset q”可见)我没有看到灯光有任何变化。
这是因为我将 Caps Lock 键映射为另一个 Ctrl 键而损坏了吗?
在 ~/.Xmodmap 中,我得到:
keycode 66 = Control_L
clear Lock
add Control = Control_L
我不想切换大写锁定,只想切换灯光。有办法做到这一点吗?
进一步说明
这是在 x86 kubuntu lucid 机器上,但我稍后会迁移到 debian。我在 python 守护进程中以非特权用户身份运行该脚本。以 root 身份运行相同的脚本将不起作用,因为 fetchmail 是为我自己配置为用户的。最后,这一切都在 tmux 会话中运行。
当我开始这个过程时,我读到了有关 setleds 的信息,但它似乎仅限于非 x 会话中的终端。
以 root 身份登录并运行 'setleds -D +caps < /dev/tty7' 可以工作,但运行 'sudo setleds -D +caps < /dev/tty7' 给我一个权限被拒绝的错误。
xset 命令似乎非常适合我的应用程序,它只是拒绝更改 Caps Lock 指示灯。
I wrote a little fetchmail script that checks the remote server and plays an audio file when I have new mail. I also wanted to also light up one of my keyboard lights when the mail was available but I ran into a problem. I am able to light up the scroll lock light with this:
/usr/bin/xset led named "Scroll Lock"
But I can't light up the Caps Lock in the same way:
/usr/bin/xset led named "Caps Lock"
I tried specifying the key with a number (1-6) but despite changing the mysterious 'LED mask' (visible with 'xset q') I saw no change to the lights.
Is this broken because I've mapped my Caps Lock key as another Ctrl?
In ~/.Xmodmap I've got:
keycode 66 = Control_L
clear Lock
add Control = Control_L
I don't want to toggle caps lock, just the light. Is there a way to do this?
Further Explanation
This is on a x86 kubuntu lucid machine but I will migrate to debian later. I'm running the script as a unprivileged user in a python daemon. Running the same script as root won't work because fetchmail is configured for myself as a user. And finally, this is all run in a tmux session.
When I began this process I read about setleds but it seems to be restricted to terminals in non x sessions.
Logging in as root and running 'setleds -D +caps < /dev/tty7' works but running 'sudo setleds -D +caps < /dev/tty7' gives me a permission denied error.
The xset command seems perfect for my application, it just refuses to change the Caps Lock light.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
root下执行:
setleds -D +caps
setleds -D +caps
setleds -D +caps
setleds -D +caps
/dev/console
很黑客,但对我有用:)
Execute under root:
setleds -D +caps < /dev/console
Hackish, but works for me :)
是否需要是
xset
?你用过setleds
吗?简要概述:Linux / Unix 命令:setleds
Does it need to be
xset
? Have you ever usedsetleds
?Brief overview: Linux / Unix Command: setleds
没有
root
权限的xset
使用
sed
编辑/usr/share/X11/xkb/compat/ledcaps
。无论是否重新启动,此更改都是永久性的。注销并再次登录后,现在可以使用以下命令控制 Caps Lock LED,无需任何
root
权限:xset
withoutroot
privilegesEdit
/usr/share/X11/xkb/compat/ledcaps
once usingsed
. This change remains permanent, regardless of any reboots.After logging out and in again, the Caps Lock LED can now be controlled without any
root
privileges using the commands:Caps Lock 指示灯(非功能)关闭
Caps Lock 指示灯(非功能)亮起
Caps Lock led (not the functionality) OFF
Caps Lock led (not the functionality) ON