36 lines
1.0 KiB
Bash
Executable File
36 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Define the file to modify
|
|
FILE="$HOME/.config/hypr/monitors.conf"
|
|
|
|
DELAY="1"
|
|
|
|
# Get specific lines from the file
|
|
LINE_DISABLE=$(sed -n '3p' "$FILE") # 3rd line: disable HDMI
|
|
LINE_MIRROR=$(sed -n '4p' "$FILE") # 4th line: mirror configuration
|
|
|
|
# Check if the first argument is "g" (get status)
|
|
if [ "$1" = "g" ]; then
|
|
[[ $LINE_MIRROR == \#* ]] && echo false || echo true
|
|
exit 0
|
|
fi
|
|
|
|
# Check if mirror mode is currently active (last line is NOT commented)
|
|
if [[ $LINE_MIRROR != \#* ]]; then
|
|
# Switching FROM mirror mode TO normal mode
|
|
# Comment the mirror line (disable mirror)
|
|
sed -i '4s/^/# /' "$FILE"
|
|
# Uncomment the disable line (temporarily disable HDMI)
|
|
sed -i '3s/^# //' "$FILE"
|
|
sleep $DELAY
|
|
sed -i '3s/^/# /' "$FILE"
|
|
else
|
|
sed -i '3s/^# //' "$FILE"
|
|
# Switching TO mirror mode FROM normal mode
|
|
# Uncomment the mirror line (enable mirror)
|
|
sed -i '4s/^# //' "$FILE"
|
|
sleep $DELAY
|
|
# Comment the disable line (don't need explicit disable when using mirror)
|
|
sed -i '3s/^/# /' "$FILE"
|
|
fi
|