regolith-linux / regolith-desktop

Meta package for the Regolith Desktop Environment
1.48k stars 31 forks source link

No lock after suspend #985

Closed mimre25 closed 3 months ago

mimre25 commented 4 months ago

Describe the bug I have a fresh install on Ubuntu 20.04. Whenever I suspend (Mod+Shift+s) the suspend works fine, however, I'm not prompted for a password after waking up from suspend.

Expected behavior After waking from suspend, prompt for password.

Installation Details

Additional context I have a second system where everything works fine. On that system I'm also using Ubuntu 20.04, and the regolith Version is 4.4.2-1regolith-focal. On that system I previously tried out i3 and only uninstalled it after installing regolith-desktop. Besides that, I cannot think of anything that I did different during the migration to regolith.

I'm open to provide more context/info to debug this, but I don't know what I could provide here/how.

mimre25 commented 4 months ago

I've even tried adding a systemd service a la:

[Unit]
Description=Lock the screen on resume from suspend
After=suspend.target #I've also tried before & 'sleep.target'

[Service]
User=martin
Type=forking
Environment=DISPLAY=:0
ExecStart=dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock

[Install]
WantedBy=suspend.target # I've also tried 'sleep.target'

But that still doesn't work. I checked dmesg and I can see pm-suspend start & exit without problems, but I cannot see anything about "suspend" when monitoring the dbus signals (dbus-monitor "type=signal").

Any help would be appreciated - I'm also happy to debug this further, but this is complete new land for me, and everything that I can find online says "just add a service" like the one above.

kgilmer commented 3 months ago

Hi @mimre25 , on the X11 session the lockscreen is handled by gnome-flashback. There is no custom behavior other than possibly some dconf settings. I suggest trying to repro with the metacity session (gnome-flashback) and see if it repros.

mimre25 commented 3 months ago

Thanks for the pointer.

Unfortunately I couldn't find anything in that direction, but I managed to get the systemd service to work.

For anyone who stumbles upon this in the future, here are the steps that solved it for me:

  1. Create a file /etc/systemd/system/lock.service:
    
    [Unit]
    Description=Lock screen when waking up
    Before=sleep.target suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target

[Service] Type=oneshot User=root ExecStart=/bin/loginctl lock-sessions

[Install] WantedBy=sleep.target suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target


2. Enable the service via `sudo systemctl enable lock.service`
3. Reload the systemd daemon `sudo systemcl daemon-reload`
4. It should work now.

In case this doesn't work, the best way to figure out what's going on is inspecting the status of the `systemd` services with `systemctl status lock.service` and `systemctl status suspend.target`. 
That's what I used to find out what exactly causes the lock not to happen and then fixed those issues. :slightly_smiling_face: 

I'll close this as it's basically solved and probably not related to regolith itself after all.