2026-04-18 22:48:38 +01:00
2026-04-18 22:48:38 +01:00
2026-04-18 22:46:56 +01:00
2026-02-19 17:45:10 +00:00

desk-reminder

Logo

Small Linux utility that enforces periodic standing desk adjustments. After 20 minutes sitting, the screen is locked until the user switches to standing mode on their adjustable standing desk. This works via an ecard reader attached to the back of the computer screen and the wall, which allows this program to detect when the user is standing or sitting.

What It Does

  • Grabs a specific input keyboard device with EVIOCGRAB, so key events from that device are hidden from other applications.
  • Reads digit key presses (0-9) until Enter.
  • Hashes the entered numeric string with SHA-256 and compares the first 8 bytes (as a 64-bit number) against a hardcoded value.
  • If the hash matches, it resets the standing timer, kills i3lock, and re-enables keyboards.
  • A background watcher thread checks elapsed time every second.
  • Once elapsed time reaches the configured interval, it disables keyboard devices via xinput and starts i3lock with a lockscreen image.

Default interval is 20 minutes.

Dependencies

Build-time:

  • GCC
  • OpenSSL development headers/libraries (libssl-dev on Debian/Ubuntu)
  • POSIX threads (pthread)
  • Linux input headers (linux/input.h)

Runtime:

  • xinput
  • i3lock
  • X11 session (because keyboard disabling uses xinput)
  • Permission to read the target input device in /dev/input/by-id/...

Build

The current Makefile does not match the source filename in this repository (desk-reminder.c), so compile directly:

gcc -Wall -Wextra -O2 desk-reminder.c -o desk-reminder -lssl -lcrypto -lpthread

Configure

Edit the hardcoded device path in desk-reminder.c:

const char *dev = "/dev/input/by-id/usb-IC_Reader_IC_Reader_08FF20171101-event-kbd";

Use one of these to find your device path:

ls -l /dev/input/by-id/
cat /proc/bus/input/devices

Usage

Run with default interval (20 minutes):

./desk-reminder

Set interval explicitly:

./desk-reminder -i 20m
./desk-reminder -i 1200s

-i accepts a positive integer and optional unit suffix:

  • s for seconds
  • m for minutes (default if no suffix)

Examples:

  • -i 30 means 30 minutes
  • -i 30m means 30 minutes
  • -i 45s means 45 seconds

Operational Notes

  • This program grabs the configured device exclusively.

  • When timeout is reached, keyboard devices are disabled using:

    • xinput --list --short | grep -i keyboard | grep -v XTEST | ... | xinput disable
  • On successful reset code entry, keyboards are re-enabled with the matching xinput enable pipeline.

  • Screen lock image is hardcoded to:

    • /usr/local/share/lockscreens/standing_gopher.png

    Ensure this file exists, or adjust the command in source.

Safety / Recovery

  • Keep another input method available during testing (for example, a second terminal/TTY).
  • Test with a short interval first (-i 30s) to verify behavior.
  • If something goes wrong and keyboards remain disabled, use another session/input device to run:
xinput --list --short | grep -i keyboard | grep -v XTEST | sed -E 's/.*id=([0-9]+).*/\1/' | xargs -r -n1 xinput enable
pkill i3lock

Limitations

  • Linux-only.
  • X11-specific keyboard management (not Wayland-native).
  • Input device path, reset hash target, and lockscreen path are all hardcoded.
  • No systemd service/unit is included in this repository.

License

This project is licensed under the GNU General Public License, version 3. See LICENSE for the full text.

Description
Intermittently reminds the user to alternate their desk position between standing and sitting.
Readme GPL-3.0 378 KiB
Languages
C 95.2%
Makefile 4.8%