You are not logged in.
Pages: 1
hy guys im having a bit of had ack here i have this script here:
#!/bin/bash
xrandr | grep DP- | grep " connected ";
if [ $? -eq 0 ]; then
echo "other screens connected"
else
pm-suspend
fi
and i placed this script to run here :
button/lid)
case "$3" in
close)
logger 'LID closed'
suspend.sh
;;
open)
logger 'LID opened'
;;
*)
logger "ACPI action undefined: $3"
;;
esac
my problem is the script runs properly if i execute it as (user or root)
but when i do close the lid and the script acpid execute it for some reason that i dont know it dont get the extra screens and suspend anyway
some one could point me the error here ??
thanks on advance
Last edited by wmunny (2014-08-26 00:20:22)
Offline
The difference is probably the DISPLAY variable being ":0.0", versus unset.
Try adding, before the xrandr line in your script:
export DISPLAY=":0.0"
Offline
Did you disable the lid detect logic in systemd?
Are you sure that the acpi deamon is running?
Edit: BTW, Welcome to Arch Linux
Last edited by ewaller (2014-08-25 20:50:44)
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
ewaller
yes i did ignore lid on logind
and apci is running
brebs
that didn't work
Offline
OK, next step: Redirect the output of those commands somewhere useful, e.g.:
xrandr >> /tmp/x.log 2>&1
Offline
looks like you are right :
Can't open display :0.0
but i still have no idea how to fix it
Last edited by wmunny (2014-08-25 21:08:39)
Offline
xrandr | grep DP- | grep " connected ";
#can be reduced to
xrandr | grep 'DP-.* connected';
You could also include whoami and env in the log.
Why are you running this through a script? Those few lines could be left in the handler, you modified the file anyway.
Last edited by emeres (2014-08-25 22:43:11)
Offline
ok guys i finally got a fix here
using this changes:
#!/bin/bash
user="$(who -u | grep -F '(:0)' | head -n 1 | awk '{print $1}')"
su -c "DISPLAY=:0.0 xrandr | grep DP- | grep ' connected '" "$user";
if [ $? -eq 0 ]; then
echo "worked" >> /tmp/x.log 2>&1
else
pm-suspend
fi
on the script did the trick thanks everyone
Last edited by wmunny (2014-08-26 00:20:31)
Offline
user="$(who -u | grep -F '(:0)' | head -n 1 | awk '{print $1}')"
#can be reduced to
user="$(who -u | awk '/(:0)/{print $1; exit}')"
Offline
I forgot - XAUTHORITY is needed, as well as DISPLAY.
Your normal user has *both* of these set, which is why using su works.
Offline
Pages: 1