A few questions on Sway

First, I would like to enable automatic suspend in AL Sway. On i3 I would install xautolock and then add this: exec --no-startup-id xautolock -time 60 -locker "systemctl suspend" to the .config.

Second, The panel doesn’t read my cpu temperatures. I dug into the config and that module references a script. I just need to know where the script is located so I can take a look at it and try to figure it out.

In .config/sway/config edit these lines:

### Idle configuration
exec swayidle -w \
    timeout 3000 'swaylock -f -c 212121' \
    timeout 3300 'swaymsg "output * dpms off"' \
    resume 'swaymsg "output * dpms on"' \
    before-sleep 'swaylock -f -c 212121'

gopsuinfo is a binary written in golang. You may try the older version by installing the psuinfo package (python) and use psuinfo -It instead of gopsuinfo -i t. It may work well. If not, you’ll at least have the script to start experimenting with.

4 Likes

Awesome. Thank you @nwg. I will have a go at it later on and report back.

3 Likes
### Idle configuration
exec swayidle -w \
    timeout 3000 'swaylock -f -c 212121' \
    timeout 3300 'swaymsg "output * dpms off"' \
    timeout 1200 'systemctl suspend' \
    resume 'swaymsg "output * dpms on"' \
    before-sleep 'swaylock -f -c 212121'

Maybe. I’ve never ever used suspend in my life.

OK. I just replied because I said I would. It does work on my system :wink:

Let me check on my testing lappy. The main machine is busy now.

You don’t really need dpms on/off if you want to suspend.

### Idle configuration
exec swayidle -w \
    timeout 10 'swaylock -f -c 212121' \
    timeout 20 'systemctl suspend' \
    before-sleep 'swaylock -f -c 212121'

(edit timeouts)

  1. Remember that you need to exit sway and start it again for changes to take effect, as it’s not exec_always.
  2. On my machine systemctl suspend requires root privileges, when started from a script. You need to edit sudoers:

your-username ALL=NOPASSWD: /usr/bin/systemctl suspend

2 Likes