jD91mZM2 / xidlehook

GitLab: https://gitlab.com/jD91mZM2/xidlehook
MIT License
387 stars 33 forks source link

not-when-audio issues #17

Closed HugoDelval closed 4 years ago

HugoDelval commented 5 years ago

Hi,

I tried this tool because I was really interested in the feature --not-when-audio but I can't make it work :/ I've tried to run a youtube video under firefox and a mp4 file under vlc and still my screen is locking up.

here is my systemd file for clarity :

[Unit]
Description=Lock the screen automatically after a timeout.

[Service]
Type=simple
User=user
Environment=DISPLAY=:0
ExecStart=/usr/bin/xidlehook --not-when-audio --timer normal 10 'xrandr --output LVDS1 --brightness .1' 'xrandr --output LVDS1 --brightness 1' --timer primary 5  'xrandr --output LVDS1 --brightness 1; /path/to/lock.sh' '' --timer normal 1800 'systemctl suspend' ''

[Install]
WantedBy=graphical.target

Any idea how I could debug this? Thanks by advance :)

EDIT: I'm runing i3 under archlinux, if it can help in any way

jD91mZM2 commented 5 years ago

Are you using pulseaudio? Also, does your service yield any output what-so-ever (journalctl -u xidlehook)?

HugoDelval commented 5 years ago

Hi jD91mZM2,

I do use pulseaudio, but maybe vlc and firefox are using another software? I've tried to find if firefox can use another lib than pulseaudio but it doesn't look so.

journalctl -u xidlehook outputs only normal logs, the only weird thing is:

mars 19 15:47:26 hd systemd[1]: xidlehook.service: Current command vanished from the unit file, execution of the command list won't be resumed.

but I don't believe it is related to sound stuff.

Also, just to be clear, the tool is doing the job properly for everything else (fullscreen detection is working for example).

jD91mZM2 commented 5 years ago

What happens if you run the command outside of systemd, just for testing? I must admit I'm a little stumped. This particular feature has been the one feature that has always worked for me, haha.

HugoDelval commented 5 years ago

Oh! You're right that's interesting! It does work properly when running it directly from the command line. So it means it has something to do with systemd..

HugoDelval commented 5 years ago

It looks like it's a permission issue, because when I launch the service as root it works fine.

jD91mZM2 commented 5 years ago

Is this something I can help with from xidlehook or can I close this?

stevensonmt commented 5 years ago

https://unix.stackexchange.com/questions/339638/difference-between-systemd-and-terminal-starting-program/339645 Then answer to that question might help debug this. Are you able to run lock.sh with systemd-run /path/to/lock.sh? Since running the systemd service as root works then it is probably not this, but could also be related to the double command being run with service type simple. See https://www.freedesktop.org/software/systemd/man/systemd.service.html#Command%20lines

Example:

ExecStart=echo one ; echo "two two"
This will execute echo two times, each time with one argument: "one" and "two two", respectively. Because two commands are specified, Type=oneshot must be used.

If it is the service type, change to oneshot and add RemainAfterExit=yes.

brettinternet commented 4 years ago

I had also assumed that --not-when-audio was not working, but after debugging my setup I found other side effects were the culprit. Consider looking into DPMS if you're using xss-lock.

For example, in my case, while I did set xset dpms 0 0 0 to disable DPMS timers, the xss-lock hook was still triggered by the screen saver timer. So, I also had to disable the screensaver timer: xset dpms 0 0 0 s off.

You can debug the setting simply with xidlehook --not-when-audio --timer 1 "echo 'triggered'" "" to see if the audio postpones the timer.

I think this ticket can be closed for now since it's been stale for almost a year. @jD91mZM2 Thanks for this great software!

jD91mZM2 commented 4 years ago

Aww, thanks for the compliment ❤️