You are not logged in.

#1 2013-08-11 15:00:04

buntwo
Member
Registered: 2012-02-14
Posts: 14

Trouble with systemd units running after wakeup

I have a laptop and a monitor docking station, which sometimes I plug into after my laptop is asleep. The dock is connected to an external monitor. I wrote a script that detects if there is a monitor attached and activates that if so (1st script below). I tried writing a systemd unit that would run this at wakeup, but it does not work. When I logged stderr, it complains that it cannot open display :0. I'm wondering if my unit is written incorrectly, eg, started at the wrong time or something? Thanks.

The unit:

[Unit]
Description=Configure monitor settings
After=suspend.target

[Service]
User=%I
Type=simple
Environment=DISPLAY=:0
ExecStart=/home/brian/utils/monitor-config-dock.sh

[Install]
WantedBy=suspend.target

monitor-config-dock.sh:

DISPLAY=":0.0"
XAUTHORITY="/home/brian/.Xauthority"

TMP=$(disper -l)
lines="$(wc -l <<<$TMP)"
num=$((lines/2))

if [[ ("$num" -eq "2") ]] && grep -q "DP2" <<<"$TMP"
then
    xrandr --output DP2 --auto --output LVDS1 --off
    /home/brian/utils/set_modmap.sh
elif [[ "$num" -eq "1" ]]
then
    xrandr --auto
fi

killall trayer 2> /dev/null

/usr/bin/env DISPLAY=:0 /usr/bin/trayer --edge top --align right --SetDockType true --SetPartialStrut true --expand true --widthtype percent --width 10 --transparent true --alpha 0 --tint 0x000000 --height 17 &

Offline

Board footer

Powered by FluxBB