Coder Social home page Coder Social logo

xidlehook's Introduction

xidlehook

Because xautolock is annoying to work with.

xidlehook is a general-purpose replacement for xautolock. It executes a command when the computer has been idle for a specified amount of time.

Improvements over xautolock:

  • Allows "cancellers" which can undo a timer action when new user activity is detected.
  • Unlimited amount of timers (provided necessary resources).
  • Not specific to locking.
  • Multiple instances can run at the same time.
  • Optionally only run through chain once.
  • Optionally prevent locking when an application is fullscreen.
  • Optionally prevent locking when any application plays audio.

Missing features:

  • Magic corners
  • All the instance related stuff (you should use unix sockets with –socket).

Example

Here's a lock using i3lock, with screen dim support:

#!/usr/bin/env bash

# Only exported variables can be used within the timer's command.
export PRIMARY_DISPLAY="$(xrandr | awk '/ primary/{print $1}')"

# Run xidlehook
xidlehook \
  `# Don't lock when there's a fullscreen application` \
  --not-when-fullscreen \
  `# Don't lock when there's audio playing` \
  --not-when-audio \
  `# Dim the screen after 60 seconds, undim if user becomes active` \
  --timer 60 \
    'xrandr --output "$PRIMARY_DISPLAY" --brightness .1' \
    'xrandr --output "$PRIMARY_DISPLAY" --brightness 1' \
  `# Undim & lock after 10 more seconds` \
  --timer 10 \
    'xrandr --output "$PRIMARY_DISPLAY" --brightness 1; i3lock' \
    '' \
  `# Finally, suspend an hour after it locks` \
  --timer 3600 \
    'systemctl suspend' \
    ''

Note: Every command is passed through sh -c, so you should be able to mostly use normal syntax.

Installation

As of currently, you will need to use the Rust 1.39.0 higher when building xidlehook.

Recommended installation is through the Nix package manager, which will get you a sane default configuration of xidlehook as well as all required libraries.

nix-env -iA nixpkgs.xidlehook

will install xidlehook regardless of whether you have rust installed, regardless of whether you have libxcb and friends installed, whatever. Nix just works.

If you instead would like to use the latest master, you can install it using the following.

nix-env -if https://gitlab.com/jD91mZM2/xidlehook/-/archive/master.tar.gz

Other installation methods

While I do definitely encourage you to try Nix if you haven't already, there are other ways to install xidlehook, of course. But it will involve some system-specific trouble I can't really help you with.

Arch Linux users can avoid that, however, thanks to an unofficial AUR package!

Xidlehook with the default settings requires libxcb, libXScrnSaver (or libxss) and libpulseaudio. On debian/ubuntu, don't forget to install the -dev versions of all the mentioned dependencies, also.

Which feature flag? Native dependency
Always libxcb, libXScrnSaver (aka libxss)
When using –features pulse (default) libpulseaudio

After getting these native libraries, one way of installing is with cargo, the official rust package manager that works almost everywhere with rust installed.

cargo install xidlehook --bins

Or if you want to clone it manually:

git clone https://gitlab.com/jD91mZM2/xidlehook
cd xidlehook
cargo build --release --bins

Socket API

The socket API can be communicated with over JSON. The full data and types for these structures can be seen in all the struct definitions of xidlehook/src/socket/models.rs.

For convenience, there is now an xidlehook-client (see #18), which will communicate with this API for you. See

xidlehook-client --help

for details.

A common use case of xidlehook is using it to run a lockscreen. To then manually lock the screen, you could first decide what ID the timer has, either by counting the indexes yourself of the timers you inform xidlehook of (starting from 0), or by querying timer information after starting it:

# Check what timer(s) you want to trigger...
xidlehook-client --socket /path/to/xidlehook.sock query

And then bind a hotkey or bash alias to lock it:

# Trigger it/them
xidlehook-client --socket /path/to/xidlehook.sock control --action trigger --timer <my timer id>

Caffeinate

If you're looking for a more elaborate client to temporarily disable xidlehook, take a look at caffeinate which has timers and PID based monitoring.

Configuring via systemd

If you use a distribution that uses systemd for its init system, you may wish to use it to ensure that xidlehook is always started when you log in. You can do this at the level of an individual user by placing the following service file at $XDG_CONFIG_HOME/systemd/user/xidlehook.service (typically $HOME/.config/systemd/user/xidlehook.service):

[Unit]
Description=Automatic Screen Locker

[Service]
Type=simple
Environment=DISPLAY=:0
Environment=XIDLEHOOK_SOCK=%t/xidlehook.socket
ExecStart=/usr/bin/xidlehook --not-when-audio --not-when-fullscreen --socket $XIDLEHOOK_SOCK --timer 900 '/usr/bin/slock' ''

[Install]
WantedBy=multi-user.target

The above service file example locks the screen using the slock program after 15 minutes of inactivity, but you can edit it the xidlehook command to do anything you wish. We need to thread the DISPLAY environment variable down so that xidlehook knows how to open up a connection to the X server.

Troubleshooting

If you have redshift running, the brightness of your screen will be quickly overriden by redshift. You can specify the brightness of the screen via redshift instead of xrandr to fix this issue.

xidlehook's People

Contributors

jd91mzm2 avatar jnqnfe avatar m-gregoire avatar mathstuf avatar maxjoehnk avatar rschmukler avatar thetarkus avatar yashsriv 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

xidlehook's Issues

Locking the screen on laptop close

Currently I use xss-lock to lock my screen if I close my laptop like so:

xss-lock -- "$HOME/.utility/lock" &

Based on the description I would think that this sort of functionality should be left with xss-lock but I just wanted to double check, obviously if I could do both with xidkehook I would.

Issue compiling

When trying to compile on Debian I get the following error:

Compiling xidlehook v0.6.0 (file:///home/otis/Developer/xidlehook)
error[E0658]: `crate` in paths is experimental (see issue #45477)
 --> src/x11api.rs:1:5
  |
1 | use crate::MyError;
  |     ^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.
error: Could not compile `xidlehook`.

To learn more, run the command again with --verbose

cargo version: 1.28.0
rustc version: 1.28.0

--not-when-audio doesn't timeout if audio stops after X goes idle

While playing with this, I noticed that I can set a timeout with --not-when-audio like so,

xidlehook --not-when-audio --timer 'echo done' ''

Play some audio, e.g. in Spotify, and stop the audio remotely e.g. with the Spotify app on my phone, and the timer never times out.

This also happens when I let a youtube video time out on its own.

This is with xidlehook 0.8.2

xidlehook's pulse module segfaulted

an 15 05:14:38 kn systemd-coredump[677499]: Process 238040 (xidlehook) of user 1000 dumped core.

                                         Stack trace of thread 238040:
                                         #0  0x0000560f26492163 n/a (xidlehook + 0xf9163)
                                         #1  0x0000560f264902e3 n/a (xidlehook + 0xf72e3)
                                         #2  0x0000560f263e9b30 n/a (xidlehook + 0x50b30)
                                         #3  0x0000560f263f9e5f n/a (xidlehook + 0x60e5f)
                                         #4  0x0000560f263ed3ec n/a (xidlehook + 0x543ec)
                                         #5  0x0000560f263ee35b n/a (xidlehook + 0x5535b)
                                         #6  0x0000560f263e05da n/a (xidlehook + 0x475da)
                                         #7  0x0000560f26400134 n/a (xidlehook + 0x67134)
                                         #8  0x0000560f263fd171 n/a (xidlehook + 0x64171)
                                         #9  0x0000560f263f6c3e n/a (xidlehook + 0x5dc3e)
                                         #10 0x0000560f263e28d0 n/a (xidlehook + 0x498d0)
                                         #11 0x0000560f263fa073 n/a (xidlehook + 0x61073)
                                         #12 0x0000560f263fa08d n/a (xidlehook + 0x6108d)
                                         #13 0x0000560f2651d577 n/a (xidlehook + 0x184577)
                                         #14 0x0000560f263e29e2 main (xidlehook + 0x499e2)
                                         #15 0x00007fbafe9b3152 __libc_start_main (libc.so.6 + 0x28152)
                                         #16 0x0000560f263d508e n/a (xidlehook + 0x3c08e)
                                         
                                         Stack trace of thread 238044:
                                         #0  0x00007fbafea8046f __poll (libc.so.6 + 0xf546f)
                                         #1  0x00007fbafebd6654 n/a (libpulse.so.0 + 0x33654)
                                         #2  0x00007fbafebbf9a9 pa_mainloop_poll (libpulse.so.0 + 0x1c9a9)
                                         #3  0x00007fbafebca281 pa_mainloop_iterate (libpulse.so.0 + 0x27281)
                                         #4  0x00007fbafebca331 pa_mainloop_run (libpulse.so.0 + 0x27331)
                                         #5  0x00007fbafebda7fe n/a (libpulse.so.0 + 0x377fe)
                                         #6  0x00007fbafe94f5fc n/a (libpulsecommon-14.1.so + 0x565fc)
                                         #7  0x00007fbafeb5d3e9 start_thread (libpthread.so.0 + 0x93e9)
                                         #8  0x00007fbafea8b293 __clone (libc.so.6 + 0x100293)

statusbar switch icon

This is not an issue but asking for a guide.

Is it possible to put a switch icon on i3 statusbar to enable/disable manually when needed?

Query xidlelock disabled/enabled

I would like to query if I am in disabled or enabled state and maybe even if there is something (e.g. a full screen video) inhibiting the screensaver.

Use case:
i3bar displaying whether screensaver is on or off as well as toggling the functionality from there.

Is there any option to get this information or do we need to extend xidlehook-client with the parameters --toggle and --query?

Question: dpms should be off?

I've got DPMS enabled and it suspends the laptop after 10 minutes of inactivity as expected.

Now that I've plugged in this amazing tool, it's not clear if I should xset -dpms at startup? Or leave it be? Because the two seems to be doing the same thing.

Thanks!

`--killer` feature from xautolock

Just to comment on what the killer feature is from xautolock, it's meant to just run a second timer for a second command...even though the name is not great. So, for instance, I used to have it so that my computer would lock after 5 minutes and then suspend after an hour:

xautolock -time 5 -locker i3lock -corners +000 -cornerdelay 1 -killer "systemctl suspend" -killtime 60

In the case of xidlehook, there's no need for this functionality. As you can run more than one xidlehook, I personally am simply running one that does the locking and one that does the suspending:

(From my i3/config file)

exec --no-startup-id xidlehook \
  --time 5 \
  --timer 'xrandr --output DVI-I-1 --brightness 1 --output DP-0 --brightness 1; i3lock' \
  --notify 10 \
  --notifier  'xrandr --output DVI-I-1 --brightness .1 --output DP-0 --brightness .1' \
  --canceller 'xrandr --output DVI-I-1 --brightness 1 --output DP-0 --brightness 1' \
  --not-when-fullscreen \
  --not-when-audio
exec --no-startup-id xidlehook \
  --time 60 \
  --timer 'xrandr --output DVI-I-1 --brightness 1 --output DP-0 --brightness 1; systemctl suspend' 

Handle spurious wakeups

It's entirely possible, although clearly unlikely since it hasn't happened to me yet, that the mio event loop returns an event that is a false positive.

All file descriptors need to be nonblocking, and any WouldBlock I/O errors need to be ignored.
Even the signalfd.

--not-when-fullscreen issue

Hi, when running xidlehook with --not-when-fullscreen it still locks the screen, tested this with full screen video in youtube under archlinux with i3lock-fancy

howto: Run timer unaffected by X11 activity?

Is it possible to use xidle to run a timer that isn't affected by whether X is idle or not?

Like a pomodoro timer that runs the screen locker after 25 minutes of the screen being unlocked?
this would be a separate timer from the one that is running after 5 minutes of inactivity.

xrandr defunct child process

I saw several xrandr defunct child process of xidlehook but idk how to trace this problem, is there anything I can help or know why xidlehook spawn some dead xrandr processes?

Toggling the disabled flag doesn't reset the timer

If you enable a previously disabled timer with xidlehook-client control --action enable --timer 0 it doesn't reset the timer. This results in unexpected behavior, where enabling doesn't actually cause the timer to trigger until the user becomes active again.

For example, I have a timer at index 2 that suspends my system. During office hours I have a script to disable this specific timer, to prevent my system from going to sleep. After office hours a cronjob enables the timer again (set for 1200s), but the timer doesn't trigger if the system was already idle when the cronjob ran.

The solution seems quite simple unless I'm missing something. Resetting the timer after toggling the disabled flag should do the trick.

less flick when dim and lock

I have screen at 80% to test this software feature. From 80% dims to .1causes screen go directly from 80% to .1 and it looks like a flick, sudden change doesn't look well on user experience.

I'm suggesting that instead go directly from X to .1, do a loop that change brightness from X->X-1->X-2->...->.1

and when user active, go from .1->2->..->X

Another issue: I use slock to lock after 10 seconds, each time xidlehook calls slock screen do a flash. I guess this dues to when calling slock, xidlehook brings back brightness at 80% then do lock screen. If we can turn off screen xset dpms force off then do lock screen, and then set brightness to 80% (in background), this would might avoid flick/flash for this issue.

Thanks.

Failed to query x for input focus

Sorry to open so many issues, this should be my last one.

When the timer executes I get the following error before my lock script runs:

warning: failed to query x for input focus

I think this is preventing the fullscreen flag from working.

not-when-audio issues

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

Revert one timer after the first

I'm sorry to fire an issue for a problem that maybe it is only due to me not understanding how xidlehook operates, if it's not a real issue you can classify as a documentation request.

I'm using xidlehook to lock my screen (it's not the only use of course, but probably the main one as you know), and until now I was using really the same example written in the README.
Now I would like to try dim the screen after locking, waiting another while, and I added a timer. But as for the first time I want the restore the brightness of the screen if an activity is detected, so I replicated the first timer in the example, namely:

  `# Dim the screen after 60 seconds, undim if user becomes active` \
  --timer 60 \
    'xrandr --output "$PRIMARY_DISPLAY" --brightness .1' \
    'xrandr --output "$PRIMARY_DISPLAY" --brightness 1' \

The problem is that when he tries to restore brightness seems to step back at the beginning, retrying also to lock the screen, that is already locked.
How can I avoid this? Is it possible to put the xidlehook 'position' after the second timer (the locking one) instead of restarting from the beginning?

Socket disappearing

xidlehook is running

le        169947  0.0  0.0 761660    72 ?        Sl   Dec21   0:02 xidlehook --socket /tmp/xidlehook.socket .......

but socket does not exist

[le@w530]: ~>$ stat /tmp/xidlehook.socket
stat: cannot stat '/tmp/xidlehook.socket': No such file or directory

This is not always the case. It is mainly working fine. Not sure how to reproduce this, though.
Is this a bug or am I missing something here?

--not-when-fullscreen not detecting wine games

Hi,

I'm using i3gaps, xidlehook and i3lock together. It normally works but recently i discovered when i was away from keyboard that xidlehook won't detect wine games even they are fullscreen.

exec --no-startup-id xidlehook --not-when-fullscreen --timer 300 "i3lock -f -B=sigma -k --pass-media-keys --timecolor=ffffffff --datecolor=ffffffff" ""

xidlehook 0.8.2
i3 version 4.18.1
5.6.15-arch1-1

Build failure due to attributes on if expressions

Compiling xidlehook-core v0.2.0 (/home/brian/documents/projects/xidlehook/xidlehook-core)
error: attributes are not yet allowed on `if` expressions
   --> xidlehook-core/src/lib.rs:474:21
    |
474 |                     #[cfg(feature = "tokio")]
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^

error: attributes are not yet allowed on `if` expressions
   --> xidlehook-core/src/lib.rs:484:21
    |
484 |                     #[cfg(feature = "tokio")]
    |                     ^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 2 previous errors

error: could not compile `xidlehook-core`.

rustc version: 1.42.0
Perhaps rust-lang/rust#69201 has something to do with this?

Add something like "-detectsleep" from xautolock

Hey,

I noticed that xidlehook triggers a timer when the system resumes its state from a suspend.
While it's not a big problem for me, I think it would be nice if it could detect that a system was suspended, so the timers should be reset on the resume.

XAutolock has -detectsleep that:

Instructs xautolock to detect that computer has been put to sleep. This is done by detecting that time has jumped by more than 3 seconds. When this occurs, the lock timer is reset and locker program is not launched even if primary timeout has been reached. This option is typically used to avoid locker program to be launched when awaking a laptop computer.

Would it be possible to have something similar?

Thank you!

Allow `--not-when-*` flags to apply to one timer

I had suggested in #41 that we extend the syntax of --not-when-* flags to allow specifying for individual timers. The original suggestion was:

xidlehook [FLAGS] [OPTIONS] --timer <duration> <command> <canceller> [--not-when-audio][--not-when-fullscreen]

Where OPTIONS includes

--timer <duration> <command> <canceller> [--not-when-audio][--not-when-fullscreen]

and FLAGS includes

--not-when-audio
--not-when-fullscreen

so that if a --not-when-* flag follows a --timer option, it applies only to that timer, and if it precedes all --timer options, it applies to all timers.

I'll try to make a PR about this once I figure out this rust stuff.

E0277 and E0308 when running `cargo install xidlehook --bins` in Ubuntu 20.04

I tried installing with cargo install xidlehook --bins and got the following errors:

Never used rust before so I'm not sure what I can do to fix it.
I'm using Ubuntu 20.04 and rustc/cargo 1.41.0.

$cargo install xidlehook --bins
   Updating crates.io index
   Installing xidlehook v0.8.2
   Compiling proc-macro2 v1.0.17
   Compiling unicode-xid v0.2.0
   Compiling syn v1.0.29
   Compiling libc v0.2.71
   Compiling cfg-if v0.1.10
   Compiling autocfg v1.0.0
   Compiling lazy_static v1.4.0
   Compiling memchr v2.3.3
   Compiling maybe-uninit v2.0.0
   Compiling version_check v0.9.2
   Compiling bitflags v1.2.1
   Compiling pkg-config v0.3.17
   Compiling proc-macro-nested v0.1.4
   Compiling futures-core v0.3.5
   Compiling once_cell v1.4.0
   Compiling futures-sink v0.3.5
   Compiling proc-macro-hack v0.5.16
   Compiling futures-io v0.3.5
   Compiling log v0.4.8
   Compiling slab v0.4.2
   Compiling pin-utils v0.1.0
   Compiling scopeguard v1.1.0
   Compiling void v1.0.2
   Compiling nix v0.17.0
   Compiling unicode-width v0.1.7
   Compiling unicode-segmentation v1.6.0
   Compiling ansi_term v0.11.0
   Compiling strsim v0.8.0
   Compiling serde v1.0.111
   Compiling async-task v3.0.0
   Compiling nix v0.15.0
   Compiling vec_map v0.8.2
   Compiling ryu v1.0.4
   Compiling scoped-tls-hkt v0.1.2
   Compiling regex-syntax v0.6.18
   Compiling quick-error v1.2.3
   Compiling pin-project-lite v0.1.5
   Compiling itoa v0.4.5
   Compiling termcolor v1.1.0
   Compiling thread_local v1.0.1
   Compiling futures-channel v0.3.5
   Compiling futures-task v0.3.5
   Compiling textwrap v0.11.0
   Compiling heck v0.3.1
   Compiling crossbeam-utils v0.7.2
   Compiling memoffset v0.5.4
   Compiling crossbeam-epoch v0.8.2
   Compiling proc-macro-error-attr v1.0.2
   Compiling proc-macro-error v1.0.2
   Compiling humantime v1.3.0
   Compiling x11 v2.18.2
   Compiling libpulse-sys v1.13.0
   Compiling aho-corasick v0.7.10
   Compiling quote v1.0.6
   Compiling kv-log-macro v1.0.6
   Compiling crossbeam-queue v0.2.2
   Compiling crossbeam-channel v0.4.2
   Compiling regex v1.3.9
   Compiling atty v0.2.14
   Compiling socket2 v0.3.12
   Compiling num_cpus v1.13.0
   Compiling crossbeam-deque v0.7.3
   Compiling clap v2.33.1
   Compiling xcb v0.9.0
   Compiling libpulse-binding v2.15.1
   Compiling env_logger v0.7.1
   Compiling syn-mid v0.5.0
   Compiling crossbeam v0.7.3
   Compiling pin-project-internal v0.4.17
   Compiling futures-macro v0.3.5
   Compiling serde_derive v1.0.111
   Compiling structopt-derive v0.4.7
   Compiling pin-project v0.4.17
   Compiling futures-util v0.3.5
   Compiling piper v0.1.2
   Compiling futures-executor v0.3.5
   Compiling futures v0.3.5
   Compiling smol v0.1.10
   Compiling async-std v1.6.0
   Compiling structopt v0.3.14
   Compiling serde_json v1.0.53
   Compiling xidlehook-core v0.1.1
   Compiling xidlehook v0.8.2
error[E0308]: mismatched types
   --> /home/alvaro/.cargo/registry/src/github.com-1ecc6299db9ec823/xidlehook-0.8.2/src/main.rs:176:38
    |
176 |                     Selected::Socket(rx.recv().await)
    |                                      ^^^^^^^^^^^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`
    |
    = note: expected enum `std::option::Option<(socket::models::Message, async_std::sync::channel::Sender<socket::models::Reply>)>`
               found enum `std::result::Result<(socket::models::Message, async_std::sync::channel::Sender<socket::models::Reply>), async_std::sync::channel::RecvError>`

error[E0308]: mismatched types
   --> /home/alvaro/.cargo/registry/src/github.com-1ecc6299db9ec823/xidlehook-0.8.2/src/main.rs:183:38
    |
183 |                     Selected::Signal(rx.recv().await)
    |                                      ^^^^^^^^^^^^^^^ expected enum `std::option::Option`, found enum `std::result::Result`
    |
    = note: expected enum `std::option::Option<nix::sys::signal::Signal>`
               found enum `std::result::Result<nix::sys::signal::Signal, async_std::sync::channel::RecvError>`

error[E0277]: the trait bound `async_std::sync::channel::RecvError: socket::models::_IMPL_SERIALIZE_FOR_Filter::_serde::Serialize` is not satisfied
    --> /home/alvaro/.cargo/registry/src/github.com-1ecc6299db9ec823/xidlehook-0.8.2/src/socket/mod.rs:51:50
     |
51   |                     let msg = serde_json::to_vec(&reply)?;
     |                                                  ^^^^^^ the trait `socket::models::_IMPL_SERIALIZE_FOR_Filter::_serde::Serialize` is not implemented for `async_std::sync::channel::RecvError`
     | 
    ::: /home/alvaro/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.53/src/ser.rs:2192:17
     |
2192 |     T: ?Sized + Serialize,
     |                 --------- required by this bound in `serde_json::ser::to_vec`
     |
     = note: required because of the requirements on the impl of `socket::models::_IMPL_SERIALIZE_FOR_Filter::_serde::Serialize` for `std::result::Result<socket::models::Reply, async_std::sync::channel::RecvError>`

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `xidlehook`.
warning: build failed, waiting for other jobs to finish...
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/tmp/cargo-installpnLfd6/release/deps/xidlehook_client-09b1d6910459e4fd.xidlehook_client.7q50wob7-cgu.0.rcgu.o" "/tmp/cargo-installpnLfd6/release/deps/xidlehook_client-09b1d6910459e4fd.xidlehook_client.7q50wob7-cgu.1.rcgu.o" "/tmp/cargo-installpnLfd6/release/deps/xidlehook_client-09b1d6910459e4fd.xidlehook_client.7q50wob7-cgu.10.rcgu.o" "/tmp/cargo-installpnLfd6/release/deps/xidlehook_client-09b1d6910459e4fd.xidlehook_client.7q50wob7-cgu.11.rcgu.o" "/tmp/cargo-installpnLfd6/release/deps/xidlehook_client-09b1d6910459e4fd.xidlehook_client.7q50wob7-cgu.12.rcgu.o" "/tmp/cargo-installpnLfd6/release/deps/xidlehook_client-09b1d6910459e4fd.xidlehook_client.7q50wob7-cgu.13.rcgu.o" "/tmp/cargo-installpnLfd6/release/deps/xidlehook_client-09b1d6910459e4fd.xidlehook_client.7q50wob7-cgu.14.rcgu.o" "/tmp/cargo-installpnLfd6/release/deps/xidlehook_client-09b1d6910459e4fd.xidlehook_client.7q50wob7-cgu.15.rcgu.o" "/tmp/cargo-installpnLfd6/release/deps/xidlehook_client-09b1d6910459e4fd.xidlehook_client.7q50wob7-cgu.2.rcgu.o" "/tmp/cargo-installpnLfd6/release/deps/xidlehook_client-09b1d6910459e4fd.xidlehook_client.7q50wob7-cgu.3.rcgu.o" "/tmp/cargo-installpnLfd6/release/deps/xidlehook_client-09b1d6910459e4fd.xidlehook_client.7q50wob7-cgu.4.rcgu.o" "/tmp/cargo-installpnLfd6/release/deps/xidlehook_client-09b1d6910459e4fd.xidlehook_client.7q50wob7-cgu.5.rcgu.o" "/tmp/cargo-installpnLfd6/release/deps/xidlehook_client-09b1d6910459e4fd.xidlehook_client.7q50wob7-cgu.6.rcgu.o" "/tmp/cargo-installpnLfd6/release/deps/xidlehook_client-09b1d6910459e4fd.xidlehook_client.7q50wob7-cgu.7.rcgu.o" "/tmp/cargo-installpnLfd6/release/deps/xidlehook_client-09b1d6910459e4fd.xidlehook_client.7q50wob7-cgu.8.rcgu.o" "/tmp/cargo-installpnLfd6/release/deps/xidlehook_client-09b1d6910459e4fd.xidlehook_client.7q50wob7-cgu.9.rcgu.o" "-o" "/tmp/cargo-installpnLfd6/release/deps/xidlehook_client-09b1d6910459e4fd" "/tmp/cargo-installpnLfd6/release/deps/xidlehook_client-09b1d6910459e4fd.2gt8xbvpez06l2iw.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-Wl,-O1" "-nodefaultlibs" "-L" "/tmp/cargo-installpnLfd6/release/deps" "-L" "/usr/lib/x86_64-linux-gnu" "-L" "/usr/lib/x86_64-linux-gnu" "-L" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/tmp/cargo-installpnLfd6/release/deps/libserde_json-6c24612c0e5741a4.rlib" "/tmp/cargo-installpnLfd6/release/deps/libryu-07b5a98b1ef9ec69.rlib" "/tmp/cargo-installpnLfd6/release/deps/libitoa-a5091f506702cc74.rlib" "/tmp/cargo-installpnLfd6/release/deps/libxidlehook_core-e4e5ab58d30897bd.rlib" "/tmp/cargo-installpnLfd6/release/deps/libasync_std-d3f82ae4c7da99a3.rlib" "/tmp/cargo-installpnLfd6/release/deps/libnum_cpus-1a872d651d4ffb24.rlib" "/tmp/cargo-installpnLfd6/release/deps/libsmol-e884cbbe6dd5be20.rlib" "/tmp/cargo-installpnLfd6/release/deps/libpiper-8223689f495a1636.rlib" "/tmp/cargo-installpnLfd6/release/deps/libasync_task-450c3325335236ad.rlib" "/tmp/cargo-installpnLfd6/release/deps/libscoped_tls_hkt-409c066cd426d689.rlib" "/tmp/cargo-installpnLfd6/release/deps/libnix-f1a87ee2daf1b277.rlib" "/tmp/cargo-installpnLfd6/release/deps/libcrossbeam-90415356b5086f41.rlib" "/tmp/cargo-installpnLfd6/release/deps/libcrossbeam_queue-eed537a83f1bdd01.rlib" "/tmp/cargo-installpnLfd6/release/deps/libcrossbeam_channel-72cfad60b7a6470c.rlib" "/tmp/cargo-installpnLfd6/release/deps/libcrossbeam_deque-5e849693a7c0b575.rlib" "/tmp/cargo-installpnLfd6/release/deps/libcrossbeam_epoch-5665f9a7588e9202.rlib" "/tmp/cargo-installpnLfd6/release/deps/libscopeguard-a78dda392bcde0b7.rlib" "/tmp/cargo-installpnLfd6/release/deps/libmemoffset-0afd2af5b914845b.rlib" "/tmp/cargo-installpnLfd6/release/deps/libmaybe_uninit-a298d468830200ff.rlib" "/tmp/cargo-installpnLfd6/release/deps/libsocket2-e706f118199c0588.rlib" "/tmp/cargo-installpnLfd6/release/deps/libfutures_util-265bee3d36af47e0.rlib" "/tmp/cargo-installpnLfd6/release/deps/libmemchr-395072760cf604fc.rlib" "/tmp/cargo-installpnLfd6/release/deps/libproc_macro_nested-33fd81c15436bdd0.rlib" "/tmp/cargo-installpnLfd6/release/deps/libfutures_channel-dc9ef617419bce36.rlib" "/tmp/cargo-installpnLfd6/release/deps/libpin_project-266569cffa669334.rlib" "/tmp/cargo-installpnLfd6/release/deps/libfutures_sink-245788bfc749042e.rlib" "/tmp/cargo-installpnLfd6/release/deps/libfutures_task-a4b4f001f231640c.rlib" "/tmp/cargo-installpnLfd6/release/deps/libonce_cell-3c0cedeff7768496.rlib" "/tmp/cargo-installpnLfd6/release/deps/libfutures_io-4e23c48023168bc0.rlib" "/tmp/cargo-installpnLfd6/release/deps/libslab-6389f6f597906dde.rlib" "/tmp/cargo-installpnLfd6/release/deps/libcrossbeam_utils-6dad68db553af84a.rlib" "/tmp/cargo-installpnLfd6/release/deps/libpin_project_lite-3542274f28f1566b.rlib" "/tmp/cargo-installpnLfd6/release/deps/libpin_utils-673b9f5031f880f1.rlib" "/tmp/cargo-installpnLfd6/release/deps/libfutures_core-292402a09442b91f.rlib" "/tmp/cargo-installpnLfd6/release/deps/libkv_log_macro-07a49755c22a497d.rlib" "/tmp/cargo-installpnLfd6/release/deps/libxcb-d6e0a0d4fb7f87d6.rlib" "/tmp/cargo-installpnLfd6/release/deps/liblibpulse_binding-b3904562fcbdd4cb.rlib" "/tmp/cargo-installpnLfd6/release/deps/liblibpulse_sys-a3aaf540ceacebfe.rlib" "/tmp/cargo-installpnLfd6/release/deps/libnix-bd35dae1e4790ef5.rlib" "/tmp/cargo-installpnLfd6/release/deps/libvoid-5ade95c7d252980f.rlib" "/tmp/cargo-installpnLfd6/release/deps/liblog-ad05045bd7a8b7a9.rlib" "/tmp/cargo-installpnLfd6/release/deps/libcfg_if-e1575648ad89a9c7.rlib" "/tmp/cargo-installpnLfd6/release/deps/libserde-81af1259103519c4.rlib" "/tmp/cargo-installpnLfd6/release/deps/libstructopt-df533ec095fe9c91.rlib" "/tmp/cargo-installpnLfd6/release/deps/liblazy_static-02374f77bb60ebb4.rlib" "/tmp/cargo-installpnLfd6/release/deps/libclap-5a36a5f1c2299438.rlib" "/tmp/cargo-installpnLfd6/release/deps/libvec_map-371e67f55c2b4526.rlib" "/tmp/cargo-installpnLfd6/release/deps/libtextwrap-483cd3fc0749e1ce.rlib" "/tmp/cargo-installpnLfd6/release/deps/libunicode_width-5ae8b6a551e0bbff.rlib" "/tmp/cargo-installpnLfd6/release/deps/libstrsim-74b13a71a08276e3.rlib" "/tmp/cargo-installpnLfd6/release/deps/libbitflags-057397ee22229dcb.rlib" "/tmp/cargo-installpnLfd6/release/deps/libatty-5b7ef2d26858e314.rlib" "/tmp/cargo-installpnLfd6/release/deps/liblibc-e097828ec91a023e.rlib" "/tmp/cargo-installpnLfd6/release/deps/libansi_term-78927abfb83cf2e7.rlib" "-Wl,--start-group" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-cd1d26a40296c383.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-946c46e8db143ba7.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-3c021fcab48e099a.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-a13ea224b282b67c.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libbacktrace-5291238e126d473c.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libbacktrace_sys-96cf2ffe5c4a068e.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-50615dde840f6f7e.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-5ca1a4c2cb5e4ca3.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-f62c22d6d8e50f70.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-e62c19949099b19e.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-115bdc63c6be79cf.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-19b60dda762cb253.rlib" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-310a55b5e5f0453f.rlib" "-Wl,--end-group" "/usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-542e54ad8a770d5e.rlib" "-Wl,-Bdynamic" "-lxcb" "-lxcb" "-lxcb" "-lxcb" "-lxcb-screensaver" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lpulse" "-lutil" "-ldl" "-lutil" "-ldl" "-lrt" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil"
  = note: /usr/bin/ld: cannot find -lxcb-screensaver
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error

error: failed to compile `xidlehook v0.8.2`, intermediate artifacts can be found at `/tmp/cargo-installpnLfd6`

Caused by:
  could not compile `xidlehook`.

Please let me know if there's any additional information that would be useful and I'll update the issue.

--not-when-fullscreen... again

I'm having a similar issue, I think. If Firefox is fullscreen it will still trigger the screenlock. If audio is running it will still trigger screen dimming but not lock.

#! /bin/bash

# Run xidlehook
xidlehook \
  `# but not when fullscreen` \
  --not-when-fullscreen \
  `# and not when audio playing` \
  --not-when-audio \
  `# dim after 60 seconds inactivity, undim if activity` \
  --timer normal 60 \
    'xrandr --output HDMI2 --brightness .4 --output VGA1 --brightness .4' \
    'xrandr --output HDMI2 --brightness 1 --output VGA1 --brightness 1' \
  `# after ten seconds undim and run gllock` \
  --timer primary 15 \
    'xrandr --output HDMI2 --brightness 1 --output VGA1 --brightness 1; gllock' \
    '' \
  `#if no activity in another 30 seconds suspend `\
    --timer normal 60 \
      'systemctl suspend'\
      ''

Originally posted by @stevensonmt in #5 (comment)

--not-when-cpu-busy

Hi ! I love the project, thank you for that :)

I was thinking about a feature I would love to have - --not-when-cpu-busy or something similar.
It would only execute the command when cpu average is below some percentage.
What do you think ?

If this seems like a good idea - I may have a PR for that some time in the future, but also feel free to pick this up whenever if someone wants :)

thanks again !

Feature Request: Identified timers

Hey! Thanks for all of your work on this project! It has been fantastic to use.

I recently released caffeinate which is inspired by a similarly named MacOS tool. The MacOS one has some nice features that allow you to conditionally enable / disable which timers are disabled / enabled. Eg. caffeinate could only prevent the system from sleeping, but not from the screen turning off.

I was wondering if you'd be open to extending the timers API to take identifiers, and the socket API to being able to selectively enable and disable them. To maintain compatibility we could use the existing command bytes to still disable the "primary" timer, but add new commands that take the name of the timer.

Something like:

xidlehook --timer display-off 180 "xset dpms force off" "" --timer sleep 300 "systemctl suspend" ""

Granted, for this to work, users would have to be using specific timer ID's that caffeinate knows about.

Another option would be to put some of the most common timers (screensaver, display-off, sleep) into xidlehook directly, which would then have the ID hardcoded, offering a perhaps more beginner friendly API.

An example w/ both a named timer, and built in timers:

xidlehook --display-off 60 --sleep 300 --timer lock 100 "~/scripts/lock.sh" ""

This would enable me to develop features like:

caffeinate --only=sleep,lock --timer 300

Just wanted to see if you were open to these kinds of changes so that perhaps I could submit a PR.

Thanks again!

cargo install fails on openSUSE Tumbleweed

error: failed to run custom build command for `x11 v2.18.1`
process didn't exit successfully: `/tmp/cargo-installzhYMGX/release/build/x11-89e8a677ff79890c/build-script-build` (exit code: 101)
--- stdout
cargo:rustc-link-search=native=/usr/lib64
cargo:rustc-link-lib=X11

--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Failure { command: "\"pkg-config\" \"--libs\" \"--cflags\" \"xscrnsaver >= 1.2\"", output: Output { status: ExitStatus(ExitStatus(256)), stdout: "", stderr: "Package xscrnsaver was not found in the pkg-config search path.\nPerhaps you should add the directory containing `xscrnsaver.pc\'\nto the PKG_CONFIG_PATH environment variable\nNo package \'xscrnsaver\' found\n" } }', src/libcore/result.rs:997:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...
error: failed to compile `xidlehook v0.7.0`, intermediate artifacts can be found at `/tmp/cargo-installzhYMGX`

I tried to look for a package named xscrnsaver using the opensuse package manager but I didnt find any matches:

zypper se xscrnsaver  
Loading repository data...
Reading installed packages...
No matching items found.

There is a package called xscreensaver, but its already installed:

zypper se xscreensaver 
Loading repository data...
Reading installed packages...

S | Name                    | Summary                                           | Type   
--+-------------------------+---------------------------------------------------+--------
i | xscreensaver            | A screen saver and locker for the X Window System | package
i | xscreensaver-data       | Selection of screensavers from xscreensaver       | package
  | xscreensaver-data-extra | Selection of screensavers from xscreensaver       | package
i | xscreensaver-lang       | Translations for package xscreensaver             | package

Is this just the case that opensuse has a different name for the package xidlehook is trying to look for?

Timer issue

For testing, I used this command:

xidlehook \
     --time 1 \
     --timer 'xrandr --output DP-2 --brightness 1; xrandr --output DP-3 --brightness 1; slock' \
     --notify 10 \
     --notifier 'xrandr --output DP-2 --brightness .5; xrandr --output DP-3 --brightness .5' \
     --canceller 'xrandr --output DP-2 --brightness 1; xrandr --output DP-3 --brightness 1' \
     --not-when-fullscreen

Then I ran watch -n 1 xidlehook --print. I could observe that the notifier triggered after about 80s of idle time, and the timer 10 seconds later.

Is it expected that the timer is very inaccurate?

howto: detect ac power to disable

Would it be possible using the existing version of xidlehook to detect when on AC power to disable
one of the "stages" (i.e. still start screensaver but do not suspend)?

The xidlehook-client add command doesn't properly take all options into account

As far as I can tell from the documentation the following command should result in a new timer, with a activation and a cancelation command:

$ xidlehook-client add --time 300 --activation activate --abortion abort

Instead, the resulting timer looks like this:

$ xidlehook-client query --timer 3
QueryResult(
    [
        QueryResult {
            timer: 3,
            time: 300s,
            activation: [
                "activate",
                "--abortion",
                "abort",
            ],
            abortion: [],
            deactivation: [],
            disabled: false,
        },
    ],
)

Example in README dosen't dim screen on some configurations

You use xrandr | awk '/ primary/{print $1}' to find which display to change the brightness of in the example in the README. This doesn't work on my machine, the display I'm using isn't "primary", even though it's the only one plugged in. Here's my xrandr output.

enolan@chonk ~/m/c/nixpkgs> xrandr 
Screen 0: minimum 8 x 8, current 3840 x 2160, maximum 32767 x 32767
DP-0 disconnected primary (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
HDMI-0 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 disconnected (normal left inverted right x axis y axis)
DP-4 connected 3840x2160+0+0 (normal left inverted right x axis y axis) 600mm x 340mm
   3840x2160     60.00*+  30.00  
   2560x1440     59.95  
   1920x1080     60.00    59.94  
   1600x900      60.00  
   1280x1024     60.02  
   1280x800      59.81  
   1280x720      60.00    59.94  
   1152x864      59.96  
   1024x768      60.00  
   800x600       60.32  
   720x480       59.94  
   640x480       59.94    59.93  
DP-5 disconnected (normal left inverted right x axis y axis)
USB-C-0 disconnected (normal left inverted right x axis y axis)

AFAIK I didn't do anything weird to make it decide a disabled output was the primary one.

error: Found argument '--not-when-audio' which wasn't expected, or isn't valid in this context

Running the latest xidlehook (0.9.1), has --not-when-audio flag gone?

% xidlehook --version
xidlehook 0.9.1

% xidlehook --not-when-audio --not-when-fullscreen --timer 2 'echo done' ''
error: Found argument '--not-when-audio' which wasn't expected, or isn't valid in this context
        Did you mean --not-when-fullscreen?

USAGE:
    xidlehook --not-when-fullscreen --timer <duration> <command> <canceller>

Don't run multiple instances when calling xidlehook again

Since it is possible to append multiple --timers.
Would it be possible to add a way for it to detect if there is already an instance
of xidlehook running and if it is don't run another instance?

For example, if I run picom -b twice, it detects than another instance is already running
and does nothing.

Sometimes I have to reload my window manager and in the startup script of the window
manager it also starts up xidlehook.
To mitigate this I wrote a simple if-statement to check if it is already running.
But it would preferable if the program checked it instead.

warning: failed to invoke command: No such file or directory (os error 2)

I'm having some problems with xidlehook on NixOS. I tried to write a systemd service but it just doesn't work. It gives errors like:

warning: failed to invoke command: No such file or directory (os error 2)

Here is my nix configuration (with some strace for debugging), and here's the strace log: https://gist.github.com/jluttine/df72194b671b1ba388903fbdc477e346

I guess this is a simple way to see the failure:

PATH="" /run/current-system/sw/bin/xidlehook --timer normal 5 "/run/current-system/sw/bin/echo hello" "/run/current-system/sw/bin/echo goodbye"
warning: failed to invoke command: No such file or directory (os error 2)
warning: failed to invoke command: No such file or directory (os error 2)

Any ideas what's going on?

In strace log it's weird that it's referencing a huge number of non-existent nix store paths..

Document how to hook xidlehook into systemd

Not everyone is comfortable with authoring systemd service files or knows that you can define a user-level service file, so it would be nice to provide an example of how one can make a service file to configure xidlehook.

Here is my attempt at some documentation for this. This could be added as a section to the README (I would have opened a PR, but I don't use emacs).

Configuring via systemd

If you use a distribution that uses systemd for its init system, you may wish to use it to ensure that xidlehook is always started when you log in. You can do this at the level of an individual user by placing the following service file at $XDG_CONFIG_HOME/systemd/user/xidlehook.service (typically $HOME/.config/systemd/user/xidlehook.service):

[Unit]
Description=Automatic Screen Locker

[Service]
Type=simple
Environment=DISPLAY=:0
Environment=XIDLEHOOK_SOCK=%t/xidlehook.socket
ExecStart=/usr/bin/xidlehook --not-when-audio --not-when-fullscreen --socket $XIDLEHOOK_SOCK --timer 900 '/usr/bin/slock' ''

[Install]
WantedBy=multi-user.target

The above service file example locks the screen using the slock program after 15 minutes of inactivity, but you can edit it the xidlehook command to do anything you wish. We need to thread the DISPLAY environment variable down so that xidlehook knows how to open up a connection to the X server.

Disabling timer with xidlehook-client has no effect

Start xidlehook with a timer to run date after 1s of inactivity:

$ xidlehook --socket /tmp/socket --timer 1 "date" ""

Disable the timer:

$ xidlehook-client --socket /tmp/socket control --timer 0 --action disable
Empty

Check it is disabled:

$ xidlehook-client --socket /tmp/socket query
QueryResult(
    [
        QueryResult {
            timer: 0,
            time: 1s,
            activation: [
                "/bin/sh",
                "-c",
                "date",
            ],
            abortion: [],
            deactivation: [],
            disabled: true,
        },
    ],
)

However the timer still fires after 1s of inactivity....

I'm using xidlehook version 0.8.1 on Arch Linux.

--not-when-fullscreen for all windows, not just active one

Would it be possible to make this disable timers when any fullscreen application is running? Sometimes I have a video on one monitor while I work on another, and it would be nice to not have to remember to keep giving the video focus every time I leave my keyboard even though me (or my toddler) is still watching.

Originally posted by @jpmorris in #5 (comment)

Panic disabling timers in 0.9.0

Hello, first of all thanks for this piece of software, it is amazing!

I think I found a bug in 0.9.0: I have 4 timers and if I try to disable them using the client, I get a panic when I disable the 4th. The order does not matter, eventually when I disable the last enabled timer, I always get the panic

xidlehook-client --socket /home/bigo/.xidlehook.sock control --action Disable --timer 1
xidlehook-client --socket /home/bigo/.xidlehook.sock control --action Disable --timer 3
xidlehook-client --socket /home/bigo/.xidlehook.sock control --action Disable --timer 2
xidlehook-client --socket /home/bigo/.xidlehook.sock control --action Disable --timer 0
thread 'main' panicked at 'timer error: the timer is shutdown, must be called from the context of Tokio runtime', /home/bigo/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.21/src/time/delay.rs:96:23
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Full trace can be found here: https://gist.github.com/crisidev/f5a4c58bb4ce23fe8eb45b6c8fc5a745

Compiling with --no-default-features still requries libpulse

Expected Behavior:

Installing with the --no-default-features flag should not depend upon libpulse.

Observed Behavior:

Installing with the --no-default-features flag still requires libpulse.

Discussion

This bug prevents me from installing xidlehook on Ubuntu 18.04 LTS, because the latest supported version of libpulse is 11, but xidlehook requires libpulse 12. This was fine with
0.7.1, because I could easily run:

cargo install --no-default-features xidlehook --version 0.7.1

And the install would successfully build without requiring/using libpulse at all. The latest version, 0.8, however, does not support this.

--not-when-audio does not work for Zoom calls

We use Zoom calls every day for meetings and xidlehook does not recognize zoom calls audio and will lock my screen after 10mins of inactivity.

Whereas, this works on the browser if I am playing any sort of video/audio.

Second timer doesn't seem to be executing

Hey I am trying to run the following script on boot:

#!/bin/bash

# Disable defaults
# https://wiki.archlinux.org/index.php/Display_Power_Management_Signaling
# https://www.linuxquestions.org/questions/arch-29/screen-goes-blank-after-ten-minutes-in-lxde-how-to-change-this-769000/
xset s off -dpms

# Run xidlehook
xidlehook \
    --not-when-fullscreen --not-when-audio \
    --timer normal 600 '~/.utility/lock' '' \
    --timer normal 300 'systemctl suspend' ''

The second --timer (system suspend) never seems to execute, am I correct in thinking that the second timer starts after the first one is executed? Or does it need to be more like 600 and 900 instead of 600 then 300?

Cheers.

error: failed to run custom build command for `x11 v2.18.1`

error: failed to run custom build command for `x11 v2.18.1`
process didn't exit successfully: `/tmp/cargo-installLq5Q2g/release/build/x11-a378cd41792e6b5a/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Failure { command: "\"pkg-config\" \"--libs\" \"--cflags\" \"x11 >= 1.4.99.1\"", output: Output { status: ExitStatus(ExitStatus(256)), stdout: "", stderr: "Package x11 was not found in the pkg-config search path.\nPerhaps you should add the directory containing `x11.pc\'\nto the PKG_CONFIG_PATH environment variable\nNo package \'x11\' found\n" } }', src/libcore/result.rs:1009:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.

warning: build failed, waiting for other jobs to finish...
error: failed to compile `xidlehook v0.6.1`, intermediate artifacts can be found at `/tmp/cargo-installLq5Q2g`

Caused by:
  build failed

Rust ver:

$ rustc --version
rustc 1.32.0 (9fda7c223 2019-01-16)

[Feature Request] generic --not-when flag

It would be nice if we could have a generic --not-when flag that takes a script as an argument and runs the timer conditionally on its exit code. e.g.

xidlehook --not-when youtube --timer 'xscreensaver-command activate'

and we could write our own checking scripts for youtube, etc.

Could --not-when-audio support ALSA ?

Hello !

First of all, thank you for this really great software. I love it ! Simple and efficient...

xidlehook --help clearly states that --not-when-audio is "PulseAudio specific". So, this is a feature request ;) Would it be possible to adapt this module to also work with ALSA-only configurations ?

Also, I use mpv as my video player, and have noticed that my xidlehook timers are not triggered when a video is playing, even if it's not fullscreen, and even if I don't use --not-when-audio. I've checked (a little) the code, but have not found anything specific to mpv, so I wonder : am I right to assume that xidlehook already knows when a video is played and doesn't trigger its timers when that's the case ? If I do am right, maybe a note could be added in the --help page, or in the README ?

Thanx for your help !

Commands are run via bash -c

I see from the source code that commands are run via bash -c. I think it'd be nicer to just have a simple command (maybe split on whitespace for arguments) and that can be a bash script rather than assuming bash. However, if bash is going to continue to be used, documenting it as such would be nice.

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.