diff options
| author | Ryan Schanzenbacher <ryan@rschanz.org> | 2026-07-11 22:14:43 -0400 |
|---|---|---|
| committer | Ryan Schanzenbacher <ryan@rschanz.org> | 2026-07-11 22:14:43 -0400 |
| commit | d2b62c9d6f30a0ea88b2a235cde120cd10ba332b (patch) | |
| tree | f373003e64c3ec4593d7ae4ffac72de52767aa70 /users/ryan/modules/sketchybar/bar-config/plugins/caffeinate.sh | |
| parent | 27117202739f092d837af2752e4b9801c47b8ddb (diff) | |
Sketchybar now, got tired of the battery issue
Diffstat (limited to 'users/ryan/modules/sketchybar/bar-config/plugins/caffeinate.sh')
| -rwxr-xr-x | users/ryan/modules/sketchybar/bar-config/plugins/caffeinate.sh | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/users/ryan/modules/sketchybar/bar-config/plugins/caffeinate.sh b/users/ryan/modules/sketchybar/bar-config/plugins/caffeinate.sh new file mode 100755 index 0000000..ce4c4d2 --- /dev/null +++ b/users/ryan/modules/sketchybar/bar-config/plugins/caffeinate.sh | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | #!/usr/bin/env bash | ||
| 2 | # idle_inhibitor -> caffeinate (keeps display + system awake while "activated") | ||
| 3 | source "$CONFIG_DIR/colors.sh" | ||
| 4 | source "$CONFIG_DIR/icons.sh" | ||
| 5 | |||
| 6 | PIDFILE="/tmp/sketchybar_caffeinate.pid" | ||
| 7 | is_on() { [ -f "$PIDFILE" ] && kill -0 "$(cat "$PIDFILE")" 2>/dev/null; } | ||
| 8 | |||
| 9 | if [ "$1" = "toggle" ]; then | ||
| 10 | if is_on; then | ||
| 11 | kill "$(cat "$PIDFILE")" 2>/dev/null; rm -f "$PIDFILE" | ||
| 12 | else | ||
| 13 | caffeinate -d -i -s & echo $! > "$PIDFILE" | ||
| 14 | fi | ||
| 15 | fi | ||
| 16 | |||
| 17 | if is_on; then | ||
| 18 | sketchybar --set "$NAME" label="$IDLE_ON" label.color=$TEXT # activated | ||
| 19 | else | ||
| 20 | sketchybar --set "$NAME" label="$IDLE_OFF" label.color=$TEXT_DIM # deactivated | ||
| 21 | fi | ||
