Last active
July 4, 2018 08:03
-
-
Save jshiell/53b9c34e49e3d00cab0459501042b952 to your computer and use it in GitHub Desktop.
Dashboard Linux monitor control for Ubuntu/Raspian
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
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| IFS=$'\n\t' | |
| readonly VBETOOL=/usr/sbin/vbetool | |
| turn_off_screen() { | |
| if [[ -x "$VBETOOL" ]]; then | |
| "$VBETOOL" dpms off | |
| else | |
| xset -display :0 dpms force off | |
| fi | |
| } | |
| turn_on_screen() { | |
| if [[ -x "$VBETOOL" ]]; then | |
| "$VBETOOL" dpms on | |
| else | |
| xset -display :0 dpms force on | |
| fi | |
| } | |
| main() { | |
| if [[ -x "$VBETOOL" && "$UID" != 0 ]]; then | |
| echo "This script must be run as root when using vbetool" | |
| exit 1 | |
| fi | |
| local WAKE_START_HOUR=8 | |
| local WAKE_END_HOUR=18 | |
| local SATURDAY=6 | |
| local CURRENT_HOUR=$(date +"%k") | |
| local DAY_OF_WEEK=$(date +"%u") | |
| if [[ "$CURRENT_HOUR" -ge "$WAKE_START_HOUR" && "$CURRENT_HOUR" -lt "$WAKE_END_HOUR" && "$DAY_OF_WEEK" -lt "$SATURDAY" ]]; then | |
| turn_on_screen | |
| else | |
| turn_off_screen | |
| fi | |
| } | |
| main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment