#!/bin/sh
# Touchpad on/off indicator for waybar.
# Reads the state file that toggle-touchpad and touchpad-auto maintain; emits
# one JSON line (text + tooltip + class) for the custom/touchpad module.
# Anything other than "disabled" reads as enabled, so a missing or garbled
# state file fails safe (pointer shown rather than hidden).
STATE_FILE="${XDG_RUNTIME_DIR:-/tmp}/touchpad-state"
state=$(cat "$STATE_FILE" 2>/dev/null || echo enabled)
if [ "$state" = "disabled" ]; then
echo "{\"text\": \"\", \"tooltip\": \"Touchpad disabled\", \"class\": \"disabled\"}"
else
echo "{\"text\": \"\", \"tooltip\": \"Touchpad enabled\", \"class\": \"enabled\"}"
fi