dot_testing/builds/utils/sh/statusbar

24 lines
617 B
Bash
Executable File

#!/bin/sh
barwidth=20
# remove all current statusbars
# pgrep doesn't handle arguments for running commands
# shellcheck disable=2009
processes="$(ps aux | grep 'st -c' | grep 'status' | awk -F' ' '{print $2}')"
for i in $processes; do
pkill -P "$i" >/dev/null 2>&1
kill "$i"
done
# get all screens
screens="$(xrandr | grep ' connected' | sed 's/ primary//g' | awk -F' ' '{print $1 " " $3}')"
# for every screen, create a statusbar
IFS="
"
for i in $screens; do
screenstring=$(echo "$i" | awk -v a="$barwidth" -F'[ x+]' '{print $2 "x" a "+" $4 "+" $5}')
st -c statusbar -p -g "$screenstring" -e status &
done