In my .sway/config, I have

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

Let's say I decide that I want to increase that timeout, so I make it,

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

How can I reload these settings? Moreover, when I try to killall swayidle and run this command manually, I get

Failed to find session name: PID 8472 does not belong to any known session
No command specified! Nothing to do, will exit

How can I get swayidle running with updated timeouts?

2 Answers 2


I use a script and it works just fine. Maybe this approach would help. Here's the relevant section of my lock script 'mylock':

#!/usr/bin/env bash

[[ "$SWAYSOCK" ]] && {

    case "$1" in
            [[ "$2" == "wait" ]] && BG=''
            swaylock -f --image "$BACKGROUND_COLLECTION/$BACKGROUND" $BG

            pkill swayidle
            swayidle -w \
                timeout $TIMEOUT  "swaymsg 'output * dpms off'" \
                resume            "swaymsg 'output * dpms on'" \
                before-sleep      "mylock lock-now wait; mylock enable-lock" &
            rofi -width 20 -e "screen lock disabled"

            pkill swayidle
            swayidle -w \
                timeout $TIMEOUT                "swaymsg 'output * dpms off'"  resume "swaymsg 'output * dpms on'" \
                timeout $(( TIMEOUT * 2 ))      "swaymsg 'output * dpms on'; mylock lock-now" \
                timeout $(( TIMEOUT * 3 ))      "swaymsg 'output * dpms off'" resume "swaymsg 'output * dpms on'" \
                timeout $(( TIMEOUT * 4 ))      "sudo systemctl suspend" \
                before-sleep                    "mylock lock-now wait" &

    #ps -ef |grep '[s]wayidle'
    exit $?

... and then this in sway config:

set $a Mod1
set $mod Mod4
set $c Control
set $s Shift
bindsym $a+$c+l    exec mylock lock-now
bindsym $mod+l     exec mylock lock-now
bindsym $s+$a+$c+l exec mylock lock-off
bindsym $s+$mod+l  exec mylock lock-off

This allows fairly complex and dynamic locking behaviour:

  • on timeout X secs, screen blanks
  • on timeout 2X secs, screen locks and displays a random photo
  • on timeout 3X, screen blanks again (but remains locked).

I also wanted to be able to turn off the locking eg if I'm at home, not worried about security but bothered by having to unlock all the time - I just press Shift-$mod-L.

But - when I suspend the laptop I want the original locking to apply (otherwise I'm likely to forget to restore it when I go to sleep or grab the laptop and go out).

If I want to manually lock the laptop 'now', then just $mod-L.

(zenity is optional for visual feedback of lock-off operation).

I hope you can adapt this approach for your use-case.


To use any new changes done to the sway config, you just need to reload it. Default shortcut should be Alt+Shift+C. But you can of course modify it to your taste in you sway config. E.g.:

# Reload the configuration file
bindsym Mod4+R reload

This would set the reload action on ⊞ Win+R. Just don't forget to reload it first with the previous shortcut.

EDIT: Just noticed, that this actually doesn't reload swayidle (or anything else that is run by exec). To reload such programs you can however manually kill them (e.g. by running killall swayidle) and then temporarily change the command in your sway config to exec_always and reload the config. Just don't forget to change it back to just exec later, otherwise you'll get new instance of swayidle everytime you reload the config in future.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .