aboutsummaryrefslogtreecommitdiff
path: root/dotfiles/hyprland/.local/bin/airplane-mode
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-02 12:16:38 -0500
committerCraig Jennings <c@cjennings.net>2026-06-02 12:16:38 -0500
commita816122f49d2c7e43e41308e251e133197a486bc (patch)
tree246b46b53c956cfea07bc9d1c2b81f9f8de53d65 /dotfiles/hyprland/.local/bin/airplane-mode
parentc8ac4d0040309c9b4226a331bafdfa0bd3f4bb73 (diff)
downloadarchsetup-a816122f49d2c7e43e41308e251e133197a486bc.tar.gz
archsetup-a816122f49d2c7e43e41308e251e133197a486bc.zip
refactor: drop in-repo dotfiles/, move stow tooling to the dotfiles repo
Since the installer clones DOTFILES_REPO into ~/.dotfiles and stows from there, the in-repo dotfiles/ tree was dead weight. Nothing reads it at install time. I removed it (831 files) now that both machines are migrated. The Makefile's stow / restow / reset / unstow / import targets and the dotfile-script unit suites moved to the dotfiles repo. They sit alongside the scripts they manage and run standalone (cd ~/.dotfiles && make ...). This Makefile keeps the VM-integration targets and the installer-helper suite (safe-rm-rf). I updated CLAUDE.md and README.md so stow operations run from ~/.dotfiles, and the dotfile-management, theme, and unit-test sections point at the standalone repo. The README was already describing the old in-repo model from before the installer switched to cloning. This brings it in line.
Diffstat (limited to 'dotfiles/hyprland/.local/bin/airplane-mode')
-rwxr-xr-xdotfiles/hyprland/.local/bin/airplane-mode110
1 files changed, 0 insertions, 110 deletions
diff --git a/dotfiles/hyprland/.local/bin/airplane-mode b/dotfiles/hyprland/.local/bin/airplane-mode
deleted file mode 100755
index 4f5ed9c..0000000
--- a/dotfiles/hyprland/.local/bin/airplane-mode
+++ /dev/null
@@ -1,110 +0,0 @@
-#!/bin/sh
-# airplane-mode — toggle a low-power "airplane" state for a laptop.
-#
-# Engage: record the current state of each lever, then apply low-power values:
-# - wifi off (nmcli; bluetooth is left alone, on purpose — earbuds)
-# - CPU energy-performance preference -> power (intel_pstate, via sysfs)
-# - display brightness dimmed
-# - stop network-only services (VPNs, sync, discovery, inbound SSH)
-# Disengage: read the recorded state and restore exactly what was there. A
-# lever already in its low-power position before engaging (e.g. wifi already
-# off, a service already stopped) is left untouched on disengage.
-#
-# State lives at $XDG_RUNTIME_DIR/airplane-state as key=value lines. The
-# waybar-airplane indicator reads `mode` from it.
-#
-# Env knobs (defaults are the real system; tests override them):
-# AIRPLANE_EPP_GLOB glob of EPP sysfs files
-# AIRPLANE_BRIGHTNESS_LOW brightnessctl target while engaged
-# AIRPLANE_SYSTEM_SERVICES system units to stop (sudo)
-# AIRPLANE_USER_SERVICES --user units to stop
-
-STATE_FILE="${XDG_RUNTIME_DIR:-/tmp}/airplane-state"
-SUDO="${AIRPLANE_SUDO:-sudo}"
-EPP_GLOB="${AIRPLANE_EPP_GLOB:-/sys/devices/system/cpu/cpu*/cpufreq/energy_performance_preference}"
-BRIGHTNESS_LOW="${AIRPLANE_BRIGHTNESS_LOW:-35%}"
-SYSTEM_SERVICES="${AIRPLANE_SYSTEM_SERVICES:-tailscaled.service proton.VPN.service avahi-daemon.service cups.service wsdd.service geoclue.service sshd.service fail2ban.service}"
-USER_SERVICES="${AIRPLANE_USER_SERVICES:-syncthing.service}"
-
-read_key() { sed -n "s/^$1=//p" "$STATE_FILE" 2>/dev/null | head -n1; }
-
-set_epp() {
- # Write $1 to every EPP file. Needs root; glob expands inside the subshell.
- $SUDO sh -c "for f in $EPP_GLOB; do [ -e \"\$f\" ] && echo $1 > \"\$f\"; done" 2>/dev/null
-}
-
-first_epp() {
- for f in $EPP_GLOB; do
- [ -e "$f" ] && { cat "$f"; return; }
- done
-}
-
-engage() {
- # --- record current state ---
- wifi_was=$(nmcli radio wifi 2>/dev/null)
- epp_was=$(first_epp)
- bright_was=$(brightnessctl get 2>/dev/null)
-
- stopped_system=""
- for s in $SYSTEM_SERVICES; do
- if systemctl is-active --quiet "$s" 2>/dev/null; then
- $SUDO systemctl stop "$s" 2>/dev/null && stopped_system="$stopped_system $s"
- fi
- done
- stopped_user=""
- for s in $USER_SERVICES; do
- if systemctl --user is-active --quiet "$s" 2>/dev/null; then
- systemctl --user stop "$s" 2>/dev/null && stopped_user="$stopped_user $s"
- fi
- done
-
- # --- apply low-power settings ---
- nmcli radio wifi off 2>/dev/null
- set_epp power
- brightnessctl set "$BRIGHTNESS_LOW" >/dev/null 2>&1
-
- # --- persist what we recorded ---
- {
- echo "mode=on"
- echo "wifi=$wifi_was"
- echo "epp=$epp_was"
- echo "brightness=$bright_was"
- echo "stopped_system=$stopped_system"
- echo "stopped_user=$stopped_user"
- } > "$STATE_FILE"
-
- notify info "Airplane mode" "ON — wifi off, low power" 2>/dev/null
-}
-
-disengage() {
- wifi_was=$(read_key wifi)
- epp_was=$(read_key epp)
- bright_was=$(read_key brightness)
- stopped_system=$(read_key stopped_system)
- stopped_user=$(read_key stopped_user)
-
- # Only restore a lever that was NOT already in its low-power state.
- [ "$wifi_was" = "enabled" ] && nmcli radio wifi on 2>/dev/null
- [ -n "$epp_was" ] && set_epp "$epp_was"
- [ -n "$bright_was" ] && brightnessctl set "$bright_was" >/dev/null 2>&1
-
- for s in $stopped_system; do
- $SUDO systemctl start "$s" 2>/dev/null
- done
- for s in $stopped_user; do
- systemctl --user start "$s" 2>/dev/null
- done
-
- echo "mode=off" > "$STATE_FILE"
- notify info "Airplane mode" "OFF — settings restored" 2>/dev/null
-}
-
-case "$(read_key mode)" in
- on) disengage ;;
- *) engage ;;
-esac
-
-# Refresh the waybar indicator immediately (custom/airplane listens on signal 10).
-pkill -RTMIN+10 waybar 2>/dev/null
-
-exit 0