我有以下脚本(/home/vitidn/Downloads/adjust_contrast.sh)来调整显示对比度:
#!/bin/sh
export DISPLAY=":0"
echo "adjust the display..."
xrandr --display :0 --output eDP1 --prop --verbose --gamma 0.5:0.5:0.45
如果我从cmd行运行但无法从crontab
运行,它可以正常工作它还包含所有权限:
-rwxrwxrwx 1 root root 167 Jan 8 10:04 /home/vitidn/Downloads/adjust_contrast.sh
我创建了一个包含以下内容的crontab(带有sudo):
* * * * * /home/vitidn/Downloads/adjust_contrast.sh > /tmp/adjust_contrast.output
在/tmp/adjust_contrast.output中,脚本会相应地运行,但xrandr otuput的一部分无法找到:
adjust the display...
我怀疑它与某项许可有关,但仍然无法确定它。
感谢您的帮助
答案 0 :(得分:2)
更新:为我的脚本添加以下权限解决了我的问题(从env获取)
export XAUTHORITY=/home/vitidn/.Xauthority