diff options
author | David Robillard <d@drobilla.net> | 2016-05-26 12:03:11 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2016-05-26 12:05:22 -0400 |
commit | dd2bd3ac588d45daa101fc5a1cd4adcd912630e8 (patch) | |
tree | 9fab9e4f38969db90341a13a21d6bb5c667e11a1 /bspwm | |
parent | 2f7ffcb1dccdb4a33841b7a3532be2c8db820038 (diff) | |
download | dotfiles-dd2bd3ac588d45daa101fc5a1cd4adcd912630e8.tar.gz dotfiles-dd2bd3ac588d45daa101fc5a1cd4adcd912630e8.tar.bz2 dotfiles-dd2bd3ac588d45daa101fc5a1cd4adcd912630e8.zip |
Add lemonbar configuration
Diffstat (limited to 'bspwm')
-rwxr-xr-x | bspwm/bspwmrc | 11 | ||||
-rwxr-xr-x | bspwm/panel | 90 | ||||
-rwxr-xr-x | bspwm/panel_bar | 96 |
3 files changed, 194 insertions, 3 deletions
diff --git a/bspwm/bspwmrc b/bspwm/bspwmrc index f31395a..efeb927 100755 --- a/bspwm/bspwmrc +++ b/bspwm/bspwmrc @@ -1,6 +1,11 @@ #! /bin/sh -export PANEL_HEIGHT=16 +export PANEL_FIFO=/home/drobilla/bspwmpanel.fifo +export PANEL_HEIGHT=18 +export PANEL_FONT="DejaVu Sans Mono-11" +export TRAY_HEIGHT=16 +export SCREEN_WIDTH="$(xrandr | grep '*' | sed 's/ *\([0-9]*\)x.*/\1/')" +export TRAY_X="$(echo "$SCREEN_WIDTH - 550" | bc)" bspc config border_width 2 bspc config window_gap 12 @@ -19,6 +24,6 @@ bspc monitor -d 1 2 3 4 5 6 7 8 9 xsetroot -solid "#000" sxhkd & -conky & -stalonetray -bg "#000" --geometry "1x1+2570+6" --grow-gravity E -i $PANEL_HEIGHT & +~/.config/bspwm/panel & +stalonetray -bg "#000" --geometry "1x1+$TRAY_X+2" --grow-gravity E -i $TRAY_HEIGHT & xdotool search --classname stalonetray windowraise 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 diff --git a/bspwm/panel_bar b/bspwm/panel_bar new file mode 100755 index 0000000..72e7629 --- /dev/null +++ b/bspwm/panel_bar @@ -0,0 +1,96 @@ +#! /bin/sh + +#. panel_colors + +n_monitors=$(bspc query -M | wc -l) + +while read -r line ; do + case $line in + S*) + # Clock + sys_info="%{F$COLOR_STATUS_FG}%{B$COLOR_STATUS_BG}${line#?}%{B-}%{F-}" + ;; + T*) + # Title + title="%{F$COLOR_TITLE_FG}%{B$COLOR_TITLE_BG}${line#?}%{B-}%{F-}" + ;; + I*) + # IO + io_info="%{F$COLOR_STATUS_FG}%{B$COLOR_STATUS_BG}${line#?}%{B-}%{F-}" + ;; + B*) + # Battery + bat_info="%{F$COLOR_STATUS_FG}%{B$COLOR_STATUS_BG} ${line#?} %{B-}%{F-}" + ;; + C*) + # CPU temperature + temp_info="%{F$COLOR_STATUS_FG}%{B$COLOR_STATUS_BG}${line#?}°%{B-}%{F-}" + ;; + L*) + # CPU load + load_info="%{F$COLOR_STATUS_FG}%{B$COLOR_STATUS_BG}${line#?}%%{B-}%{F-}" + ;; + M*) + # Memory usage + mem_info="%{F$COLOR_STATUS_FG}%{B$COLOR_STATUS_BG}${line#?}%{B-}%{F-}" + ;; + N*) + # Network throughput + net_info="%{F$COLOR_STATUS_FG}%{B$COLOR_STATUS_BG}${line#?}%{B-}%{F-}" + ;; + W*) + # Window manager state + wm_info="" + IFS=':' + set -- ${line#?} + while [ $# -gt 0 ] ; do + item=$1 + name=${item#?} + case $item in + M*) + # active monitor + if [ $n_monitors -gt 1 ] ; then + wm_info="$wm_info %{F$COLOR_ACTIVE_MONITOR_FG}%{B$COLOR_ACTIVE_MONITOR_BG}${name} %{B-}%{F-} " + fi + ;; + m*) + # inactive monitor + if [ $n_monitors -gt 1 ] ; then + wm_info="$wm_info %{F$COLOR_INACTIVE_MONITOR_FG}%{B$COLOR_INACTIVE_MONITOR_BG}${name}%{B-}%{F-} " + fi + ;; + O*) + # focused occupied desktop + wm_info="${wm_info}%{F$COLOR_FOCUSED_OCCUPIED_FG}%{B$COLOR_FOCUSED_OCCUPIED_BG}%{U$COLOR_FOREGROUND}%{+u}${name}%{-u}%{B-}%{F-} " + ;; + F*) + # focused free desktop + wm_info="${wm_info}%{F$COLOR_FOCUSED_FREE_FG}%{B$COLOR_FOCUSED_FREE_BG}%{U$COLOR_FOREGROUND}%{+u}${name}%{-u}%{B-}%{F-} " + ;; + U*) + # focused urgent desktop + wm_info="${wm_info}%{F$COLOR_FOCUSED_URGENT_FG}%{B$COLOR_FOCUSED_URGENT_BG}%{U$COLOR_FOREGROUND}%{+u}${name}%{-u}%{B-}%{F-} " + ;; + o*) + # occupied desktop + wm_info="${wm_info}%{F$COLOR_OCCUPIED_FG}%{B$COLOR_OCCUPIED_BG}${name}%{B-}%{F-} " + ;; + f*) + # free desktop + wm_info="${wm_info}%{F$COLOR_FREE_FG}%{B$COLOR_FREE_BG}${name}%{B-}%{F-} " + ;; + u*) + # urgent desktop + wm_info="${wm_info}%{F$COLOR_URGENT_FG}%{B$COLOR_URGENT_BG}${name}%{B-}%{F-} " + ;; + L*) + # layout + #wm_info="$wm_info %{F$COLOR_LAYOUT_FG}%{B$COLOR_LAYOUT_BG} ${name} %{B-}%{F-}" + ;; + esac + shift + done + ;; + esac + printf "%s\n" "%{l}${wm_info} : ${load_info} ${temp_info} : ${mem_info} :${io_info} : ${net_info}%{c} ${title} %{r} ${bat_info}${sys_info}" +done |