Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with systemd / suspend #399

Open
1 task done
valentin2105 opened this issue Sep 11, 2023 · 8 comments
Open
1 task done

Issue with systemd / suspend #399

valentin2105 opened this issue Sep 11, 2023 · 8 comments
Labels

Comments

@valentin2105
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Operating system

Manjaro

Installation method

Package Manager (from OS)

Betterlockscreen & Dependency-Versions

Betterlockscreen: version: v4.2.0 (dunst: true, feh: true)
i3lock: version 2.13.c.5 © 2010 Michael Stapelberg, © 2015 Cassandra Fox, © 2021 Raymond Li
Version: ImageMagick 7.1.1-15 Q16-HDRI x86_64 21298 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenCL OpenMP(4.5)
Delegates (built-in): bzlib cairo djvu fftw fontconfig freetype heic jbig jng jp2 jpeg jxl lcms lqr ltdl lzma openexr pangocairo png raqm raw rsvg tiff webp wmf x xml zip zlib
Compiler: gcc (13.2)
Dunst is not running.
feh version 3.10
Compile-time switches: curl exif inotify help magic stat64 verscmp xinerama

Bug description

Sorry to open another issue about systemd/suspend but I don't find any answer that work on the closed issue, and the opened ones seem not exactly the same issue.

So, I have added the betterlockscreen@.service and enabled it, (after daemon-reloaded systemd), and when it got triggered by LidClosed (systemd-logind) of just by restarting the service, I got this message (and betterlockscreen don't launch) :

Sep 12 08:22:54 val-Manja systemd[1]: Starting Lock screen when going to sleep/suspend...
Sep 12 08:22:54 val-Manja betterlockscreen[31055]: Authorization required, but no authorization protocol specified
Sep 12 08:22:54 val-Manja betterlockscreen[31055]: xset:  unable to open display ":0"
Sep 12 08:22:54 val-Manja betterlockscreen[31058]: Authorization required, but no authorization protocol specified
Sep 12 08:22:54 val-Manja betterlockscreen[31058]: xset:  unable to open display ":0"
Sep 12 08:22:54 val-Manja betterlockscreen[31050]: [B] Betterlockscreen
Sep 12 08:22:54 val-Manja betterlockscreen[31050]: [*] Running prelock...
Sep 12 08:22:54 val-Manja betterlockscreen[31050]: [*] Locking screen...
Sep 12 08:22:54 val-Manja betterlockscreen[31069]: Authorization required, but no authorization protocol specified
Sep 12 08:22:54 val-Manja betterlockscreen[31069]: i3lock: Could not connect to X11, maybe you need to set DISPLAY?
Sep 12 08:22:54 val-Manja betterlockscreen[31050]: [*] Running postlock...

It seem unable to get the display, or X11 access..

Can you help me ?

Sorry if it's a duplicate issue

Steps to reproduce

No response

Relevant log output

No response

@aurkaxi
Copy link

aurkaxi commented Sep 13, 2023

Same issue.

@valentin2105
Copy link
Author

I mitigated the bug by adding Environment="XAUTHORITY=/tmp/xauth_... ( need to adapt path) in my betterlockscreen@.service file.

@ronit1996
Copy link

Same issue on Arch linux, is there any solution to this?

@lucasreis1
Copy link

Same here on arch too!

@kepi
Copy link

kepi commented Oct 3, 2023

Same issue on Arch, but this is either regression or something new. This method has been working for at least year without any issue.

I would label this as critical, as it might leave users with unlocked devices without their knowledge. It took me time to realize, that I didn't write the password and device is unlocked.

As for workaround mentioned by @valentin2105 you'd have to change env every time you reboot or restart X, which isn't really practical.

For now, I'm mittigating this with:

  1. disabling systemd service betterlockscreen@myuser
  2. creating system proxy service and user suspend target as mentioned in this answer on SE
  3. creating user service for betterlockscreen in ~/.config/systemd/user/betterlockscreen.service
    [Unit]
    Description=Lock screen when going to sleep/suspend
    Before=sleep.target
    Before=suspend.target
    
    [Service]
    Type=simple
    ExecStart=/usr/bin/betterlockscreen --lock
    TimeoutSec=infinity
    ExecStartPost=/usr/bin/sleep 1
    
    [Install]
    WantedBy=suspend.target
    
  4. systemctl --user daemon-reload && systemctl --user enable --now betterlockscreen.service

This works as user systemd session, at least on Arch linux, is updated with correct XAUTHORITY and DISPLAY on x start.

Seems like lot of work, so not sure if this is preferred solution.

Another workaround might be creating script in xinitrc, similar as arch one to update XAUTHORITY, which would set some env file which will be loaded in betterlockscreen system systemd service.

@rmathguy
Copy link

rmathguy commented Oct 4, 2023

I have the same issue error log is as follows:

betterlockscreen@$USER.service - Lock screen when going to sleep/suspend
Loaded: loaded (/usr/lib/systemd/system/betterlockscreen@.service; enabled; preset: disabled)
Active: failed (Result: exit-code) since Wed 2023-10-04 12:24:18 EDT; 20min ago
Process: 138746 ExecStart=/usr/bin/betterlockscreen --lock (code=exited, status=1/FAILURE)
Process: 138747 ExecStartPost=/usr/bin/sleep 1 (code=exited, status=0/SUCCESS)
Main PID: 138746 (code=exited, status=1/FAILURE)
CPU: 62ms

Oct 04 12:24:17 COMPUTER_NAME betterlockscreen[138754]: xset: unable to open display ":0"
Oct 04 12:24:17 COMPUTER_NAME betterlockscreen[138760]: Failed to open connection to "session" message bus: Usin>
Oct 04 12:24:17 COMPUTER_NAME betterlockscreen[138758]: Failed to communicate with dunst, is it running? Or mayb>
Oct 04 12:24:17 COMPUTER_NAME betterlockscreen[138746]: [B] Betterlockscreen
Oct 04 12:24:17 COMPUTER_NAME betterlockscreen[138762]: 138674
Oct 04 12:24:17 COMPUTER_NAME betterlockscreen[138762]: 138693
Oct 04 12:24:17 COMPUTER_NAME betterlockscreen[138746]: [!] i3lock already running
Oct 04 12:24:17 COMPUTER_NAME systemd[1]: betterlockscreen@$USER.service: Main process exited, code=exited, s>
Oct 04 12:24:18 COMPUTER_NAME systemd[1]: betterlockscreen@$USER.service: Failed with result 'exit-code'.
Oct 04 12:24:18 COMPUTER_NAME systemd[1]: Failed to start Lock screen when going to sleep/suspend.

Where $USER was my correct username

@Je12emy
Copy link

Je12emy commented Nov 24, 2023

bump. I've playing around to see if I missed something in the configuration step, but I'm glad I'm not the only one running into this one

@Alanon202
Copy link

Not sure if this will be relevant for anyone else, but this hasn’t been an issue for me until recently, when I switched from LightDM to SDDM in search of a display manager that can run both X11 and Wayland sessions.

As is, I couldn’t get betterlockscreen to work with any of the old or new suggestions until I stopped using SDDM. I suspect that there might be peculiarities with the way SDDM starts Xsessions that is either incomplete or simply not working for my barebones Openbox config.

Regardless, starting my X11 session with LightDM again makes betterlockscreen work as it should. I’ve also begun testing greetd and although other things need work with my session config, the default betterlockscreen setup works as it should in that case as well. YMMV.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants