You are not logged in.

#1 2023-06-08 07:47:04

anicearchnewbie
Member
Registered: 2023-05-04
Posts: 16

[SOLVED] Setting up Sway to execute shutdown when laptop lid is closed

I've been trying to configure Sway WM to execute the poweroff command and shutdown the system when the lid is closed, for this i used the

bindswitch lid:on --locked --nowarn --reload exec poweroff 

line in my configuration, i tried the same without the "--locked" and the "--reload" flags but that didn't happen either.

When i close the lid, sway enters a suspend state and executes the swaylock instead of shutting down, i've tried to stop this by commenting out the sway lock configuration that i had :

# exec swayidle -w \
#          timeout 300 'swaylock -f -c 2c3639' \
#          timeout 600 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
#          before-sleep 'swaylock -f -c 2c3639 --indicator-radius 70 --indicator-thickness 15 --inside-color 2c3639'\

but even then, it is still locking the screen, i thought maybe it was a  permission issue, i made sure that the user i'm using sway with, can run the command "poweroff" without sudo, i tried it in the terminal and it works well, no password needed, the computer shuts down, but it doesn't seem to work when used in the the sway wm configuration.

I'm the attaching the sway configuration here

Last edited by anicearchnewbie (2023-06-09 06:24:40)

Offline

#2 2023-06-08 08:44:58

jl2
Member
From: 47° 18' N 8° 34' E
Registered: 2022-06-01
Posts: 1,397

Re: [SOLVED] Setting up Sway to execute shutdown when laptop lid is closed

from https://wiki.archlinux.org/title/Sway#C … eybindings:

Note: Systemd handles some special keys like the power key and lid open as well as close events. These may interfere with the ones configured in sway. See loginctl(1) and logind.conf(5) for details on how to configure them in systemd.

So what you want to do is edit /etc/systemd/logind.conf and replace the #HandleLidSwitch=suspend with:
HandleLidSwitch=poweroff

you might also want to edit the following 2 lines.

Last edited by jl2 (2023-06-08 11:39:35)


Why I run Arch? To "BTW I run Arch" the guy one grade younger.
And to let my siblings and cousins laugh at Arsch Linux...

Upload longer text output like this

Offline

#3 2023-06-09 06:24:12

anicearchnewbie
Member
Registered: 2023-05-04
Posts: 16

Re: [SOLVED] Setting up Sway to execute shutdown when laptop lid is closed

That worked flawlessly. Thanks a lot, I'm marking this topic as solved.

Offline

Board footer

Powered by FluxBB