Implement automatic idle detection to stop work tracking when the user's device is idle (no keyboard/mouse activity). This feature will be privacy-safe, cross-distro compatible, and opt-in.
1. Check idle status 1 minute after each nudge
2. If idle for threshold → issue "work off" + notification
3. If not idle → continue normal nudging cycle
4. No auto-resume (intentional linearity)1. KDE/Plasma (Wayland/X11) → DBus:
org.freedesktop.ScreenSaver.GetSessionIdleTime
- Works on Plasma 6/Wayland and Plasma/X11
- Uses qdbus or gdbus
2. GNOME (Wayland/X11) → DBus:
org.gnome.Mutter.IdleMonitor.GetIdletime
- Uses gdbus for GNOME Mutter
- Covers GNOME on both Wayland and X11
3. systemd-logind (any DE/WM) → loginctl:
Use IdleHint=yes + IdleSinceHint (µs since epoch)
- Reliable on modern distros regardless of DE/WM
- Universal fallback
4. X11 (XFCE, LXQt on X11, i3, Openbox, etc.) → xprintidle:
- Traditional X11 utility
- Covers X11-based window managers
- No ambiguities for X11 environments
5. disabled: if none available
- Graceful degradation
- No crashes or erratic behaviorWORK_IDLE_DETECTION_ENABLED=false # Default: disabled
WORK_IDLE_THRESHOLD=21 # (10*2 + 1) minutes
WORK_IDLE_DETECTION_METHOD=auto # auto-detect environment- KDE/Plasma → DBus (Plasma 6/Wayland and Plasma/X11)
- GNOME → DBus (GNOME Mutter on Wayland/X11)
- systemd-logind → Universal fallback (any DE/WM)
- X11 → xprintidle (XFCE, LXQt on X11, i3, Openbox, etc.)
- Feature disabled → Everything else
- KDE/Plasma: Use
qdbusorgdbusfor ScreenSaver DBus - GNOME: Use
gdbusfor Mutter IdleMonitor - X11: Use
xprintidle(no ambiguities) - Other Wayland: Fall back to systemd-logind
- Unsupported: Feature disabled
- Auto-detect environment and use appropriate method
- Cache detection method after first successful use
- If detection fails → feature disabled
- If environment not supported → feature disabled
- Auto-off after threshold → notify "Work tracking stopped due to inactivity"
- No auto-resume (intentional, per linearity principle)
- If detection unavailable → feature silently disabled
- Opt-in by default → user must enable feature
work idle-enable # Enable idle detection
work idle-disable # Disable idle detection
work idle-status # Show detection method + status- Always:
notify-send,sqlite3 - KDE/Plasma:
qdbusorgdbus(DBus tools) - GNOME:
gdbus(DBus tools) - X11 WMs:
xprintidle(X11 utility) - systemd:
loginctl(usually pre-installed)
1. Environment Detection:
# Auto-detect DE/WM and use appropriate method
- KDE/Plasma → DBus (qdbus/gdbus)
- GNOME → DBus (gdbus for Mutter)
- X11 → xprintidle (no ambiguities)
- Other Wayland → systemd-logind fallback
- Unsupported → feature disabled2. Method Caching:
# Cache detection method after first successful use
# Store in database or config file
# Avoid repeated environment detection3. Timer Strategy:
# Prefer systemd user timers over cron
# Cron fallback for pure X11 setups
# Maintain session environment for DBus calls4. Normalization:
# All methods return seconds
# Handle KDE milliseconds quirk
# Consistent output across environments- Add
idle_detection_enabledcolumn tostatetable - Add
idle_detection_methodcolumn tostatetable - Add
idle_thresholdcolumn tostatetable
- Enhance
work-nudgescript with idle detection - Add
work idle-enable/disable/statuscommands - Update
setup.shto handle new dependencies - Implement
get_idle_seconds()function with comprehensive detection - Add environment detection and method caching
- Prefer systemd user timers over cron (with cron fallback)
- No keylogging → only detect "activity happened", not "what activity"
- No telemetry → 100% local processing
- No data collection → all data stays on user's machine
- Opt-in → feature disabled by default
- DBus calls → use session bus only
- X11 tools → standard utilities, no custom monitoring
- systemd → use existing session management
- Graceful failure → no crashes or erratic behavior
- Test idle detection on each supported environment
- Test threshold behavior (21 minutes)
- Test notification delivery
- Test auto-off functionality
- Test graceful degradation
- Test on KDE/Plasma (Wayland and X11)
- Test on GNOME (Wayland and X11)
- Test on X11 WMs (XFCE, i3, Openbox)
- Test on systemd-based distros (Ubuntu, Fedora, etc.)
- Test on minimal distros (feature should be disabled)
- Test on unsupported Wayland compositors (feature should be disabled)
- No display server (headless)
- Multiple displays
- Remote desktop sessions
- Virtual machines
- Containerized environments
- Configurable idle thresholds
- Different thresholds for different projects
- Idle detection method selection
- Performance optimization (caching detection method)
- Environment-specific configuration
- This feature enables mobile sync (consistent idle detection)
- Foundation for advanced analytics
- Preparation for multi-device scenarios
- Implement
get_idle_seconds()function - Add environment detection logic
- Update database schema
- Add CLI commands
- Enhance
work-nudgescript - Update
setup.shfor dependencies - Implement systemd user timers
- Add configuration options
- Cross-distro testing
- Edge case handling
- Documentation updates
- Performance optimization
Note: This feature is designed to be privacy-first, cross-distro compatible, and opt-in. It provides automatic idle detection without compromising user privacy or requiring complex setup.