Disable automatic screen lock in sway

Hello, I am new to both Manjaro and Sway.

For my desktop PC at home, I prefer to disable automatic screen locking (requiring password entry) so my family or I can simply wake it up with the mouse or keyboard. Automatically powering off the display when the system is idle is preferred, just not the screen lock.

I have been reading a bit trying to figure out how to accomplish this in Sway and I’m afraid I’m kind of stumped. This is the first time I have installed a DE where this is not easily accomplished through the GUI so I have been reading a lot.

So far I have learned (please let me know if my understanding is incorrect!) that the session locking is handled by swaylock, which is triggered by the swayidle manager. I think what I want to do is disable swaylock. I read through the man pages for both swaylock and swayidle, but I didn’t see an obvious way to do that.

I did see in the swayidle man entry the example configuration they have listed:

EXAMPLE
           swayidle -w \
                timeout 300 'swaylock -f -c 000000' \
                timeout 600 'swaymsg "output * dpms off"' \
                     resume 'swaymsg "output * dpms on"' \
                before-sleep 'swaylock -f -c 000000'

       This will lock your screen after 300 seconds of inactivity, then turn off your displays after an‐
       other 300 seconds, and turn your screens back on when resumed. It will also lock your screen be‐
       fore your computer goes to sleep.

I thought maybe a good starting point would be to look at what my current swayidle configuration is, and try to determine if there was a simple adjustment I could make to get swaylock disabled. I know there is a swayidle configuration of some sort set up by default, because obviously screen locking and powering off the display are already happening with my fresh install.

I looked through ~/.config/sway/config, but I didn’t see any entries related to swaylock or swayidle in there. I checked in ~/.config/sway/definitions.d/ and ~/.config/sway/config.d/, but so far they don’t have anything but a couple readme files.

Are the default configurations for this sort of thing more or less hidden away, and you apply changes on top of them through the config files? Or is there somewhere else I should be poking around?

Hello and welcome. :slight_smile:
This may be a case of the blind leading the blind, as I am pretty new to sway myself, but I think this is correct. Its default settings are in /etc/sway/* and /usr/share/sway/templates/waybar/*. If you add a sway.conf file to ~/.config/sway/config.d/, you can override the defaults there. In this case, you could delete the swaylock parts of the example and get pretty much what you are looking for. Perhaps copy the config.jsonc default to ~/.config/waybar/ and then edit it to reconfigure waybar.

A good reference is here:

https://man.archlinux.org/man/sway.5.en

Bonne chance,

R

1 Like

Thanks for the suggestion. I added the example with the swaylock parts removed to ~/.config/sway/config:

# Enable swayidle without swaylock
 exec swayidle -w \
          timeout 600 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' \

The configuration survived reboot and I haven’t seen any error messages about a bad configuration or anything, which is good, but I am afraid there must be something more to it. I still get an automatic lock screen and have to reenter the password to get back into the session. Swaylock must be enabled somewhere else, or I have to figure out some way to specifically disable it.

I must admit, the lock screen is really cool! But I still want to disable it for this PC, so I’m afraid I’m going to have to keep digging.

Well, that isn’t where I said to put it, but digging is always good.

I do see that you specified adding the config file to ~/.config/sway/config.d/, my mistake. The config example file itself suggests to save in ~/.config/sway/config at the top of the file, which is why I think I got mixed up there. Honestly, the different config files scattered all over the place are a little confusing.

In any case I copied the modified config file to ~/.config/sway/config.d/ like you originally suggested and pushed through another reboot, but I’m afraid that wasn’t the ticket either. The screen lock is still working normally.

I’m under the impression that Sway does not enable swaylock by default because I am reading that some folks add it in to their config files when they are building it up. So perhaps it is something Manjaro has established somewhere in this build?

Hey, maybe I can bring some light in here… in ~/.config/sway/config.d you will find a file 99-… that contains autostart applications: overlays/sway/etc/skel/.config/sway/config.d/99-autostart-applications · master · manjaro-arm / applications / arm-profiles · GitLab

There you will see something like exec $idle, which refers to a variable defined as in ~/.config/sway/config: overlays/sway/etc/skel/.config/sway/config · master · manjaro-arm / applications / arm-profiles · GitLab

So only item to change is the variable definition in that file to change the behavior of the idle / lock screen.

Hope that helps.

1 Like

@appelgriebsch thank you so much! That worked beautifully.

On my machine the file 99-autostart-applications.conf is located in /etc/sway/config.d, not ~/.config/sway/config.d, but after I finally found it I realized I don’t actually need the file anyhow.

The really useful piece was the link to the $set idle entry on GitLab. I copied that chunk into my config file like you instructed and just deleted the two lines with exec $locking.

Works great! Thanks again for your help.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.