dotfiles/.local/bin/dwmbar

57 lines
1.1 KiB
Plaintext
Raw Normal View History

2022-08-14 02:10:53 +08:00
#!/bin/bash
2022-10-01 14:45:43 +08:00
DD=";"
2022-08-17 22:38:29 +08:00
DELIM=" "
DELIM_START=0
2022-08-14 02:10:53 +08:00
2022-08-19 18:02:28 +08:00
mkdir -p ~/.local/tmp/
run() {
for FILE in $(ls ~/.local/scripts)
do
touch "$HOME/.local/tmp/.tmp_$(echo $FILE | cut -d'_' -f3)_BIT"
{
while true
do
echo "$(sh ~/.local/scripts/$FILE)" > "$HOME/.local/tmp/.tmp_$(echo $FILE | cut -d'_' -f3)_BIT"
sleep=$(echo $FILE | cut -d'_' -f2)
if [ $sleep -eq 0 ]
then
sleep=0.1
fi
sleep $sleep
done
} &
done
}
2022-08-14 02:10:53 +08:00
status() {
2022-08-17 22:38:29 +08:00
strt=0
[ $DELIM_START -eq 1 ] && strt=1
2022-08-14 02:10:53 +08:00
for FILE in $(ls ~/.local/scripts)
do
2022-08-19 18:02:28 +08:00
res=$(cat "$HOME/.local/tmp/.tmp_$(echo $FILE | cut -d'_' -f3)_BIT")
2022-08-17 22:38:29 +08:00
if [ $strt -eq 0 ]
then
strt=1
echo "$res"
else
echo "$DELIM$res"
fi
2022-08-14 02:10:53 +08:00
done
}
2022-08-19 18:02:28 +08:00
run
2022-08-14 02:10:53 +08:00
2022-08-19 18:02:28 +08:00
while :
2022-08-14 02:10:53 +08:00
do
2022-08-19 18:02:28 +08:00
stat=$(status | tr -d '\n')
2022-10-01 14:45:43 +08:00
extrabarleft="^b#440044^Status^d^ ^c#ff0000^bar 2^d^"
extrabarright="^b#444400^Right ^b#00ff00^text^d^ ^c#ff0000^pisec ^b#000044^dlinee3bu^d^"
xprop -root -set WM_NAME "$stat$DD$extrabarleft$DD$extrabarright"
2022-08-19 18:02:28 +08:00
sleep 0.1
2022-08-14 02:10:53 +08:00
done
2022-08-19 18:02:28 +08:00