man | ||
src | ||
.gitignore | ||
build.zig | ||
build.zig.zon | ||
LICENSE | ||
README.md |
wprintidle
wprintidle is a command line tool to print the users idle time to stdout
. It
serves as an alternative to xprintidle for Wayland environments, and is
compatible with Wayland compositors that implement the ext-idle-notify
protocol.
Table of Contents
Motivation
The direct inspiration for this project was xprintidle, while my motivation for
completing it was largely personal. Indeed, while I was reviewing my own Emacs
customizations along with org-clock.el
I found a setting that I had either
never noticed or forgotten: org-clock-x11idle-program-name
. I had been meaning
to write my first Wayland program for some time, and it occurred to me that
there's no equivalent in the Wayland world despite seeing requests for the
feature with projects like swayidle.
Usage
Using the utility will be fairly straightforward even without a lot of command line experience.
We can run wprintidle without specifying any options, in which case it will
pick an arbitrary seat, or a seat can be provided. For example, wprintidle -s default
will bind to the seat named default. After starting the program send
SIGUSR1
to print idle time in seconds, or SIGUSR2
for milliseconds.
See the wprintidle(1)
man page for additional details.
Example
As a simple test start wprintidle in a terminal, then open another terminal to send the signals.
Terminal 1:
$ wprintidle
Terminal 2:
$ sleep 5 && pkill -USR1 wprintidle && pkill -USR2 wprintidle
Output (terminal 1):
5
4953
Dependencies
- Zig 0.14.0*
- wayland
- wayland-protocols*
- scdoc**
* Compile-time only
** Optional for man pages
Compiling
The examples below demonstrate how to build the program with and without
installing it. Use zig build -h
to see all available options.
Build without Installing
zig build -Doptimize=ReleaseSafe
Build and Install
zig build -Doptimize=ReleaseSafe --prefix=/usr install
Differences from xprintidle
The primary difference from its cousin, xprintidle, is that wprintidle must be running in order to report idle time. Because Wayland specifies that the compositor is the arbiter of idle events, we cannot simply ask for the time or rely on other programs like screensavers. Accordingly, we query wprintidle by sending signals rather than providing command line arguments.
License
wprintidle is licensed under the General Public License Version 3.