xrandr weird issue running from a script

Łukasz Maśko ed at yen.ipipan.waw.pl
Tue Nov 8 23:26:12 UTC 2016


Dnia wtorek, 8 listopada 2016 14:19:08 Ratin pisze:
> I am testing this simple script, calling it from php via apache web server.
> But anything to do with xrandr is simply omitted by the scipt while
> everything else include system calls like reboot etc works fine. Initially
> I thought its because the DISPLAY env variable issue but it gets the
> variable correctly in the logs, so now I am totally baffled.
> 
> #! /bin/bash
> 
> #export DISPLAY=:0
> export Dis=$(echo $DISPLAY)
> echo "Display: $Dis" > /var/log/updateDDInfo.log
> 
> checkHDMI=`sudo /usr/bin/xrandr| grep -i "HDMI1.*\ connected"`
> checkDP=`sudo /usr/bin/xrandr --display :0| grep -i "DP1.*\ connected"`
> echo "p.sh: HDMI Check: $checkHDMI " > /var/log/updateDDInfo.log
> echo "p.sh: DP Check: $checkDP " > /var/log/updateDDInfo.log
> 
> 
> If I run from command prompt I get the usual response:
> "p.sh: DP Check: DP1 connected 3840x2160+1920+0 (normal left inverted right
> x axis y axis) 607mm x 345mm"
> 
> Anybody has any clue?

Probably the problem is with X authorization, DISPLAY variable is not enough. 
In my scripts I do something like this:

export XAUTHORITY=/home/users/$USER/.Xauthority
export DISPLAY=:0
export QT_X11_NO_MITSHM=1 # don't now if xrandr needs this, probably not

and then xrandr and other commands work. But these are bash scripts. You have 
to probaby do something similar.
-- 
Łukasz Maśko                                                            _o)
Lukasz.Masko(at)ipipan.waw.pl                                           /\\
Registered Linux User #61028                                           _\_V
Ubuntu: staroafrykańskie słowo oznaczające "Nie umiem zainstalować Debiana"



More information about the xorg mailing list