Files
arch-dotfiles/.config/hyprdynamicmonitors/scripts/display-toggle.sh
2026-08-29 13:54:04 +02:00

31 lines
708 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
CONFIG="$HOME/.config/hyprdynamicmonitors/config.toml"
get_current_mode() {
grep -m1 '^mode = "' "$CONFIG" | sed 's/^mode = "\(.*\)"/\1/'
}
set_mode() {
local new_mode="$1"
sed -i --follow-symlinks 's/^mode = ".*"/mode = "'"$new_mode"'"/' "$CONFIG"
}
current=$(get_current_mode)
case "$current" in
both) next="external" ;;
external) next="laptop" ;;
laptop) next="both" ;;
*) next="both" ;;
esac
set_mode "$next"
# Redémarrage de hyprdynamicmonitors pour appliquer la nouvelle config
pkill -f -x hyprdynamicmonitors 2>/dev/null || true
sleep 0.2
hyprdynamicmonitors >/dev/null 2>&1 &
notify-send "Écrans" "Mode : $next"