Files
dotfiles/hosts/sctfw004/hypr/clamshell.sh
T
connor e6644d0616 Rebuild dotfiles as one branch with per-host layers
Replaces the previous repo, which had split into two histories that never
met (mainframe on a dead GitLab remote, the laptops on Gitea) with 146
dirty files across three machines and the NAS never enrolled at all.

Branch-per-machine is gone. One main, with host differences expressed as
small files under hosts/<hostname>/ rather than as branches, so there is
nothing to merge. The reconciled zsh layer reduces 15-33 line forks to
1-7 effective lines per host; distro differences (oh-my-zsh prefix,
syntax-highlighting path, fd vs fdfind) are probed in common/ instead.

Fresh history: the old one carried six plaintext credentials, 45 MB of
mail caches, browser caches and vendored binaries. 5,096 tracked files
and 144 MB become 462 files and 2.6 MB. The .gitignore is now an
allowlist, which is what keeps that true.

Root cause of the rot: ~/.local/bin was a symlink to scripts/ with GOPATH
inside it, so every go install wrote into version control (2.2 GB on the
work laptop). PATH now points at the repo instead of the reverse.

Also: Hyprland replaces sway and is sourced in two halves so $browser is
defined before use; singleton automations carry ConditionHost= alongside
host-layer-only placement; ddns moves from cron to a guarded timer;
package manifests and pkg-snapshot/pkg-restore replace the X11-era
install_scripts/; networkmanager-dmenu added to system76 (the binding
always existed, the package never did).
2026-09-14 14:24:37 -04:00

54 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# --- CONFIGURATION ---
# Change this to your internal monitor name (use 'hyprctl monitors' to find it)
INTERNAL_DISPLAY="eDP-1"
# Icons for notifications (ensure you have an icon theme installed)
ICON_LAPTOP="computer-laptop"
ICON_MONITOR="video-display"
# --- FUNCTIONS ---
notify_user() {
# Change '-u low' to '-u normal' if you want popups to stay longer
notify-send -u low -i "$3" "$1" "$2"
}
# --- MODES ---
mode_close() {
# Only disable internal screen if an external monitor is connected
MONITORS_COUNT=$(hyprctl monitors all | grep -c "Monitor")
if [[ $MONITORS_COUNT -gt 1 ]]; then
hyprctl keyword monitor "$INTERNAL_DISPLAY, disable"
sed -i "s/^monitor = $INTERNAL_DISPLAY, preferred, auto, auto$/monitor = $INTERNAL_DISPLAY, disable/" ~/.config/hypr/hyprland.conf
fi
}
mode_open() {
# Force enable internal screen
hyprctl keyword monitor "$INTERNAL_DISPLAY, preferred, auto, 1"
sed -i "s/^monitor = $INTERNAL_DISPLAY, disable$/monitor = $INTERNAL_DISPLAY, preferred, auto, auto/" ~/.config/hypr/hyprland.conf
}
# --- LOGIC ---
if [[ "$1" == "close" ]]; then
mode_close
notify_user "Clamshell Mode" "External monitor active. Laptop screen disabled." "$ICON_MONITOR"
elif [[ "$1" == "open" ]]; then
mode_open
notify_user "Laptop Mode" "Laptop screen enabled." "$ICON_LAPTOP"
elif [[ "$1" == "check" ]]; then
# Silent check for startup/reload to sync state
if grep -q "open" /proc/acpi/button/lid/*/state; then
mode_open
else
mode_close
fi
else
echo "Usage: $0 [open|close|check]"
exit 1
fi