Sway: Sway is unusable if left unattended with a cat

Created on 2 Feb 2020  路  10Comments  路  Source: swaywm/sway

  • Sway Version: sway version 1.4-5568f14e (Jan 26 2020, branch 'HEAD')
    Screenshot from 2020-02-01 22:53:38

Steps to reproduce:

  • Place cat on keyboard

Jokes aside this basically caused a DOS because of how many layer shell clients were on the screen at once. I did manage to ssh into my laptop and kill all of the clients that were spawned but it'd be nice if there was a way to set a hardcoded limit for how many can be on the screen at once after which no more can be spawned.

Most helpful comment

Removing cat's legs is a dirty workaround

All 10 comments

This is probably doable with a script for the moment:

Use swaymsg -t get_tree to get the number of windows/clients.
If the number is below a threshold: start program

There is a swayidle, which can be suitable right for anti catDOS attack :)

exec swayidle -w \
         timeout 900 'swaylock -f -i /path/to/bg.jpg' \
         timeout 100 'swaymsg "output * dpms off"' \
              resume 'swaymsg "output * dpms on"' \
         before-sleep 'swaylock -f -i /path/to/bg.jpg'

There is a swayidle, which can be suitable right for anti catDOS attack :)

exec swayidle -w \
         timeout 900 'swaylock -f -i /path/to/bg.jpg' \
         timeout 100 'swaymsg "output * dpms off"' \
              resume 'swaymsg "output * dpms on"' \
         before-sleep 'swaylock -f -i /path/to/bg.jpg'

Does that just put the computer to sleep? How does that solve the problem?

There is a swayidle, which can be suitable right for anti catDOS attack :)

exec swayidle -w \
         timeout 900 'swaylock -f -i /path/to/bg.jpg' \
         timeout 100 'swaymsg "output * dpms off"' \
              resume 'swaymsg "output * dpms on"' \
         before-sleep 'swaylock -f -i /path/to/bg.jpg'

Does that just put the computer to sleep? How does that solve the problem?

There is also option of putting cat to sleep too. Absolute fix.

Does that just put the computer to sleep? How does that solve the problem?

This just run certain command after timeout [num sec] sway is being idle.
So after 15 min in my example computer gets locked.

There is also option of putting cat to sleep too.

Yeah, you shouldn't be using cat anyway. bat does the work very well and python accepts files as arguments. CoW should also allow you to have many identical clients without a performance impact. As a last resort, you can also use man. :joy:

Basically, there is no guarantee that someone's cat can't type rm -rf /* + enter.
Anyway, to prevent undesired computer interact computer should be locked.

Removing cat's legs is a dirty workaround

As mentioned by others, I would recommend using swaylock (either manually or spawned by swayidle after an idle timeout).

Removing cat's legs is a dirty workaround

Wouldn't fix the problems. Then you'd have a whole cat on your keyboard, instead of smaller cat legs.
One could argue that legs may yield faster results, but with a good enough multi-key rollover, you may experience a larger CDOS attack.

To be sure, it would need to be tested, but I'm quite sure there would be animal advocates behind the door.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

emersion picture emersion  路  4Comments

emersion picture emersion  路  4Comments

StephenBrown2 picture StephenBrown2  路  4Comments

DpoBoceka picture DpoBoceka  路  4Comments

ddevault picture ddevault  路  4Comments