嗨,我正在试着运行这个脚本,当我调用这个脚本时,它会关闭屏幕。
脚本代码:
#!/bin/sh
STATUS=`xset -q | grep "Monitor is" | awk '{print $3}'`
if [ "${STATUS}" = "On" ]
then
xset dpms force off
else
xset dpms force on
fi
exit 0但是当我调用这个脚本时,我得到了这个错误
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 142 (DPMS)
Minor opcode of failed request: 6 (DPMSForceLevel)
Serial number of failed request: 10
Current serial number in output stream: 12发布于 2013-06-21 15:55:57
#!/bin/bash
export DISPLAY=:0.0
if [ $# -eq 0 ]; then
echo usage: $(basename $0) "on|off|status"
exit 1
fi
if [ $1 = "off" ]; then
echo -en "Turning monitor off..."
xset dpms force off
echo -en "done.\nCheck:"
xset -q|grep "Monitor is"
elif [ $1 = "on" ]; then
echo -en "Turning monitor on..."
xset dpms force on
echo -en "done.\nCheck:"
xset -q|grep "Monitor is"
elif [ $1 = "status" ]; then
xset -q|sed -ne 's/^[ ]*Monitor is //p'
else
echo usage: $(basename $0) "on|off|status"
fi从这里:http://systembash.com/content/how-to-turn-off-your-monitor-via-command-line-in-ubuntu/
发布于 2014-04-08 16:55:39
STATUS_MONITOR=$(xset q | grep "Monitor is" | awk '{print $3}')
if [ "$STATUS_MONITOR" == "On" ]; then
echo "Status = "$STATUS_MONITOR
else
echo "Status = "$STATUS_MONITOR
fi这对我很有效。
https://stackoverflow.com/questions/17230192
复制相似问题