Initial commit

This commit is contained in:
Just Midi 2021-11-29 22:50:28 -06:00
commit 44e603c1d7
3 changed files with 188 additions and 0 deletions

35
panel Executable file
View File

@ -0,0 +1,35 @@
#! /bin/sh
PANEL_FIFO=/tmp/panel-fifo
PANEL_HEIGHT=24
PANEL_FONT="-*-fixed-*-*-*-*-10-*-*-*-*-*-*-*"
PANEL_WM_NAME=bspwm_panel
export PANEL_FIFO PANEL_HEIGHT PANEL_FONT PANEL_WM_NAME
if xdo id -a "$PANEL_WM_NAME" > /dev/null ; then
printf "%s\n" "The panel is already running." >&2
exit 1
fi
trap 'trap - TERM; kill 0' INT TERM QUIT EXIT
[ -e "$PANEL_FIFO" ] && rm "$PANEL_FIFO"
mkfifo "$PANEL_FIFO"
bspc subscribe report > "$PANEL_FIFO" &
while :; do
date '+%y-%m-%d %H:%M' | xargs -0 printf "D%s"
top -bn1 | grep 'Cpu(s)' | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}' | xargs -0 printf "C%s"
free -h | awk '/^Mem/ { print $3 " / " $2 }' | sed 's/i//g' | xargs -0 printf "R%s"
sleep 1
done > "$PANEL_FIFO" &
. .config/panel/panel_colors
.config/panel/panel_bar < "$PANEL_FIFO" | lemonbar -a 32 -u 2 -n "$PANEL_WM_NAME" -g x$PANEL_HEIGHT -f "$PANEL_FONT" -F "$COLOR_DEFAULT_FG" -B "$COLOR_DEFAULT_BG" | sh &
wid=$(xdo id -m -a "$PANEL_WM_NAME")
xdo above -t "$(xdo id -N Bspwm -n root | sort | head -n 1)" "$wid"
wait

129
panel_bar Executable file
View File

@ -0,0 +1,129 @@
#! /bin/sh
. .config/panel/panel_colors
num_mon=$(bspc query -M | wc -l)
while read -r line ; do
case $line in
C*)
# cpu output
cpu="%{F$COLOR_SYS_FG}%{B$COLOR_SYS_BG} ${line#?} %{B-}%{F-}"
;;
D*)
# clock output
datetime="%{F$COLOR_SYS_FG}%{B$COLOR_SYS_BG} ${line#?} %{B-}%{F-}"
;;
M*)
# mpv and such
media="%{F$COLOR_TITLE_FG}%{B$COLOR_TITLE_BG} ${line#?} %{B-}%{F-}"
;;
R*)
# memory output
ram="%{F$COLOR_SYS_FG}%{B$COLOR_SYS_BG} ${line#?} %{B-}%{F-}"
;;
T*)
# xtitle output
title="%{F$COLOR_TITLE_FG}%{B$COLOR_TITLE_BG} ${line#?} %{B-}%{F-}"
;;
W*)
# bspwm's state of desktops
#refactor later
wm=
IFS=':'
set -- ${line#?}
while [ $# -gt 0 ] ; do
item=$1
name=${item#?}
case $item in
[mM]*)
case $item in
m*)
# monitor
FG=$COLOR_MONITOR_FG
BG=$COLOR_MONITOR_BG
on_focused_monitor=
;;
M*)
# focused monitor
FG=$COLOR_FOCUSED_MONITOR_FG
BG=$COLOR_FOCUSED_MONITOR_BG
on_focused_monitor=1
;;
esac
[ $num_mon -lt 2 ] && shift && continue
wm="${wm}%{F${FG}}%{B${BG}}%{A:bspc monitor -f ${name}:} ${name} %{A}%{B-}%{F-}"
;;
[fFoOuU]*)
case $item in
f*)
# free desktop
FG=$COLOR_FREE_FG
BG=$COLOR_FREE_BG
UL=$BG
;;
F*)
if [ "$on_focused_monitor" ] ; then
# focused free desktop
FG=$COLOR_FOCUSED_FREE_FG
BG=$COLOR_FOCUSED_FREE_BG
UL=$BG
else
# active free desktop
FG=$COLOR_FREE_FG
BG=$COLOR_FREE_BG
UL=$COLOR_FOCUSED_FREE_BG
fi
;;
o*)
# occupied desktop
FG=$COLOR_OCCUPIED_FG
BG=$COLOR_OCCUPIED_BG
UL=$BG
;;
O*)
if [ "$on_focused_monitor" ] ; then
# focused occupied desktop
FG=$COLOR_FOCUSED_OCCUPIED_FG
BG=$COLOR_FOCUSED_OCCUPIED_BG
UL=$BG
else
# active occupied desktop
FG=$COLOR_OCCUPIED_FG
BG=$COLOR_OCCUPIED_BG
UL=$COLOR_FOCUSED_OCCUPIED_BG
fi
;;
u*)
# urgent desktop
FG=$COLOR_URGENT_FG
BG=$COLOR_URGENT_BG
UL=$BG
;;
U*)
if [ "$on_focused_monitor" ] ; then
# focused urgent desktop
FG=$COLOR_FOCUSED_URGENT_FG
BG=$COLOR_FOCUSED_URGENT_BG
UL=$BG
else
# active urgent desktop
FG=$COLOR_URGENT_FG
BG=$COLOR_URGENT_BG
UL=$COLOR_FOCUSED_URGENT_BG
fi
;;
esac
wm="${wm}%{F${FG}}%{B${BG}}%{U${UL}}%{+u}%{A:bspc desktop -f ${name}:} ${name} %{A}%{B-}%{F-}%{-u}"
;;
[LTG]*)
# layout, state and flags
wm="${wm}%{F$COLOR_STATE_FG}%{B$COLOR_STATE_BG} ${name} %{B-}%{F-}"
;;
esac
shift
done
;;
esac
printf "%s\n" "%{l}${wm}${title}%{c}${media}%{r}${cpu}${ram}${datetime}"
done

24
panel_colors Executable file
View File

@ -0,0 +1,24 @@
COLOR_DEFAULT_FG="#a7a5a5"
COLOR_DEFAULT_BG="#333232"
COLOR_MONITOR_FG="#8dbcdf"
COLOR_MONITOR_BG="#333232"
COLOR_FOCUSED_MONITOR_FG="#b1d0e8"
COLOR_FOCUSED_MONITOR_BG="#144b6c"
COLOR_FREE_FG="#737171"
COLOR_FREE_BG="#333232"
COLOR_FOCUSED_FREE_FG="#000000"
COLOR_FOCUSED_FREE_BG="#504e4e"
COLOR_OCCUPIED_FG="#a7a5a5"
COLOR_OCCUPIED_BG="#333232"
COLOR_FOCUSED_OCCUPIED_FG="#d6d3d2"
COLOR_FOCUSED_OCCUPIED_BG="#504e4e"
COLOR_URGENT_FG="#f15d66"
COLOR_URGENT_BG="#333232"
COLOR_FOCUSED_URGENT_FG="#501d1f"
COLOR_FOCUSED_URGENT_BG="#d5443e"
COLOR_STATE_FG="#89b09c"
COLOR_STATE_BG="#333232"
COLOR_TITLE_FG="#a8a2c0"
COLOR_TITLE_BG="#333232"
COLOR_SYS_FG="#b1a57d"
COLOR_SYS_BG="#333232"