diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2026-10-17 10:40:11 -0700 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2026-10-17 10:40:11 -0700 |
| commit | ea127689e0ae2d39b49004be605e541ff80e2621 (patch) | |
| tree | abbe79e5e37792bd8ebea8f9ac788ff5b8aed704 /bin | |
| download | openbsd-dotfiles-ea127689e0ae2d39b49004be605e541ff80e2621.zip | |
Initial Commit
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/cwmbar | 37 | ||||
| -rwxr-xr-x | bin/sct-daemon | 23 | ||||
| -rwxr-xr-x | bin/start-tmux | 13 |
3 files changed, 73 insertions, 0 deletions
diff --git a/bin/cwmbar b/bin/cwmbar new file mode 100755 index 0000000..7d723dd --- /dev/null +++ b/bin/cwmbar @@ -0,0 +1,37 @@ +#!/bin/sh +set -o errexit + +main() { + # Redraw when the active group or the window list changes. + # -spy prints once at startup too, so the bar draws immediately. + xprop -root -spy _NET_CURRENT_DESKTOP _NET_CLIENT_LIST | + while read -r _; do + groups + done | lemonbar-xft -g x18 -B '#222222' -F '#dddddd' | sh +} + +groups() { + cur=$(xprop -root _NET_CURRENT_DESKTOP | awk '{print $3}') + num=$(xprop -root _NET_NUMBER_OF_DESKTOPS | awk '{print $3}') + + # groups that currently contain windows + occ=$(for w in $(xprop -root _NET_CLIENT_LIST | cut -d'#' -f2 | tr -d ','); do + xprop -id "$w" _NET_WM_DESKTOP 2>/dev/null | awk '{print $3}' + done | sort -u) + + out="" + i=1 # skip 0 ("nogroup") + while [ "$i" -lt "$num" ]; do + if [ "$i" -eq "$cur" ]; then + out="$out%{R} $i %{R}" # active: reversed colors + elif echo "$occ" | grep -qx "$i"; then + out="$out%{A:xdotool set_desktop $i:} $i %{A}" # occupied, clickable + else + out="$out%{F#555}%{A:xdotool set_desktop $i:} $i %{A}%{F-}" # empty, dimmed + fi + i=$((i + 1)) + done + echo "%{l}$out" +} + +main diff --git a/bin/sct-daemon b/bin/sct-daemon new file mode 100755 index 0000000..f975081 --- /dev/null +++ b/bin/sct-daemon @@ -0,0 +1,23 @@ +#!/bin/sh +set -o errexit + +main() { + while true; do + hour=$(date +%H) + if is_day "$hour"; then + sct 6500 >/dev/null + elif is_evening "$hour"; then + sct 4500 >/dev/null + elif is_night "$hour"; then + sct 3500 >/dev/null + fi + sleep 600 & + wait $! + done +} + +is_day() { [ "$1" -ge 6 ] && [ "$1" -lt 17 ]; } +is_evening() { [ "$1" -ge 17 ] && [ "$1" -lt 20 ]; } +is_night() { [ "$1" -ge 20 ] && [ "$1" -lt 6 ]; } + +main diff --git a/bin/start-tmux b/bin/start-tmux new file mode 100755 index 0000000..12b22ad --- /dev/null +++ b/bin/start-tmux @@ -0,0 +1,13 @@ +#!/bin/sh +set -o errexit + +readonly SESSION_NAME="$USER" + +main() { + if ! tmux has-session -t "$SESSION_NAME" 2>/dev/null; then + tmux new-session -A -s "$SESSION_NAME" -d + fi + exec tmux attach-session -t "$SESSION_NAME" +} + +main |