autorandr icon indicating copy to clipboard operation
autorandr copied to clipboard

Problem with systemd service and a better solution

Open Vladimir-csp opened this issue 6 years ago • 4 comments
trafficstars

With autorandr 1.8.1 I get default profile on wakeup instead of a saved one. This happens due to autorandr running too early via systemd service in sleep target.

There is a mechanism in systemd for sleep hooks specifically with ability to specify when to run action (pre|post).

Disable autorandr.service (remove sleep.target installation) and add this to /lib/systemd/system-sleep/autorandr-wakeup

#!/bin/sh
case $1 in
  post)
    /usr/bin/autorandr --batch --change
    ;;
esac

Vladimir-csp avatar Aug 28 '19 15:08 Vladimir-csp

/lib/systemd/system-sleep/ is an executable file on my system. Do you potentially mean /usr/lib/systemd/system-sleep?

Flowdalic avatar Sep 03 '19 11:09 Flowdalic

systemd-sleep is an executable, system-sleep is a directory.

/lib/systemd and /usr/lib/systemd are the same thing on my system since usrmerge is applied.

Vladimir-csp avatar Sep 03 '19 16:09 Vladimir-csp

Fine with me. One thought though:

I've got to admit I'm getting less and less convinced that the systemd (or other system wide hooks) integration is the best course of action. I've recently used srandr and it's way more reliable for me.

What do you think about making a autorandr_launcher launched via autostart in an X11 session the default, and only using systemd if explicitly requested?

phillipberndt avatar Sep 13 '19 14:09 phillipberndt

If X has a usable mechanism to listen to display events that also is reliable on wakeup, then it would be a better solution than going through device and systemd hooks.

Vladimir-csp avatar Sep 13 '19 16:09 Vladimir-csp