penguinpowernz/workrave-kick

Monitors idle status of Waylnd on COSMIC and kicks workrave via DBUS

★ 0Forks 0GoGitHub ↗Compare

README

workrave-kick

A small daemon that monitors user idle status via the Wayland ext_idle_notify_v1 protocol and reports activity to Workrave over DBus.

Workrave's built-in idle detection does not work under Wayland compositors that implement ext_idle_notify_v1 (e.g. KDE Plasma ≥ 5.27, GNOME ≥ 44, sway, COSMIC). This daemon bridges the gap: it listens for idle/resumed events from the compositor and calls ReportActivity on the Workrave DBus interface so that Workrave's break timer stays accurate.

I made this for COSMIC desktop so that it would work with workrave.

How it works

  1. Connects to the Wayland display and binds wl_seat and ext_idle_notifier_v1.
  2. Registers an idle notification with a configurable timeout (default 3 s).
  3. When the user goes idle the daemon stops sending activity reports.
  4. When the user resumes, the daemon sends ReportActivity to Workrave every 2 s (configurable) until the next idle period.

Requirements

Go version

  • Go 1.21+
  • libwayland-client development headers (for cgo)
  • Dependencies are declared in go.mod:
    • github.com/godbus/dbus/v5
    • github.com/rajveermalviya/go-wayland/wayland
go mod tidy
go build -o workrave-kick .

Usage

Start Workrave first, then run the daemon:

# Go (after building)
./workrave-kick

The daemon retries the Workrave DBus connection up to 10 times (1 s apart) before giving up, so it is safe to start it alongside Workrave in an autostart script.

Command-line Options (Go version)

./workrave-kick [OPTIONS]
  • -n, --no-idle - Disable idle detection (always report active)
  • -d, --dbus-idle - Use DBus idle detection instead of Wayland (experimental, requires Mutter/GNOME)
  • --go-wayland - Use pure Go Wayland library (may not work on all compositors)
  • -h, --help - Show help message

Default behavior: Uses C libwayland-client via CGO for maximum compatibility with all Wayland compositors including COSMIC.

Implementation Details

The Go version now uses two implementations:

  1. C libwayland-client (default): Uses CGO to call the native libwayland-client library. This works reliably on all Wayland compositors including COSMIC, KDE Plasma, GNOME, and Sway.

  2. Pure Go (--go-wayland flag): Uses github.com/rajveermalviya/go-wayland library. This may not work on some compositors like COSMIC due to protocol compatibility issues.

Configuration

Timeouts are compile-time constants at the top of each source file:

Constant Default Meaning
idleTime 3 s How long without input before declaring idle
kickTime 2 s Interval between ReportActivity calls while active

Autostart

systemd user unit

# ~/.config/systemd/user/workrave-kick.service
[Unit]
Description=Workrave Wayland idle bridge
After=graphical-session.target

[Service]
ExecStart=/usr/local/bin/workrave-kick
Restart=on-failure

[Install]
WantedBy=graphical-session.target
systemctl --user enable --now workrave-kick.service

Security notes

The daemon:

  • Makes no network connections (Wayland socket and DBus are local IPC only).
  • Does not write to the filesystem.
  • Does not require elevated privileges.
  • Only calls org.workrave.CoreInterface.ReportActivity on the session DBus.

Credits

The credits are in the directory portedfrom that I found in a github issue somewhere that @ValdikSS had made. rcaelers/workrave#523 (comment)

Contributors

penguinpowernz

Issues