30 lines
679 B
Bash
Executable File
30 lines
679 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 -x hyprdynamicmonitors 2>/dev/null || true
|
|
hyprdynamicmonitors &
|
|
|
|
notify-send "Écrans" "Mode : $next" |