autorandr icon indicating copy to clipboard operation
autorandr copied to clipboard

Not working after wake up from sleep.

Open itzmanish opened this issue 4 years ago • 6 comments

Hey @phillipberndt . First of all thanks for this great tool. Recently I have found that autorandr does not work after wake up from sleep/suspend. I tried to do autorandr --change It didn't detected change and also didn't select the suitable profile that is already available. Right now I have to manually do autorandr --change suitable_profile. It would be really helpful if autorandr can automatically detect the current setup and select suitable profile even after waking up from sleep/suspend.

OS : Arch linux Kernel: 5.10.56-1-lts Autorandr version : autorandr 1.11 WM: i3

itzmanish avatar Sep 02 '21 04:09 itzmanish

It should! Something seems to be wrong with the setup reported by your xrandr, as if your driver doesn't report the update until you actively make a change. All autorandr does is parse the output of the xrandr tool.

Now the question is if you can somehow manage to convince it to query for a change in the setup.

Maybe you could execute an innocent xrandr call upon wakeup, before invoking autorandr? E.g. bump the gamma value of a screen you have always connected to some other value and back?

phillipberndt avatar Sep 02 '21 06:09 phillipberndt

Maybe you could execute an innocent xrandr call upon wakeup, before invoking autorandr? E.g. bump the gamma value of a screen you have always connected to some other value and back?

Yeah that I think can be done.

Also I found a weird bug of automatically lowering of brightness on external monitor. However I see full brightness on arandr (xrandr gui). After few times it gets back to its original brightness.

itzmanish avatar Sep 02 '21 07:09 itzmanish

@itzmanish maybe the autorandr systemd service is not started or fails? Can you check

systemctl status autorandr

before and after sleep?

mephinet avatar Nov 04 '21 22:11 mephinet

Same issue here. autorandr --change suitable_profile doesn't work for me though work.

ByteDrummer avatar Dec 01 '22 06:12 ByteDrummer

I'm getting the same behavior but randomly. After a short investigation, my amateur understanding is that the hook (and more generally systemd-sleep) is not triggered by any wake-up from S2Idle state (suspend to idle) which is how my "sleep" is configured. At least:

[Service]
ExecStartPre=/bin/sleep 10
ExecStart=/usr/bin/autorandr --batch --change --default default
Type=oneshot
RemainAfterExit=false
KillMode=process

doesn't do anything after 10 sec. If this interpretation is correct, we'd need to get round systemd hooks.

tpaniaki avatar Mar 26 '23 01:03 tpaniaki

Upon waking my system, my second monitor does not automatically wake up. The primary one does, and I have to power cycle the secondary.

$ systemctl status autorandr
× autorandr.service - autorandr execution hook
     Loaded: loaded (/lib/systemd/system/autorandr.service; enabled; preset: enabled)
     Active: failed (Result: start-limit-hit) since Sat 2023-11-18 05:02:18 PST; 1h 2min ago
    Process: 2107 ExecStart=/usr/bin/autorandr --batch --change --default default (code=exited, status=0/SUCCESS)
   Main PID: 2107 (code=exited, status=0/SUCCESS)
        CPU: 67ms

Nov 18 05:02:18 arctic systemd[1]: Finished autorandr.service - autorandr execution hook.
Nov 18 05:02:18 arctic systemd[1]: autorandr.service: Start request repeated too quickly.
Nov 18 05:02:18 arctic systemd[1]: autorandr.service: Failed with result 'start-limit-hit'.
Nov 18 05:02:18 arctic systemd[1]: Failed to start autorandr.service - autorandr execution hook.
Nov 18 05:02:18 arctic systemd[1]: autorandr.service: Start request repeated too quickly.
Nov 18 05:02:18 arctic systemd[1]: autorandr.service: Failed with result 'start-limit-hit'.
Nov 18 05:02:18 arctic systemd[1]: Failed to start autorandr.service - autorandr execution hook.
Nov 18 05:02:18 arctic systemd[1]: autorandr.service: Start request repeated too quickly.
Nov 18 05:02:18 arctic systemd[1]: autorandr.service: Failed with result 'start-limit-hit'.
Nov 18 05:02:18 arctic systemd[1]: Failed to start autorandr.service - autorandr execution hook.

If I run autorandr --change --default default manually, the second monitor does wake, however, scaling settings are not maintained, so I have to reset the settings manually.

I also see this error log:

$ /usr/bin/autorandr --change --default default   
default (detected)
Failed to apply profile 'default' (line 930):
  Command failed: xrandr --fb 9023x5120 --output HDMI-0 --crtc 1 --gamma 1.0:1.0:1.0 --mode 2560x1440 --pos 0x0 --rate 59.95 --reflect normal --rotate left --transform 2.000000,0.000000,0.000000,0.000000,2.000000,0.000000,0.000000,0.000000,1.000000 --set non-desktop 0 --output DP-0 --crtc 0 --gamma 1.0:1.0:1.0 --mode 3840x2160 --pos 2880x0 --primary --rate 60.00 --reflect normal --rotate normal --transform 1.599991,0.000000,0.000000,0.000000,1.599991,0.000000,0.000000,0.000000,1.000000 --set non-desktop 0 (line 930)

I see a very similar failure log in the journalctl output below:

Command failed: xrandr --fb 9023x5120 --output HDMI-0 --crtc 1 --gamma 1.0:1.0:1.0 --mode 2560x1440 --pos 0x0 --rate 59.95 --reflect normal --rotate left --transform 

Debug output:

~ via  v20.2.0 via 💎 v3.2.2 took 194ms 
09:52:09 PM ➜ autorandr --debug --dry-run --change --force
default (detected) (current)
xrandr --fb 9023x5120 --output HDMI-0 --transform none --output DP-0 --transform none 
xrandr --fb 9023x5120 --output HDMI-0 --crtc 1 --gamma 1.316:1.0:0.769 --mode 2560x1440 --pos 0x0 --rate 59.95 --reflect normal --rotate left --transform 2.000000,0.000000,0.000000,0.000000,2.000000,0.000000,0.000000,0.000000,1.000000 --set non-desktop 0 --output DP-0 --crtc 0 --gamma 1.316:1.0:0.769 --mode 3840x2160 --pos 2880x0 --primary --rate 60.00 --reflect normal --rotate normal --transform 1.599991,0.000000,0.000000,0.000000,1.599991,0.000000,0.000000,0.000000,1.000000 --set non-desktop 0 

I was surprised there are two xrandr commands being emitted. Does that look right?

 via  v20.2.0 via 💎 v3.2.2 took 17ms 
09:58:01 PM ✗ xrandr --listmonitors 
Monitors: 2
 0: +*DP-0 6144/697x3456/392+2880+0  DP-0
 1: +HDMI-0 2880/597x5120/336+0+0  HDMI-0

System Info

$ uname -a
Linux arctic 6.5.0-10-generic #10-Ubuntu SMP PREEMPT_DYNAMIC Fri Oct 13 13:49:38 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/lsb-release
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: /etc/lsb-release
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ DISTRIB_ID=Ubuntu
   2   │ DISTRIB_RELEASE=23.10
   3   │ DISTRIB_CODENAME=mantic
   4   │ DISTRIB_DESCRIPTION="Ubuntu 23.10"
───────┴────────────────────────────────────

$ xrandr
Screen 0: minimum 8 x 8, current 9024 x 5120, maximum 32767 x 32767
DVI-D-0 disconnected (normal left inverted right x axis y axis)
HDMI-0 connected 2880x5120+0+0 left (normal left inverted right x axis y axis) 597mm x 336mm
   2560x1440     59.95*+  69.93
   1920x1080     60.00    59.94    50.00    23.98
   1680x1050     59.95
   1440x900      59.89
   1280x1024     75.02    60.02
   1280x960      60.00
   1280x800      59.81
   1280x720      60.00    59.94    50.00
   1152x864      75.00
   1024x768      75.03    70.07    60.00
   800x600       75.00    72.19    60.32    56.25
   720x576       50.00
   720x480       59.94
   640x480       75.00    72.81    59.94    59.93
DP-0 connected primary 6144x3456+2880+0 (normal left inverted right x axis y axis) 697mm x 392mm
   3840x2160     60.00*+  30.00
   2560x1440     59.95
   1920x1080     60.00    59.94    59.93
   1280x720      59.94
   1024x768      60.00
   800x600       60.32
   720x480       59.94
   640x480       59.94    59.93
DP-1 disconnected (normal left inverted right x axis y axis)

DP-0 is scaled to 125% and HDMI-0 is scaled to 100%

It seems like these are the journalctl logs for "system lock". Looks fine to me.

Nov 01 02:24:33 arctic sudo[24343]: alichtman : a password is required ; PWD=/usr/lib/pm-utils/sleep.d ; USER=root ; COMMAND=/usr/bin/cat /usr/lib/pm-utils/sleep.d/99_autorandr
Nov 01 02:24:36 arctic rtkit-daemon[2737]: Supervising 8 threads of 5 processes of 1 users.
Nov 01 02:24:36 arctic rtkit-daemon[2737]: Supervising 8 threads of 5 processes of 1 users.
Nov 01 02:24:40 arctic sudo[24822]: alichtman : PWD=/usr/lib/pm-utils/sleep.d ; USER=root ; COMMAND=/usr/bin/cat /usr/lib/pm-utils/sleep.d/99_autorandr
Nov 01 02:24:40 arctic sudo[24822]: pam_unix(sudo:session): session opened for user root(uid=0) by (uid=1000)
Nov 01 02:24:40 arctic sudo[24822]: pam_unix(sudo:session): session closed for user root
Nov 01 02:25:01 arctic CRON[28764]: pam_unix(cron:session): session opened for user root(uid=0) by (uid=0)
Nov 01 02:25:01 arctic CRON[28768]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Nov 01 02:25:01 arctic CRON[28767]: pam_unix(cron:session): session opened for user alichtman(uid=1000) by (uid=0)
Nov 01 02:25:01 arctic CRON[28766]: pam_unix(cron:session): session opened for user alichtman(uid=1000) by (uid=0)
Nov 01 02:25:01 arctic CRON[28765]: pam_unix(cron:session): session opened for user alichtman(uid=1000) by (uid=0)
Nov 01 02:25:01 arctic CRON[28770]: (alichtman) CMD (rm ~/.sudo_as_admin_successful)
Nov 01 02:25:01 arctic CRON[28771]: (alichtman) CMD (rm -rf ~/.1password)
Nov 01 02:25:01 arctic CRON[28764]: pam_unix(cron:session): session closed for user root
Nov 01 02:25:01 arctic CRON[28772]: (alichtman) CMD ("/home/linuxbrew/.linuxbrew/bin/open-tab-tracker" --add-datapoint > /dev/null # open_tab_tracker)
Nov 01 02:25:01 arctic CRON[28767]: pam_unix(cron:session): session closed for user alichtman
Nov 01 02:25:01 arctic CRON[28765]: (CRON) info (No MTA installed, discarding output)
Nov 01 02:25:01 arctic CRON[28765]: pam_unix(cron:session): session closed for user alichtman
Nov 01 02:25:01 arctic CRON[28766]: pam_unix(cron:session): session closed for user alichtman
Nov 01 02:25:02 arctic firefox.desktop[5306]: [Parent 5306, Main Thread] WARNING: OnCloseSessionDone error: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: Object does not exist at path “/org/freedesktop/portal/desktop/session/1_124/firefox_com_1password_1password_3794042061”: 'glib warning', file>
Nov 01 02:25:02 arctic firefox[5306]: OnCloseSessionDone error: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: Object does not exist at path “/org/freedesktop/portal/desktop/session/1_124/firefox_com_1password_1password_3794042061”
Nov 01 02:25:06 arctic dbus-daemon[4398]: apparmor="DENIED" operation="dbus_method_call"  bus="session" path="/org/gnome/Mutter/IdleMonitor/Core" interface="org.gnome.Mutter.IdleMonitor" member="GetIdletime" mask="send" name=":1.53" pid=5306 label="snap.firefox.firefox" peer_pid=4921 peer_label="unconfi>
Nov 01 02:25:09 arctic dbus-daemon[4398]: apparmor="DENIED" operation="dbus_method_call"  bus="session" path="/org/gnome/Mutter/IdleMonitor/Core" interface="org.gnome.Mutter.IdleMonitor" member="GetIdletime" mask="send" name=":1.53" pid=5306 label="snap.firefox.firefox" peer_pid=4921 peer_label="unconfi>
Nov 01 02:25:11 arctic pkexec[28790]: pam_unix(polkit-1:session): session opened for user root(uid=0) by (uid=1000)
Nov 01 02:25:11 arctic pkexec[28790]: alichtman: Executing command [USER=root] [TTY=unknown] [CWD=/home/alichtman] [COMMAND=/usr/lib/update-notifier/package-system-locked]
Nov 01 02:25:11 arctic update-notifier.desktop[28795]: Cannot stat file /proc/9856/fd/4: Permission denied
Nov 01 02:25:11 arctic update-notifier.desktop[28795]: Cannot stat file /proc/9856/fd/5: Permission denied

It seems like the failure is here:

Nov 18 05:02:31 arctic autorandr.desktop[5821]: Failed to apply profile 'default' (line 930):
Nov 18 05:02:31 arctic autorandr.desktop[5821]:   Command failed: xrandr --fb 9023x5120 --output HDMI-0 --crtc 1 --gamma 1.0:1.0:1.0 --mode 2560x1440 --pos 0x0 --rate 59.95 --reflect normal --rotate left --transform 2.000000,0.000000,0.000000,0.000000,2.000000,0.000000,0.000000,0.000000,1.000000 --set n>
Nov 18 05:02:31 arctic autorandr.desktop[5821]: default (detected)
Nov 18 05:02:31 arctic gnome-session[5738]: gnome-session-binary[5738]: WARNING: App 'autorandr.desktop' exited with code 1

Update

apt on Ubuntu 23.10 ships version 1.12.1. I installed 1.14 with pipx and manually reinstalled the systemd service to /lib/systemd/system/autorandr.service (with a symlink to /etc/systemd/system/sleep.target.wants/autorandr.service and a patched path to autorandr). I can run --change --default default without messing up scaling now! It's still not run on login for some reason. I didn't find the systemd service being executed on login... Will have to continue looking.

Update 2

I started logging into a Wayland session instead of an X11 session (I guess it's been the default since 21.04, and I'd been setup to log into an X11 session instead -- oops). That did not fix the issue.

alichtman avatar Nov 18 '23 14:11 alichtman