swayidle icon indicating copy to clipboard operation
swayidle copied to clipboard

distinguish between "idle" reasons (keyboard, mouse, touchpad, ...)

Open rpodgorny opened this issue 4 years ago • 7 comments

this will probably be rejected right away but still... ;-) i currently use swayidle to do the session locking, dpms, etc... one of the actions is:

timeout 5 "light -s sysfs/leds/asus::kbd_backlight -r -S 0" resume "light -s sysfs/leds/asus::kbd_backlight -r -S 1"

...this lights up the keyboard anytime i press a key and turns off the light after 5s - this increases battery life a lot! (while preserving "where's that obscure key" kind of comfort). the only downside is that this also fires when i move the cursor (which i sometimes do to prevent screen lock in middle of reading an article). :-( would it be possible to add something like "timeout-keyboard" etc.?

...or any other suggestions how to achieve such behaviour?

thanks!

rpodgorny avatar Aug 29 '19 16:08 rpodgorny

Hi, i am also interested in distinguishing idle reasons, but with a different purpose. When the system is active, any event should keep the system active, as it is now. But when the system is idle i would like to ignore cursor events. Only buttons or keys should be able to awake the system.

The use case is: the system may become idle (after a timeout or when i force it with SIGUSR1) and set the dpms state to off. Then the system should stay idle even if the mouse moves, either because of unrelated perturbances (like somebody hits the table) or because i need the desktop space where the mouse is.

Another possible way of doing this is setting a threshold: the cursor should move more than X pixels in one second to resume.

vicencb avatar Oct 18 '19 17:10 vicencb

@vicencb that's a very good point! I would definitely appreciate being able to resume only on keyboard events and ignore mouse events.

kittydoor avatar Dec 20 '19 16:12 kittydoor

@kittydoor This has been added in https://github.com/swaywm/sway/pull/4805

emersion avatar Dec 20 '19 16:12 emersion

Hi, i was trying to setup sway in order not to wake up on mouse move, but it does not work. I can put it to sleep with Mod4+z and then it awakens with any input, including mouse moves. What am i doing wrong? This is the relevant part of the configuration:

exec swayidle -w timeout 500 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"'
bindsym Mod4+z exec /usr/bin/sh -c 'sleep 1 ; /usr/bin/kill -USR1 swayidle'
seat * idle_wake keyboard switch

vicencb avatar Oct 05 '20 18:10 vicencb

I start swayidle like this to not unlock on mouse movements, it works:

  swayidle -w \                                                                
      timeout 1800 'swaymsg input type:pointer events disabled ;
        swaymsg "output * dpms off"' \
      resume 'swaymsg input type:pointer events enabled ;
        swaymsg "output * dpms on"'

alex3kov avatar Nov 28 '21 13:11 alex3kov

This worked for me to only inhibit idle on keyboard actions and ignore mouse movements:

seat * idle_wake keyboard
seat * idle_inhibit keyboard

This issue can thus be closed, no?

josch avatar Feb 21 '23 01:02 josch

This worked for me to only inhibit idle on keyboard actions and ignore mouse movements:

seat * idle_wake keyboard
seat * idle_inhibit keyboard

This issue can thus be closed, no?

well, i'd have to test it but at first glance it doesn't seem like it really solves my problem. the thing is i still want to make any keyboard or mouse event to be considered "activity" so the screen doesn't lock after a timeout... ...i just need a way to actively hook myself to a specific subset of inputs...

rpodgorny avatar Feb 21 '23 11:02 rpodgorny