A generic, lightweight Linux daemon that exposes process context (e.g., gaming activity) and hardware inventory via a Varlink interface.
contextd allows userspace applications to:
- Detect active sessions: Seamlessly identify when a high-performance app or game starts or stops across multiple launchers.
- Hardware Inventory: List connected peripherals (keyboards, mice, controllers) and check their access permissions (
uaccess). - IPC Bridge: Provides a root-level daemon that exposes a safe, unprivileged socket for user-level apps (like RGB controllers or profile switchers) to query system state.
- Wide Support: Detects games and apps from:
- Steam: Native and Flatpak versions.
- Heroic Games Launcher: Epic Games, GOG, and Amazon Games.
- Lutris: Open-source gaming platform for Linux.
- Hardware-Aware:
- Groups complex udev nodes into single logical devices.
- Main Inventory: Clean list of only active gaming gear (Mice, Keyboards, Controllers, Audio).
- RGB Inventory: Dedicated endpoint for system aesthetics (LEDs, Fans, Lighting Strips).
- Reports
uaccessstatus for "readiness" checks (permission verification).
- System Diagnostics:
- Provides hardware sanity checks for support reporting.
- Reports RAM/CPU specs, GPU details, and kernel/OS info.
- Verifies presence of Vulkan and OpenGL libraries.
- Modern IPC: Uses Varlink for typed, discoverable, and language-agnostic communication.
- systemd Native: Distributed as a systemd portable service, ensuring zero-dependency deployment on any modern Linux distro.
contextd is distributed as a systemd portable service, ensuring a hardened, isolated environment that still has visibility into hardware and game libraries.
Build and install via the native package:
cd packaging/arch
makepkg -sicThis installs the portable image to /opt/contextd and automatically attaches it using the trusted profile.
For other distributions, use the production deployment script:
./scripts/deploy.shThis script automates the assembly of the portable OS tree in /opt/contextd and manages the portablectl lifecycle.
Use the contextctl helper to query the daemon:
# Get active game/app
./scripts/contextctl.sh active
# List installed games
./scripts/contextctl.sh list-games
# List connected gaming peripherals
./scripts/contextctl.sh list-devices
# List RGB controllers, fans, and lights
./scripts/contextctl.sh list-rgb
# Get system diagnostics (RAM, GPU, Vulkan, etc.)
./scripts/contextctl.sh diagnosticsYou can query the daemon state using the provided wrapper script:
# Show currently running game
./scripts/contextctl.sh active
# List gaming hardware
./scripts/contextctl.sh list-devices
# List RGB controllers/fans
./scripts/contextctl.sh list-rgb
# Show system diagnostics
./scripts/contextctl.sh diagnosticssudo systemctl status contextd
sudo systemctl restart contextdTo detach/uninstall:
sudo portablectl detach contextdcontextd can be configured via a TOML file located at /etc/contextd/config.toml. A sample configuration is provided in examples/config.sample.toml.
- TTLs: Control how frequently the daemon polls for games, hardware, and diagnostics.
- Blacklisting: Ignore specific processes or hardware devices.
- Security: Authorize specific systemd units for restricted operations.
The daemon implements a "dumb" but secure peer validation system:
- Unprivileged Public Sockets: Basic context (active game, hardware list, controller registration) is accessible via
/run/contextd/public/contextd.socketto all users. - Restricted Private Sockets: Operational control (RGB lighting) is restricted via
/run/contextd/private/contextd-rgb-control.socket. - Peer Validation: Uses
SO_PEERCREDto identify the systemd unit of the calling process for restricted operations. - Granular Authorization: Restricted methods (like updating system lighting) are only allowed if the caller's systemd unit is listed in the
authorized_unitswhitelist inconfig.toml.
- Repository: https://github.com/shanefagan/contextd
- Author: Shane Fagan
MIT
