Last active
April 28, 2025 07:01
-
-
Save 0xAungkon/0c073f8225d63578ba390bfec042f162 to your computer and use it in GitHub Desktop.
screen_blackout.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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