Giter Club home page Giter Club logo

swayidle's People

Contributors

ammgws avatar apiraino avatar ascent12 avatar boucman avatar ddevault avatar electrickite avatar eli-schwartz avatar emantor avatar emersion avatar ericonr avatar gdamjan avatar ianyfan avatar ivyl avatar jubalh avatar kamiyaa avatar kupospelov avatar kylelaker avatar markstos avatar martinetd avatar michelesr avatar mvdan avatar nikobockerman avatar oersen avatar oranenj avatar oscarwcl avatar primeos avatar rustybamboo avatar ryandwyer avatar stacyharper avatar the-king-of-toasters avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swayidle's Issues

Additional option for the lid switch of laptops

I propose two additional options lid-close and lid-open, which are triggered when the lid of a laptop is closed. A good example of a usecase would be to start a lock screen, even when a device is not configured to go to sleep when when it is closed. You could also start a timer to lift an inhibitor, and cancel said timer in the lid-open callback, allowing to delay suspend after closing the lid.

multiple timeout/resume on same cmd line doesn't work anymore

I've been having for a while something like:
exec swaydile timeout 3600 command line calling swaylock timeout 50 dpms off resume dpms on
It seems to work for a while.
Now only the last timeout/resume stanza seems processed.

My apologizes if I do things the wrong way.

Thks 4 ur attention.

Feature Proposal: Support for systemd's lock-session feature

Currently, as far as I can tell, swayidle does support systemd-inhibitors to ensure the screen is locked before actually going to sleep. In addition to that, supporting the systemd-session-lock mechanism as used for example by loginctl lock-session[s] or configurations in /etc/systemd/logind.conf would allow swayidle to react to exactly this.

If lock session is triggered, a Lock-signal is emitted on the session objects on org.freedesktop.login1, to which one can subscribe.

If XDG_SESSION_ID is not set (i.e. swayidle runs outside a session, for example a systemd-user-unit), simply all sessions could be locked, making this feature also usable with systemd user units and its benefits.

An exemplary implementation of this in Python can be found here.

RFE: Ability to temporarily disable timeouts

Right now there is no easy way to temporarily disable swayidle's timeouts, short of killing it and restarting it later. I'd like there to be a way to tell swayidle to stop and restart timeouts, perhaps via signals, like SIGUSR1 makes it enter idle mode.

configuration change

Is it possible (or can it be made possible) to change swayidle config after launching it?

My use case would be to run

swayidle -w \
    timeout 600 'swaymsg "output * dpms off"' \
         resume 'swaymsg "output * dpms on"' \

in most situations, but disable DPMS on idle when I'm watching TV or presenting on a beamer (I have a key combination to configure my outputs in this mode). For now I'm running pkill swayidle, but that doesn't seem right.

unlock event not triggered

For testing purposes, I am executing the following swayidle command in my terminal:
swayidle -w timeout 5 'swaymsg "output * dpms off" ; echo "timeout"' resume 'swaymsg "output * dpms on" ; echo "resume"' unlock 'echo "unlock" ; pkill swayidle' lock 'echo "lock" ; swaylock -f'

In my sway config, I have this binding to lock my session:
bindsym $mod+Ctrl+l exec "loginctl lock-session"

After locking, waiting 5 seconds, then entering the password, the following gets printed:

  1. lock
  2. timeout
  3. resume

I am missing the unlock message. Am I doing something wrong here?

EDIT: I just realized that maybe I should have created this issue for swaylock. I guess the unlock for swayidle is only triggered, when loginctl unlock-session is called by swaylock.

Swayidle kicks in despite video playing

Currently, for me, swayidle seems to lock the screen even if a video is playing in my browser or if I'm in a video call and just don't touch any input devices.

Is there a way to make it respect these cases and not trigger as long as a video is being played in the foreground?

Here's my Sway config: https://github.com/mastertinner/dotfiles/blob/main/sway/.config/sway/config#L26

As a browser, I'm using Brave: brave --enable-features=UseOzonePlatform --ozone-platform=wayland

swayidle resumes immediately with SIGUSR1

  • Sway Version: 1.1

Running swayidle and then sending it a SIGUSR1 signal enters an idle state as expected - but it then immediately enters the active state again without any interaction.

This is quite easy to reproduce by running this command:

swayidle -w -d \
    timeout 300 'swaymsg "output * dpms off"' \
    resume 'swaymsg "output * dpms on"' 

and then in a separate shell running this command:

killall -SIGUSR1 swayidle

This will cause the screen to turn off but then immediately turn back on (the only delay being the actual time the screen takes to turn back on).

I would expect that given these set of commands that the state would remain as "idle" and the screen would remain off.

Here is the output of the sway idle command on my terminal:

Got timeout
Register idle timeout at 300000 ms
Setup idle
Command: swaymsg "output * dpms off"
Setup resume
Command: swaymsg "output * dpms on"
Register with timeout: 300000
Got SIGUSR1
Register with timeout: 0
idle state
Cmd exec swaymsg "output * dpms off"
Spawned process swaymsg "output * dpms off"
active state
Register with timeout: 300000
Cmd exec swaymsg "output * dpms on"
Spawned process swaymsg "output * dpms on"
Got SIGUSR1
Register with timeout: 0
idle state
Cmd exec swaymsg "output * dpms off"
Spawned process swaymsg "output * dpms off"
active state
Register with timeout: 300000
Cmd exec swaymsg "output * dpms on"
Spawned process swaymsg "output * dpms on"

Fix 1.4 Github release

Hi!

1.4 is not marked as "latest stable" and is not signed; Is this a pre-release? If so, could it be marked as such?

Thanks!

[Proposal] conditional timeouts

I would like to suggest adding something like "conditional timeouts". Basically, a timeout would get an optional parameter with the path to some script/program that would be executed and conditional on its exit code, the actual command would be run.

A possible syntax for that would be:

timeout <timeout> <timeout command> [if <condition command>] [resume <resume command>]

I think this is a rather simple design that could accommodate multiple use cases such as #28 and #50 (for the first one, one could add one timeout per display checking whether the streaming application one uses is running fullscreen, for the second one, the mentioned edge case probably wouldn't be possible to achieve but the other part should be easy).

Another possible design might be to group timeouts by conditions, but I think the suggested one is probably easier to implement.

If you think such a feature is worth adding and we can agree on a design, I'd be willing to try to implement it.

[Feature Request] Charge state / power aware timeouts

I would like to configure swayidle to have separate timeouts depending on whether my device is running on battery power or is charging/doesn't have a battery.

This would let me have a long suspend time (like 2 hours) for my desktop or laptops currently charging and mounted to a display, while letting devices running on battery suspend quickly (like 30 minutes) to not waste their charge.

One edge case to consider is, if a device was on charge and the early/battery timeout has expired and was ignored, but then power cuts out. In my opinion, in this case, the device should immediately suspend.

This is of course possible to implement on top of swayidle, but would require keeping state externally.

DPMS event

When using

swayidle -w timeout 300 'swaylock -f -c 000000' timeout 600 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' before-sleep 'swaylock -f -c 000000'

while watching a long video, the screen is locked. Is there a way to listen to a DPMS event (like xss-lock does) instead in Wayland?

timeouts are handled in the "wrong" order with SIGUSR1

When enabling idle state through with SIGUSR1 (pkill -USR1 swayidle), the events are processed in the reversed order than if they are activated through the regular timeout.

Take for example the following configuration:

swayidle -w -d \
    timeout 300 'swaylock-blur -- -f' \
    timeout 600 'swaymsg "output * dpms off"' \
    resume 'swaymsg "output * dpms on"'

Normally, first (after 5min) the screen gets locked by swaylock(-blur), and then (after 10min) the screen gets blanked.
With USR1, these commands are executed in the opposite order: First the screen gets blanked, then it gets locked.
This is a problem in this case, because swaylock-blur needs the display to generate the lock image for swaylock.

Is this behavior intentional?

A workaround would be to use timeout 600 'sh -c \'sleep 3 && swaymsg "output * dpms off"\'&', but this seems to be buggy (the display doesn't turn on anymore).

FR: second timeout for DPMS when locked screen + idle

Hi all,

In the default sway config swayidle is started like so:
exec swayidle timeout 300 'swaylock -c 000000' timeout 600 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' before-sleep 'swaylock -c 000000'

...which means, after 600 seconds the screen is locked and powered down. If I then move my mouse, screens are powered on and the lockscreen is shown. However, if I've moved my mouse only by accident, I have to wait the full DPMS timout before my screens are powered off again, right?

I thought it would be nice to have a second timeout for when that happens (maybe timeout --locked), so that I can say "please turn my screen off again if I don't start entering my password after 10 sec".

This feature is NOT really important to me, I more want to record this thought here, as it may be a useful feature.

Thanks for reading.

Support fork-free locking notification mechanism

From swaywm/swaylock#42 it could be used by swayidle instead (or in addition) of the current -w option. It could also allow the tool to have a new semantic for the lock/unlock operations by keeping the locker as a child and sending a SIGTERM at unlock.

What do you think ? I volunteer to implement it but I'm clueless about the appropriate command-line semantic.

PS: If this is going forward I would like to also implement the LockedHint from logind.

Option to start locked

My use case is that my desktop computer auto-logins (via sddm) and starts my sway session with some additional programs running. I'd like for swayidle to start locked in that case. perhaps a -l cli option?

Postpone resuming after wake up

Not sure if this is desirable, but when using:

swayidle -w timeout 180 'swaymsg "output * dpms off"' \
                   resume 'swaymsg "output * dpms on"'`

and the laptop is idle, when you hit the sleep button or close the lid, swayidle resumes before going to sleep. This results in a blink of the screen.

Another use case is for tracking non-idle time: I have a simple script for timer, which is paused/resumed on swayidle events. When I close the lid, the timer is started.

Enhancement:

postpone resuming after waking up if the event causing resume causes sleep as well.

one of the monitors won't wake up

I don't know when this issue is started but it was working fine. Now, my primary monitor wakes up but every 2-3 seconds it loops itself with losing the image, no signal message on display and returning the image again

exec swayidle -w \
         timeout 600 'swaylock -f -c 000000' \
         timeout 900 'swaymsg "output * dpms off"' \
              resume 'swaymsg "output * dpms on"' \
         before-sleep 'swaylock -f -c 000000'
output DP-1 resolution 2560x1440 adaptive_sync on position 0,0 bg ~/Pictures/Wallpapers/IMG_4298.JPG center
output HDMI-A-1 resolution 3840x2160 scale 2 position 2560,0 transform 90 bg ~/Pictures/Wallpapers/wallhaven-639473.jpg fill
focus output DP-1

I'm using latest sway and arch linux

Gaming peripherals do not reset the idle timer

Title says it all. I connect my steering wheel to the PC (A Logitech G29, though I don't think brand matters here), fire up my game, start playing. A few minutes in I start cursing because my lockscreen shows up out of nowhere.
Now there could be some serious misunderstanding I've made in how swaywm/swayidle is setup that would allow swayidle to "hear" input from the wheel, but at the moment I'm stumped.
I've also tried it with a bluetooth gamepad with the same result.
My current workaround of killing swayidle whenever I want to play a game using such a peripheral is, to be perfectly honest, not the most convenient one.

systemd/logind IdleAction taken despite not being idle

I am trying to enable auto suspend through systemd/logind. In /etc/systemd/logind.conf I have the lines:

IdleAction=suspend
IdleActionSec=1min

However this causes my system to suspend every 1 minute regardless of activity or inactivity. My guess was that sway is not correctly reporting its idle state based on systemd/systemd#1295.

add short delay to allow fast resume without password lock

How do I add delay to allow fast resume without password lock?
I've tried this

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

but no success, if I keypress immediately after display turn off it asks for password anyway.

[FR?] Send SIGTERM to a timeout command

I have a script that I used to use with xss-lock (I think the script came with the program) that dims the screen. I want to run this after 5 minutes of inactivity, another 5 minutes later the screen is locked and turned off. This was working out of the box with xss-lock but not in swaidle.

I think the problem lies in the fact that the script waits for a TERM signal so it can set the screen brightness to the value it was before. Apparently xss-lock send this signal and swaidle does not, so I guess this is a feature request to add an option for this.

Here is the script I am using so you get a better idea:

#!/bin/bash
min_brightness=5
fade_steps=20
fade_step_time=0.05

get_brightness() {
	float=$(light -G $1)
	printf '%.*f\n' 0 $float
}

set_brightness() {
	light -S $1
}

fade_brightness() {
	local level
	for level in $(eval echo {$(get_brightness)..$1}); do
		set_brightness $level
		sleep $fade_step_time
	done
}

trap 'exit 0' TERM INT
trap "set_brightness $(get_brightness); kill %%" EXIT
fade_brightness $min_brightness
sleep 314151235 &
wait

wrong ordering or broken forking

I have the following configuration on my laptop:

exec swayidle -w \
        timeout 30 'swaymsg output * dpms off' \
        resume 'swaymsg output * dpms on' \
        timeout 60 locker \
        timeout 80 memsys

locker is just a shell script which wraps around swaylock, memsys is a small setuid program which suspends my machine.

What I expected was something like:

  • 30 seconds after no activity, turn off the screens ; turn them on on resuming (is that even needed?)
  • 60 seconds after no activity, lock the session
  • 80 seconds after no activity, suspend the machine

What I seem to get: Some time (probably 60 seconds) after no activity screen gets locked; if it was after more time (the 80 seconds I guess) of inactivity my laptop gets suspended right after unlocking it. Screen (Laptop's LCD, didn't try an external screen) is never blanked.

Couple of issues when parsing the config file

Running swayidle 04a176e

Exhibit # 1: Config file without empty newline segfaults

$ cat -p swayidle/.config/swayidle/config
timeout 3 'swaylock'
before-sleep 'swaylock'
$ swayidle 
Segmentation fault (core dumped)

With an empty newline no problems

$ cat -p swayidle/.config/swayidle/config
timeout 3 'swaylock'
before-sleep 'swaylock'

$ swayidle 
Failed to find session

Exhibit # 2: Command without quotes is not correctly parsed

$ cat -p swayidle/.config/swayidle/config
timeout 3 'swaylock'
timeout 6 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"'
before-sleep swaylock

$ swayidle -d
...
Command: swayloc
Setup sleep lock: swayloc
...

With quotes or a random char (in the example a dash -) fixes

$ cat -p swayidle/.config/swayidle/config
timeout 3 'swaylock'
timeout 6 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"'
before-sleep swaylock-

$ swayidle -d
...
Command: swaylock
Setup sleep lock: swaylock
...

Exhibit # 3: Misc

  • before-sleep directive without quotes refused
  • UTF-8 is not supported (minor issue, just for completeness)
    timeout 3 'swaylock🐶🔥' => Command: swaylock🐶�

SIGUSR1 gets queued up when idle inhibitor is active

This one's a bit peculiar. When an idle inhibitor is active (I use Waybar's idle_inhibitor module for this, which uses the associated Wayland protocol) sending a SIGUSR1 to swayidle does nothing (this is correct, since the system can't be considered idle). However, the second you turn off the idle inhibitor swayidle believes the system is idle, and thus locks.

I think this is confusing and unexpected, especially since idle inhibition can be active for long periods of time after which your system might surprise lock on you if you forgot you triggered swayidle some way (for example through a lockcmd shortcut in sway).

I would expect that while the idle inhibitor is active, swayidle would discard requests to enter idle state, instead of seemingly delaying processing them.

~ ❯❯❯ /usr/bin/swayidle -w -d \
      timeout 300 'swaylock -f -c 000000 -i /home/daenney/Pictures/Rainbow_Dash_Wallpaper.png' \
      timeout 600 'swaymsg "output * dpms off"' \
      resume 'swaymsg "output * dpms on"' \
      lock 'swaylock -f -c 000000 -i /home/daenney/Pictures/Rainbow_Dash_Wallpaper.png' \
      before-sleep 'swaylock -f -c 000000 -i /home/daenney/Pictures/Rainbow_Dash_Wallpaper.png'
Got timeout
Register idle timeout at 300000 ms
Setup idle
Command: swaylock -f -c 000000 -i /home/daenney/Pictures/Rainbow_Dash_Wallpaper.png
Got timeout
Register idle timeout at 600000 ms
Setup idle
Command: swaymsg "output * dpms off"
Setup resume
Command: swaymsg "output * dpms on"
Got lock
Command: swaylock -f -c 000000 -i /home/daenney/Pictures/Rainbow_Dash_Wallpaper.png
Setup lock hook: swaylock -f -c 000000 -i /home/daenney/Pictures/Rainbow_Dash_Wallpaper.png
Got before-sleep
Command: swaylock -f -c 000000 -i /home/daenney/Pictures/Rainbow_Dash_Wallpaper.png
Setup sleep lock: swaylock -f -c 000000 -i /home/daenney/Pictures/Rainbow_Dash_Wallpaper.png
Got sleep lock: 11
Register with timeout: 600000
Register with timeout: 300000

---> Sent SIGUSR1

Got SIGUSR1
Register with timeout: 0
Register with timeout: 0
idle state
Cmd exec swaymsg "output * dpms off"
Spawned process swaymsg "output * dpms off"
idle state
Cmd exec swaylock -f -c 000000 -i /home/daenney/Pictures/Rainbow_Dash_Wallpaper.png
Spawned process swaylock -f -c 000000 -i /home/daenney/Pictures/Rainbow_Dash_Wallpaper.png
active state
Register with timeout: 600000
Cmd exec swaymsg "output * dpms on"
Spawned process swaymsg "output * dpms on"
active state
Register with timeout: 300000

---> Activate Idle inhibitor
---> Sent SIGUSR1

Got SIGUSR1
Register with timeout: 0
Register with timeout: 0

---> Deactivate idle inhibitor

idle state
Cmd exec swaymsg "output * dpms off"
Spawned process swaymsg "output * dpms off"
idle state
Cmd exec swaylock -f -c 000000 -i /home/daenney/Pictures/Rainbow_Dash_Wallpaper.png
Spawned process swaylock -f -c 000000 -i /home/daenney/Pictures/Rainbow_Dash_Wallpaper.png
active state
Register with timeout: 600000
Cmd exec swaymsg "output * dpms on"
Spawned process swaymsg "output * dpms on"
active state
Register with timeout: 300000

If I send multiple SIGUSR1's while the idle inhibitor is active you get this instead:

Got SIGUSR1
Register with timeout: 0
Register with timeout: 0
Got SIGUSR1
Register with timeout: 0
Register with timeout: 0
Got SIGUSR1
Register with timeout: 0
Register with timeout: 0
Got SIGUSR1
Register with timeout: 0
Register with timeout: 0

---> Deactivate idle inhibitor

idle state
Cmd exec swaymsg "output * dpms off"
Spawned process swaymsg "output * dpms off"
idle state
Cmd exec swaylock -f -c 000000 -i /home/daenney/Pictures/Rainbow_Dash_Wallpaper.png
Spawned process swaylock -f -c 000000 -i /home/daenney/Pictures/Rainbow_Dash_Wallpaper.png
active state
Register with timeout: 600000
Cmd exec swaymsg "output * dpms on"
Spawned process swaymsg "output * dpms on"
active state
Register with timeout: 300000

Prematurely Trigger Idle

Is it possible to execute a command to prematurely trigger an idle? I have have swayidle putting my turning my screens off after a delay but I would like to be able to manually trigger it. If not could it be possible to just specify a command to execute on the next activity?

No command specified

With the latest commit (7af7e37), when I issue:

swayidle timeout 30 'swaylock -c 000000' timeout 60 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' before-sleep 'swaylock -c 000000'

I get:

No command specified! Nothing to do, will exit

swayidle ignores controller input

sway commit: gfa2d2c85
wlroots commit: 8beeb883

Controller is a GameCube controller via a USB adapter, which works as expected in most games. The issue is that swayidle doesn't seem to be interpreting the controller input as any actual input and triggers even if I've been playing for a few minutes. I suspect that this hasn't been coded into swayidle at all, but if it has and this is an issue for my specific config, I'd be more than willing to provide more info.

Open lid to trigger resume

Hi!

Setup:
My config is the most often an external monitor plugged on my laptop and the laptop lid closed.
The swayidle command I use is:

exec swayidle -w                                                 \
    timeout 120  'swaylock'                                      \
    timeout  20  'pgrep swaylock && swaymsg "output * dpms off"' \
         resume  'swaymsg "output * dpms on"'                    \
    before-sleep 'swaylock'

Expected:
This works almost great, if the output is off since few seconds, I can just type my password or move my mouse and everything goes back normaly.

Bug:
However if the output is off for more than few minutes (I don't know how long), the resume stuff is not triggered and I can't wake up my monitors. The only way I have is to open the laptop lid.

Versions:

  • sway: 1:1.2-5 (Arch Linux community)
  • swayidle: 1.5-1 (Arch Linux community)

I think that the external keyboard and mouse are disabled after dpms has been triggered (It does not append when I remove the dpms timeout/resume stuff), I just don't know why and if I can prevent them to

Handle logind inhibitors

Title explains it all. swaidle doesn't seem to handle logind's idle inhibitors.

I'd like to implement a toggle in my shell that turns on the idle inhibitor, but that doesn't work via dbus and setting up the Wayland protocol for that toggle is infeasible.

All applications are frozen after turning on the display with DPMS

I have the following desktop setup:

  • 3 x 4k monitors (DP1 DP2 DP3)
  • AMD ATI Radeon RX 5700 XT GPU
  • sway version 1.4-eeb90a79 (Jun 21 2020, branch 'master')
  • mesa driver version 20.1.1

I have set up swayidle to turn off my displays with the following command:

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

Whenever the outputs get turned off by swayidle after 900 seconds and then subsequently turned on with the dpms on command when I perform an action (e.g. press a key on the keyboard) all previously opened applications become frozen (terminal, browser etc.) and cannot be interacted with or even closed (although new applications can still be launched) - In which case I usually have to kill sway and restart it. This might be an issue with my GPU as it's quite a new model (although the latest mesa drivers seem to support this card). Or this could be something to do with the compositor itself. Can someone recommend how to best debug this issue and has anyone experienced a similar problem?

P.S. This issue doesn't happen 100% of the time, it sometimes happens, sometimes it doesn't - it's quite random.

Also, system suspend works correctly and doesn't have the same issue.

Memory leaks in parse_timeout?

Hi,

I tried running swayidle with clang address sanitizer and LeakSanitizer reported the following leaks when I stopped swayidle:

Feb 04 21:33:33 laptop swayidle[44588]: =================================================================
Feb 04 21:33:33 laptop swayidle[44588]: ==44588==ERROR: LeakSanitizer: detected memory leaks
Feb 04 21:33:33 laptop swayidle[44588]: Direct leak of 240 byte(s) in 3 object(s) allocated from:
Feb 04 21:33:33 laptop swayidle[44588]:     #0 0x496782 in calloc (/home/niko/ews/sway-related/swayidle/build/swayidle+0x496782)
Feb 04 21:33:33 laptop swayidle[44588]:     #1 0x7f4fefbbd902  (/usr/lib64/libwayland-client.so.0+0x5902)
Feb 04 21:33:33 laptop swayidle[44588]: Direct leak of 128 byte(s) in 2 object(s) allocated from:
Feb 04 21:33:33 laptop swayidle[44588]:     #0 0x49660d in malloc (/home/niko/ews/sway-related/swayidle/build/swayidle+0x49660d)
Feb 04 21:33:33 laptop swayidle[44588]:     #1 0x7f4fefbabfa8 in wl_event_loop_add_signal (/usr/lib64/libwayland-server.so.0+0xafa8)
Feb 04 21:33:33 laptop swayidle[44588]: Direct leak of 50 byte(s) in 2 object(s) allocated from:
Feb 04 21:33:33 laptop swayidle[44588]:     #0 0x482624 in strdup (/home/niko/ews/sway-related/swayidle/build/swayidle+0x482624)
Feb 04 21:33:33 laptop swayidle[44588]:     #1 0x4c84fe in parse_command /home/niko/ews/sway-related/swayidle/build/../main.c:632:9
Feb 04 21:33:33 laptop swayidle[44588]:     #2 0x4c7e7b in parse_timeout /home/niko/ews/sway-related/swayidle/build/../main.c:670:18
Feb 04 21:33:33 laptop swayidle[44588]:     #3 0x4c70da in load_config /home/niko/ews/sway-related/swayidle/build/../main.c:952:4
Feb 04 21:33:33 laptop swayidle[44588]:     #4 0x4c63df in main /home/niko/ews/sway-related/swayidle/build/../main.c:990:20
Feb 04 21:33:33 laptop swayidle[44588]:     #5 0x7f4fef7b0f1b in __libc_start_main /var/tmp/portage/sys-libs/glibc-2.32-r5/work/glibc-2.32/csu/../csu/libc-start.c:314:16
Feb 04 21:33:33 laptop swayidle[44588]: Direct leak of 27 byte(s) in 1 object(s) allocated from:
Feb 04 21:33:33 laptop swayidle[44588]:     #0 0x482624 in strdup (/home/niko/ews/sway-related/swayidle/build/swayidle+0x482624)
Feb 04 21:33:33 laptop swayidle[44588]:     #1 0x4c84fe in parse_command /home/niko/ews/sway-related/swayidle/build/../main.c:632:9
Feb 04 21:33:33 laptop swayidle[44588]:     #2 0x4c7ee8 in parse_timeout /home/niko/ews/sway-related/swayidle/build/../main.c:675:21
Feb 04 21:33:33 laptop swayidle[44588]:     #3 0x4c70da in load_config /home/niko/ews/sway-related/swayidle/build/../main.c:952:4
Feb 04 21:33:33 laptop swayidle[44588]:     #4 0x4c63df in main /home/niko/ews/sway-related/swayidle/build/../main.c:990:20
Feb 04 21:33:33 laptop swayidle[44588]:     #5 0x7f4fef7b0f1b in __libc_start_main /var/tmp/portage/sys-libs/glibc-2.32-r5/work/glibc-2.32/csu/../csu/libc-start.c:314:16
Feb 04 21:33:33 laptop swayidle[44588]: SUMMARY: AddressSanitizer: 445 byte(s) leaked in 8 allocation(s).

This was from a build against latest master (7dafac7) + cherry-picked commit from #83 (8ccea65).

I tried to analyze the two leaks from parse_command() when called from parse_timeout(). However, I fail to understand how that code can work at all as it seems to me that the cmd is not stored anywhere, only the cmd->link member is stored in the state->timeout_cmds list.

Do you consider these real problems? And do you want me to provide some extra information?

I could even try to fix those leaks myself and issue a PR, but I don't understand how the code even works today so can't do that without someone explaining that first :)

inhibit_idle ignored on Fedora 32 with sway 1.4

I just started using sway and swayidle, my apologies if this is the wrong repo or issue format. With X11 and i3, dpms worked exactly the way I want, without any customization: it would turn screen off after a period of idleness, but never when Netflix was playing. After transitioning to sway, I'm having trouble configuring the same behaviour.

I run swayidle to turn dpms off after a timeout, but I configured inhibit_idle on fullscreen. Unfortunately, swayidle turns dpms off even when a window is in fullscreen.

Here are the details captured right after one such occurrence:

Fedora 32 - x86_64 - Updates                                                       895 kB/s | 1.5 MB     00:01    
Last metadata expiration check: 0:00:01 ago on Fri 22 May 2020 12:50:52 PM.
Installed Packages
sway.x86_64                                             1.4-4.fc32                                         @updates
swaybg.x86_64                                           1.0-3.fc32                                         @fedora 
swayidle.x86_64                                         1.6-2.fc32                                         @fedora 
localhost>ps -l `pgrep swayid`|cat
F S   UID     PID    PPID  C PRI  NI ADDR SZ WCHAN  TTY        TIME CMD
0 S  1000   48455       1  0  80   0 -  1630 -      ?          0:00 swayidle timeout 120 swaymsg "output * dpms off" resume swaymsg "output * dpms on"
localhost>swaymsg -t get_tree|grep fullscreen
               "fullscreen_mode": 0,
               "fullscreen_mode": 1,
               "fullscreen_mode": 0,
               "name": "Inhibit idle while a fullscreen app is running? : swaywm - Mozilla Firefox",
               "fullscreen_mode": 0,
                 "title": "Inhibit idle while a fullscreen app is running? : swaywm - Mozilla Firefox",
localhost>swaymsg -t get_config 
<snip>
for_window [class=".*"] inhibit_idle fullscreen
for_window [app_id=".*"] inhibit_idle fullscreen
exec_always --no-startup-id swayidle timeout 120 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' &
localhost>ps x|grep wayland
  29076 tty2     Ssl+   0:00 /usr/libexec/gdm-wayland-session --register-session sway
  29125 tty2     Sl+   12:07 Xwayland :0 -rootless -terminate -listen 22 -listen 23 -wm 49
  48966 pts/1    S+     0:00 grep wayland

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

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!

Feature Request: per-display/output idle handling

Hello,

A long, long while back in #wayland I brought up some ideas that it would be neat (if you're watching a movie) to have displays blank just on the displays that were idle. The output showing the movie would continue to stay on. At the moment, it seems idle detected in a session-wide way through from logind? You can only detect idle across everything or nothing.

I'm not sure how this should be handled, but I wish it were possible to do this. Could swayidle be extended to allow you to execute a command when an individual screen/output has become "idle"?

(Thanks!)

Failed to send Inhibit signal: Permission denied

When I run swayidle I have this log error Failed to send Inhibit signal: Permission denied but the program don't crash.

Someone can explain me the goal of this line ?

swayidle/main.c

Line 116 in 85a6801

int ret = sd_bus_call_method(bus, "org.freedesktop.login1",

And what is the goal of this syscall ? and maybe I need to update permission ?

Example :

./build/swayidle -d -w \                                                      
         timeout 3 'swaylock -f -c 000000' \
         timeout 6 'swaymsg "output * dpms off"' \
              resume 'swaymsg "output * dpms on"' \
         before-sleep 'swaylock -f -c 000000'

                                                                                   
Got timeout
Register idle timeout at 3000 ms
Setup idle
Command: swaylock -f -c 000000
Got timeout
Register idle timeout at 6000 ms
Setup idle
Command: swaymsg "output * dpms off"
Setup resume
Command: swaymsg "output * dpms on"
Got before-sleep
Command: swaylock -f -c 000000
Setup sleep lock: swaylock -f -c 000000
Failed to send Inhibit signal: Permission denied
Register with timeout: 6000
Register with timeout: 3000

Thanks !

Small delay before swaylock grabs the keyboard input when resuming.

There seems to be a small delay between when swayidle resumes and when it passes the input to swaylock. Learned this the hard way when I tried to unlock my computer. Instead of typing in my password in swaylock I typed it in a chat window and sent it.

Using sway-1.5, swayidle-1.6 and swaylock-1.5
Arch running 5.8.8-arch1 with mesa-20.1.7. Using a RX 5700xt with two 4k monitors hooked up (ASUS VG289Q). My monitors are pretty slow to wake up so maybe that has something to do with it.

Repro:
In the sway config:

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

Have a text editor open, wait until swayidle's timeout threshold is hit and monitors have gone to sleep. Then start typing and some text should end up in the text editor before swaylock is started.

Recommended way to combine with manual locking

Hi, I've been trying to create a config were swaylock will be launched both on idle and on a keyboard shortcut. This is my current attempt:

exec swayidle -w \
         timeout 10 'if pgrep swaylock; then swaymsg "output * dpms off"; fi' \
         timeout 60 'if ! pgrep swaylock; then swaylock -f -c 000000; fi' \
         timeout 90 'swaymsg "output * dpms off"' \
              resume 'swaymsg "output * dpms on"' \
         before-sleep 'if ! pgrep swaylock; then swaylock -f -c 000000; fi'
bindsym --release $mod+Shift+s exec "swaylock -c 000000"

With this config I run into the problem that the screen continues to be off even after I unlock the machine.

I'm using systemd so I guess a combination of lock / unlock / timeout / resume + binding some dbus-send on keyboard shortcut could also do the trick?

Thanks

Support seatd

sway and wlroots support seatd. seatd support in swayidle would increase consistency across sway platform.

systemd user service

I've been trying to write a systemd user unit for swayidle. However swayidle fails to run swaylock with error execve failed!: No such file or directory

Here is my systemd service:

[Unit]
After=graphical-session.target
Description=Idle manager for Wayland
Documentation=man:swayidle(1)
PartOf=graphical-session.target

[Service]
Environment="LOCALE_ARCHIVE=/nix/store/xyzmznz9gjw0p78vmgfwwn813gnzpk9n-glibc-locales-2.30/lib/locale/locale-archive"
Environment="PATH=/nix/store/0fscv6z3qi2bsb8j8nfvnz52b37svx5w-swayidle-04a176ee91aee6cca45aa91b95f2626ecb2fbb28/bin:/nix/store/5msjs7cwfvxgvk7xzq47ncl47w0f5v53-swaylock-a99afe6a7075c962da72b140f02e18318052d833/bin:/nix/store/5k6nk721b96wij41723kxgjdijz7dkdj-sway-8b2ff2f1b3c03df9ec5573fe74ed076776869559/bin:/nix/store/3k8lm51wqhl7nyr55l9cn9w2glqbdw7n-coreutils-8.31/bin:/nix/store/asp8xjybxrwmirai24h8mvdz4plg3904-findutils-4.7.0/bin:/nix/store/fpmxrgczd54b2b0kspdi3c44m6hpxbzi-gnugrep-3.4/bin:/nix/store/abrakd4qy9py5s1mys72583r08mamkgc-gnused-4.8/bin:/nix/store/mygdcfxbghd8wa9jwa3p400bnz8k8sl1-systemd-245.5/bin:/nix/store/0fscv6z3qi2bsb8j8nfvnz52b37svx5w-swayidle-04a176ee91aee6cca45aa91b95f2626ecb2fbb28/sbin:/nix/store/5msjs7cwfvxgvk7xzq47ncl47w0f5v53-swaylock-a99afe6a7075c962da72b140f02e18318052d833/sbin:/nix/store/5k6nk721b96wij41723kxgjdijz7dkdj-sway-8b2ff2f1b3c03df9ec5573fe74ed076776869559/sbin:/nix/store/3k8lm51wqhl7nyr55l9cn9w2glqbdw7n-coreutils-8.31/sbin:/nix/store/asp8xjybxrwmirai24h8mvdz4plg3904-findutils-4.7.0/sbin:/nix/store/fpmxrgczd54b2b0kspdi3c44m6hpxbzi-gnugrep-3.4/sbin:/nix/store/abrakd4qy9py5s1mys72583r08mamkgc-gnused-4.8/sbin:/nix/store/mygdcfxbghd8wa9jwa3p400bnz8k8sl1-systemd-245.5/sbin"
Environment="TZDIR=/nix/store/zkf26f1f58axgr5fh5pwvi7js3jrma5r-tzdata-2019c/share/zoneinfo"



ExecStart=/nix/store/0fscv6z3qi2bsb8j8nfvnz52b37svx5w-swayidle-04a176ee91aee6cca45aa91b95f2626ecb2fbb28/bin/swayidle -d -w \
   timeout 5 'swaylock -f -c 000000' \
   timeout 10 'swaymsg "output * dpms off"' \
   resume 'swaymsg "output * dpms on"' \
   before-sleep 'swaylock -f -c 000000'

Type=simple

As you can see I add swaylock and sway paths to PATH environment variable for the service. I also tried passing swaylock with full path in the ExecStart command but it didn't make a difference.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.