diff options
Diffstat (limited to 'bspwm/panel')
-rwxr-xr-x | bspwm/panel | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/bspwm/panel b/bspwm/panel new file mode 100755 index 0000000..bb5df43 --- /dev/null +++ b/bspwm/panel @@ -0,0 +1,90 @@ +#! /bin/sh + +export COLOR_FOREGROUND='#FFA3A6AB' +export COLOR_BACKGROUND='#FF000000' +export COLOR_ACTIVE_MONITOR_FG='#FF000000' +export COLOR_ACTIVE_MONITOR_BG='#FF000000' +export COLOR_INACTIVE_MONITOR_FG='#FF58C5F1' +export COLOR_INACTIVE_MONITOR_BG='#FF000000' +export COLOR_FOCUSED_OCCUPIED_FG='#FFF6F9FF' +export COLOR_FOCUSED_OCCUPIED_BG='#FF000000' +export COLOR_FOCUSED_FREE_FG='#FFF6F9FF' +export COLOR_FOCUSED_FREE_BG='#FF000000' +export COLOR_FOCUSED_URGENT_FG='#FF000000' +export COLOR_FOCUSED_URGENT_BG='#FFF9A299' +export COLOR_OCCUPIED_FG='#FFA3A6AB' +export COLOR_OCCUPIED_BG='#FF000000' +export COLOR_FREE_FG='#FF6F7277' +export COLOR_FREE_BG='#FF000000' +export COLOR_URGENT_FG='#FFF9A299' +export COLOR_URGENT_BG='#FF000000' +export COLOR_LAYOUT_FG='#FFA3A6AB' +export COLOR_LAYOUT_BG='#FF000000' +export COLOR_TITLE_FG='#FFA3A6AB' +export COLOR_TITLE_BG='#FF000000' +export COLOR_STATUS_FG='#FFA3A6AB' +export COLOR_STATUS_BG='#FF000000' +export COLOR_STATUS_READ="#859900" +export COLOR_STATUS_WRITE="#990A1B" + +if [ $(pgrep -cx panel) -gt 1 ] ; 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 config top_padding $PANEL_HEIGHT +bspc control --subscribe > "$PANEL_FIFO" & +xtitle -sf 'T%s' > "$PANEL_FIFO" & +clock -sf 'S%a %Y-%m-%d %H:%M' > "$PANEL_FIFO" & +mpstat 1 | stdbuf -oL awk '$12 ~ /[0-9.]+/ { printf "L%3d\n", 100 - $12 }' > "$PANEL_FIFO" & +free -m -s 1 | stdbuf -oL awk '/^Mem:.*/ { print "M"$2 - $6 - $7"/"$2 }' > "$PANEL_FIFO" & +iostat -y -d 1 | stdbuf -oL awk '/Device.*/ { printf("\nI"); next } /^[0-9a-z]* / { printf " %s %04.0f↓ %04.0f↑", $1, $3, $4 } END { printf "\n" }' > "$PANEL_FIFO" & + +# Battery +while :; do + acpi -b | sed 's/.*, /B/' > "$PANEL_FIFO" + sleep 1 +done & + +# Temperature +while :; do + cat /sys/devices/virtual/thermal/thermal_zone0/temp | sed 's/[0-9][0-9][0-9]$//' | sed 's/^/C/' > "$PANEL_FIFO" + sleep 2 +done & + +# Network throughput +while :; do + net_info=$( + ip -4 -o addr show | grep -v ' lo ' | + while read line; do + iface=$(echo $line | cut -d ' ' -f 2); + addr=$(echo $line | cut -d ' ' -f 4 | sed 's/\/.*//'); + + rf=/sys/class/net/eth0/statistics/rx_bytes; + tf=/sys/class/net/eth0/statistics/tx_bytes; + + # Get RX and TX bytes then sleep for ~1 second + r1=`cat $rf`; + t1=`cat $tf`; + sleep 1 + + # Get RX and TX bytes and print rates in KBPS + r2=`cat $rf`; + t2=`cat $tf`; + rr="$(((r2-r1)/1024))"; + tr="$(((t2-t1)/1024))"; + printf "$iface $addr %04.0f↓ %04.0f↑ " $rr $tr + done) + echo "N$net_info" > "$PANEL_FIFO" +done & + +#. ./panel_colors + +cat "$PANEL_FIFO" | ~/.config/bspwm/panel_bar | lemonbar -f "Deja Vu Sans Mono-11" -g x$PANEL_HEIGHT -f "$PANEL_FONT" -F "$COLOR_FOREGROUND" -B "$COLOR_BACKGROUND" & + +wait |