我有一台 MacBook Pro,我正在绑定脚本来控制键盘上的背光级别。我写了两个脚本,它们工作得很好,我只是无法让它们在按键上运行。我在配置文件中使用名为 .xbindkeysrc 的配置文件设置并运行 xbindkeys 我尝试将脚本绑定到我的特殊功能键(与 fn 同一行)。我知道我的配置文件加载正确,因为当我运行时,xbindkeys -s
它显示了当前未工作的两个尝试绑定。这是 my.xbindkeysrc 文件的内容
###########################
# xbindkeys configuration #
###########################
#
# Version: 0.1.3
#
# If you edit this, do not forget to uncomment any lines that you change.
# The pound(#) symbol may be used anywhere for comments.
#
# A list of keys is in /usr/include/X11/keysym.h and in
# /usr/include/X11/keysymdef.h
# The XK_ is not needed.
#
# List of modifier (on my keyboard):
# Control, Shift, Mod1 (Alt), Mod2 (NumLock),
# Mod3 (CapsLock), Mod4, Mod5 (Scroll).
#
# Another way to specifie a key is to use 'xev' and set the
# keycode with c:nnn or the modifier with m:nnn where nnn is
# the keycode or the state returned by xev
#
# This file is created by xbindkey_config
# The structure is :
# # Remark
# "command"
# m:xxx + c:xxx
# Shift+...
#keystate_numlock = enable
#keystate_scrolllock = enable
#keystate_capslock = enable
"bash /opt/keyLightInc.sh"
m:0x0 + c:238
XF86KbdBrightnessUp
"bash /opt/keyLightDec.sh"
m:0x0 + c:237
XF86KbdBrightnessDown
#
# End of xbindkeys configuration
我从详细选项开始。这是输出:
screen 0 for window 259
Start program with fork+exec call
sudo: no tty present and no askpass program specified
答案1
如果您的sudoers
文件设置了该requiretty
选项,则您只能从终端调用 sudo。
如果您的sudoers
文件没有设置该requiretty
选项,那么您可以从任何地方调用 sudo,但如果它提示输入密码,则需要终端。消息“sudo: no tty present and no Askpass program specified”表示 sudo 尝试提示您输入密码,但失败。
您可以传递-A
选项来告诉 sudo 使用不同的方法来提示您输入密码。由于您在 X11 中运行,因此您可以使用ssh-askpass
随 OpenSSH 分发的程序,该程序会在 X11 窗口中提示输入密码。
sudo -A /usr/bin/ssh-askpass whatever-command-you-need-to-execute-as-root