Files
whyfile---Niri-Dots/config/niri/off.sh
2025-08-25 14:50:36 +03:00

35 lines
1.1 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
CONFIG_FILE="/home/whyoolw/.config/niri/config.kdl"
TMP_FILE="${CONFIG_FILE}.tmp"
# Считываем текущий статус eDP-1
EDP_BLOCK=$(awk '/output "eDP-1"[[:space:]]*\{/,/\}/' "$CONFIG_FILE")
if echo "$EDP_BLOCK" | grep -q 'off'; then
# Включаем монитор: удаляем строку с "off"
awk '
BEGIN {inside=0}
/output "eDP-1"[[:space:]]*\{/ {inside=1}
inside && /off/ {next}
inside && /\}/ {inside=0}
{print}
' "$CONFIG_FILE" > "$TMP_FILE" && mv "$TMP_FILE" "$CONFIG_FILE"
echo "Монитор eDP-1 включен."
else
# Выключаем монитор: добавляем "off" после строки с открывающей скобкой
awk '
BEGIN {inside=0}
/output "eDP-1"[[:space:]]*\{/ {
print
print " off"
inside=1
next
}
inside && /\}/ {inside=0}
{print}
' "$CONFIG_FILE" > "$TMP_FILE" && mv "$TMP_FILE" "$CONFIG_FILE"
echo "Монитор eDP-1 выключен."
fi