#!/bin/sh # Airplane-mode indicator for waybar. # Reads the state file the airplane-mode toggle maintains; emits one JSON line # (text + tooltip + class) for the custom/airplane module. The file holds # key=value lines; only `mode` (on/off) matters here. Anything other than # "on" reads as off, so a missing or garbled state file fails safe (airplane # mode shown as inactive — i.e. radios assumed on). # # Laptop-only: airplane mode is meaningless on a desktop, so the module hides # itself (emits nothing → waybar drops it) on machines with no battery. STATE_FILE="${XDG_RUNTIME_DIR:-/tmp}/airplane-state" PS_DIR="${AIRPLANE_POWER_SUPPLY_DIR:-/sys/class/power_supply}" # Laptop check: a battery present means this is a portable machine. is_laptop() { for b in "$PS_DIR"/BAT*; do [ -e "$b" ] && return 0 done return 1 } is_laptop || exit 0 mode=$(sed -n 's/^mode=//p' "$STATE_FILE" 2>/dev/null | head -n1) # Same clear plane glyph in both states; the class drives the color (gold when # engaged, default gray when not) so there's no slash to obscure the wings. if [ "$mode" = "on" ]; then echo "{\"text\": \"\", \"tooltip\": \"Airplane mode ON — wifi off, low power\", \"class\": \"active\"}" else echo "{\"text\": \"\", \"tooltip\": \"Airplane mode OFF\", \"class\": \"inactive\"}" fi