Skip to content

Instantly share code, notes, and snippets.

@0xAungkon
Last active April 28, 2025 07:01
Show Gist options
  • Select an option

  • Save 0xAungkon/0c073f8225d63578ba390bfec042f162 to your computer and use it in GitHub Desktop.

Select an option

Save 0xAungkon/0c073f8225d63578ba390bfec042f162 to your computer and use it in GitHub Desktop.
screen_blackout.sh
#!/bin/bash
STATUS_FILE="$HOME/.screenstatus"
# If file doesn't exist, create it with 0
if [ ! -f "$STATUS_FILE" ]; then
echo 0 > "$STATUS_FILE"
fi
# Read current status
status=$(cat "$STATUS_FILE")
# Get all connected displays
displays=$(xrandr --verbose | grep " connected" | cut -d" " -f1)
if [ "$status" -eq 0 ]; then
# Set brightness to 0
for display in $displays; do
xrandr --output "$display" --brightness 0
done
echo 1 > "$STATUS_FILE"
else
# Set brightness to 1
for display in $displays; do
xrandr --output "$display" --brightness 1
done
echo 0 > "$STATUS_FILE"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment