All Projects → jD91mZM2 → Xidlehook

jD91mZM2 / Xidlehook

Licence: mit
GitLab: https://gitlab.com/jD91mZM2/xidlehook

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Xidlehook

Linux Second Screen
Scripts to repurpose old android device as second monitor on linux
Stars: ✭ 160 (-25.93%)
Mutual labels:  lockscreen
Web Greeter
A modern, visually appealing greeter for LightDM.
Stars: ✭ 196 (-9.26%)
Mutual labels:  lockscreen
Xvfbwrapper
Manage headless displays with Xvfb (X virtual framebuffer)
Stars: ✭ 209 (-3.24%)
Mutual labels:  x11
Docker Osx
Run Mac in a Docker! Run near native OSX-KVM in Docker! X11 Forwarding! CI/CD for OS X!
Stars: ✭ 20,774 (+9517.59%)
Mutual labels:  x11
Azpainter
Full color painting software for Unix-like systems for illustration drawing. This is un-official little fixed repository for package maintainers of image editor AzPainter (based on "mlib" toolkit). Official repository - http://azsky2.html.xdomain.jp/arc/download.html
Stars: ✭ 179 (-17.13%)
Mutual labels:  x11
Chamferwm
A tiling X11 window manager with Vulkan compositor.
Stars: ✭ 200 (-7.41%)
Mutual labels:  x11
Wallutils
🌆 Utilities for handling monitors, resolutions, wallpapers and timed wallpapers
Stars: ✭ 145 (-32.87%)
Mutual labels:  x11
Libagar
Cross-Platform GUI Toolkit (stable)
Stars: ✭ 212 (-1.85%)
Mutual labels:  x11
Applocker
AppLocker - simple lock screen for iOS Application ( Swift 4+, iOS 9.0+) Touch ID / Face ID
Stars: ✭ 188 (-12.96%)
Mutual labels:  lockscreen
Kime
Korean IME
Stars: ✭ 208 (-3.7%)
Mutual labels:  x11
Hideit.sh
Automagically hide/show a window by its name when the cursor is within a defined region or you mouse over it.
Stars: ✭ 171 (-20.83%)
Mutual labels:  x11
Sara
Originally a fork of catwm, now an offspring of dwm with a streamlined featureset, plus some bspwm.
Stars: ✭ 179 (-17.13%)
Mutual labels:  x11
Glmark2
glmark2 is an OpenGL 2.0 and ES 2.0 benchmark
Stars: ✭ 199 (-7.87%)
Mutual labels:  x11
Sppatternlock
A Pattern Lock for iOS similar to the one in Android
Stars: ✭ 168 (-22.22%)
Mutual labels:  lockscreen
Xcolor
Lightweight color picker for X11
Stars: ✭ 209 (-3.24%)
Mutual labels:  x11
Picom
A lightweight compositor for X11
Stars: ✭ 2,299 (+964.35%)
Mutual labels:  x11
Alttab
The task switcher for minimalistic window managers or standalone X11 session
Stars: ✭ 196 (-9.26%)
Mutual labels:  x11
X11 Packages
Packages using the X Window System.
Stars: ✭ 213 (-1.39%)
Mutual labels:  x11
Frankenwm
🖼️ Fast dynamic tiling X11 window manager
Stars: ✭ 209 (-3.24%)
Mutual labels:  x11
Xf86 Input Wacom
X.Org driver for Wacom devices
Stars: ✭ 201 (-6.94%)
Mutual labels:  x11

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].