Files
DeeJanuz--frametop/power/run.sh
T
DeeJanuzandClaude Opus 5.5 b99fb97f32 Turn the displays off while the headset isn't used, and keep it awake on a charger
A display mount that covers the proximity sensor makes the headset seem
worn, so SteamVR never turned its displays off and they stayed on all
night. The new power service, ft-powerd (frametop-power.service), goes by
use instead: after DISPLAY_OFF_MIN minutes in which the headset and
controllers didn't move and no input device was used, it turns the
backlight off, and the next movement or input turns it back on.

The new Power tab in Frametop Display Settings sets that time and has a
Stay awake while plugged in switch. The switch sets Steam's own "When
Plugged In and Idle -> Sleep after" to Never through Steam's UI, so the
Frame stays reachable remotely while the power button still works.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 09:34:34 -06:00

27 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Install, start, stop, or inspect ft-powerd on the Frame (runs in the dev container).
# Usage: power/run.sh install|uninstall # user service, starts with SteamVR
# power/run.sh start|stop|restart|status|log [lines]
# power/run.sh off|on # the displays off now (to try it) or back on
set -euo pipefail
root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
. "$root/scripts/_env.sh"
frame="$root/scripts/frame.sh"
unit=frametop-power.service
case ${1:-status} in
install)
"$root/scripts/sync.sh" >/dev/null
fill_template "$root/power/$unit" | on_frame "mkdir -p ~/.config/systemd/user && cat > ~/.config/systemd/user/$unit"
"$frame" --host "set -e; pkill -x ft-powerd || true
systemctl --user daemon-reload; systemctl --user enable --now $unit
# It comes up once SteamVR runs (it starts with it); distrobox enter takes a few seconds.
for i in \$(seq 20); do systemctl --user is-active --quiet $unit && break; sleep 1; done
echo \"$unit: \$(systemctl --user is-active $unit)\"; journalctl --user -u $unit --no-pager -o cat -n 3" ;;
uninstall) "$frame" --host "systemctl --user disable --now $unit 2>/dev/null; rm -f ~/.config/systemd/user/$unit; systemctl --user daemon-reload; echo removed" ;;
start|stop|restart) "$frame" --host "systemctl --user $1 $unit; systemctl --user is-active $unit" ;;
status) "$frame" --host "systemctl --user is-active $unit; python3 -c 'import socket; s=socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM); s.bind(\"\"); s.settimeout(1); s.sendto(b\"status\", \"\\0ft_powerd\"); print(s.recv(256).decode())' 2>/dev/null || echo 'ft-powerd not answering'" ;;
log) "$frame" --host "journalctl --user -u $unit --no-pager -o cat -n ${2:-30}" ;;
off|on) "$frame" --host "python3 -c 'import socket; s=socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM); s.bind(\"\"); s.settimeout(1); s.sendto(b\"$1\", \"\\0ft_powerd\"); print(s.recv(256).decode())'" ;;
*) echo "usage: $0 install|uninstall|start|stop|restart|status|log|off|on" >&2; exit 2 ;;
esac