user1560335
user1560335

Reputation: 79

Can't execute xrandr command in crontab(even with $DISPLAY arg supplied)

I have the following script(/home/vitidn/Downloads/adjust_contrast.sh) to adjust display contrast:

#!/bin/sh

export DISPLAY=":0"
echo "adjust the display..."
xrandr --display :0 --output eDP1 --prop --verbose --gamma 0.5:0.5:0.45

it works fine if I run from cmd line but failed to run from crontab

It also has all perms:

-rwxrwxrwx 1 root root 167 Jan  8 10:04 /home/vitidn/Downloads/adjust_contrast.sh

I create a crontab(with sudo) with the following content:

* * * * * /home/vitidn/Downloads/adjust_contrast.sh > /tmp/adjust_contrast.output

In /tmp/adjust_contrast.output, the script is run accordingly but part of xrandr otuput is no where to be found:

adjust the display...

I suspect that it has somethings to do with a permission but still can't pinpoint it.

Thank you for your helps

Upvotes: 0

Views: 1741

Answers (1)

user1560335
user1560335

Reputation: 79

Update: add the following permission to my script solved my problem(get it from env)

export XAUTHORITY=/home/vitidn/.Xauthority

Upvotes: 2

Related Questions