Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 47 lines (38 sloc) 1.49 KB
#!/bin/sh
#Bodge as the pine DRM driver does not support suspend/resume
#d_ed wrote power management support in there, but it does not work..yet
#need to reset the driver and then restore the original mode
#but we lose that after reset...best to just let userspace do it
LOGFILE=/tmp/systemd_suspend_test
# Find the "most active" user session. Only sessions with a seat
# count, so if a PB only has ssh'ed in users this will fall over.
active_session=""
active_user=""
# Reads two lines of loginctl output (name and active) and
# sets active_user to name, if active is yes.
for s in $( loginctl list-sessions --no-legend | grep 'seat[0-9]' | sed -e 's/^ *//' -e 's/ .*//' ) ; do
_active=$( loginctl show-session -p Name -p Active --value "$s" | { read _name ; read _active ; test yes = "$_active" && echo "$_name" ; } )
if test -n "$_active" ; then
active_user="$_active"
break
fi
done
if test pre = "$1" ; then
: > "$LOGFILE" # Empty it out
fi
if test -z "$active_user" ; then
echo "No active user session found, ignoring screen." >> "$LOGFILE"
loginctl list-sessions >> "$LOGFILE"
exit 1
fi
echo "Screen action $1 at $(LC_ALL=C date)" >> "$LOGFILE"
echo " .. session $active_session user $active_user" >> "$LOGFILE"
case $1 in
pre)
sudo -u "$active_user" DISPLAY=:0 xset dpms force off >> "$LOGFILE" 2>&1
;;
post)
sudo -u "$active_user" DISPLAY=:0 xset dpms force off >> "$LOGFILE" 2>&1
sudo -u "$active_user" DISPLAY=:0 xset dpms force on >> "$LOGFILE" 2>&1
;;
esac