From 274c4c187f199d1c9dc59793f99e50d2d50f01a9 Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado <55825613+luevano@users.noreply.github.com> Date: Sun, 20 Dec 2020 13:11:43 -0700 Subject: Add polybar and rename lemonbar --- .local/bin/statusbar/lemonbar_panel | 55 ++++++++++++++ .local/bin/statusbar/lemonbar_panel_colors | 24 +++++++ .local/bin/statusbar/lemonbar_panel_main | 112 +++++++++++++++++++++++++++++ .local/bin/statusbar/panel | 55 -------------- .local/bin/statusbar/panel_colors | 24 ------- .local/bin/statusbar/panel_main | 112 ----------------------------- .local/bin/statusbar/polybar_panel | 21 ++++++ 7 files changed, 212 insertions(+), 191 deletions(-) create mode 100755 .local/bin/statusbar/lemonbar_panel create mode 100644 .local/bin/statusbar/lemonbar_panel_colors create mode 100755 .local/bin/statusbar/lemonbar_panel_main delete mode 100755 .local/bin/statusbar/panel delete mode 100644 .local/bin/statusbar/panel_colors delete mode 100755 .local/bin/statusbar/panel_main create mode 100755 .local/bin/statusbar/polybar_panel (limited to '.local/bin') diff --git a/.local/bin/statusbar/lemonbar_panel b/.local/bin/statusbar/lemonbar_panel new file mode 100755 index 0000000..c4f400f --- /dev/null +++ b/.local/bin/statusbar/lemonbar_panel @@ -0,0 +1,55 @@ +#!/bin/sh +# General script that manages the bar. + +STATUSBAR_FIFO=/tmp/lemonbar-panel-fifo +STATUSBAR_HEIGHT=20 +STATUSBAR_FONT="Noto Sans Mono:size=10" +STATUSBAR_EMOJI_FONT0="Noto Color Emoji" +STATUSBAR_EMOJI_FONT1="Font Awesome 5 Free" +STATUSBAR_EMOJI_FONT2="Font Awesome 5 Brands" +STATUSBAR_EMOJI_FONT3="Font Awesome 5 Free Solid" +STATUSBAR_WM_NAME=bspwm_lemonbar_panel +. lemonbar_panel_colors + + +if xdo id -a "$STATUSBAR_WM_NAME" > /dev/null ; then + printf "%s\n" "The status bar is already running. Try pkill -x panel." >&2 + exit 1 +fi + +trap 'trap - TERM; kill 0' INT TERM QUIT EXIT + + +# Create a new FIFO. (Pipe) +[ -e "$STATUSBAR_FIFO" ] && rm "$STATUSBAR_FIFO" +mkfifo "$STATUSBAR_FIFO" + + +# Here is where all the 'plugins' or 'blocks' for the bar. +# are run. They're piped into the FIFO for later reading. +# In general you want them to print a letter at the beginning and then +# the actual stuff to show on scren, so you can distinguish between them on the actual bars. +xtitle -sf 'T%s\n' > "$STATUSBAR_FIFO" & +# date +"C%d/%m%y %r" > "$STATUSBAR_FIFO" & +bspc subscribe report > "$STATUSBAR_FIFO" & + + +# Here you can start N amount of bars and each one would be +# different if required. Piping into 'sh' is required for interaction +# with the bar. +lemonbar_panel_main < "$STATUSBAR_FIFO" | lemonbar -a 32 -u 2 -n "$STATUSBAR_WM_NAME" -g x$STATUSBAR_HEIGHT -f "$STATUSBAR_FONT" -f "$STATUSBAR_EMOJI_FONT0" -f "$STATUSBAR_EMOJI_FONT1" -f "$STATUSBAR_EMOJI_FONT2" -f "$STATUSBAR_EMOJI_FONT3" -F "$COLOR_DEFAULT_FG" -B "$COLOR_DEFAULT_BG" | sh & + + +# This only really works for one monitor. +# wid=$(xdo id -m -a "$STATUSBAR_WM_NAME") +# xdo above -t "$(xdo id -N Bspwm -n root | sort | head -n 1)" "$wid" + +# Set the bar only on top of the 'root' window, which is bspwm itself. +# This, so you can fullscreen a program and it stays on top. +bspid="$(xdo id -N Bspwm -n root | sort | head -n 1)" +# The first part of the pipe is the "wid" +xdo id -m -a "$STATUSBAR_WM_NAME" | while read wid; do + xdo above -t "$bspid" "$wid" +done + +wait diff --git a/.local/bin/statusbar/lemonbar_panel_colors b/.local/bin/statusbar/lemonbar_panel_colors new file mode 100644 index 0000000..4597036 --- /dev/null +++ b/.local/bin/statusbar/lemonbar_panel_colors @@ -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" diff --git a/.local/bin/statusbar/lemonbar_panel_main b/.local/bin/statusbar/lemonbar_panel_main new file mode 100755 index 0000000..4b96cea --- /dev/null +++ b/.local/bin/statusbar/lemonbar_panel_main @@ -0,0 +1,112 @@ +#!/bin/sh + +. lemonbar_panel_colors + +while read -r line ; do + case $line in + C*) + clock="%{F$COLOR_SYS_FG}%{B$COLOR_SYS_BG} ${line#?} %{B-}%{F-}" + ;; + T*) + title="%{F$COLOR_TITLE_FG}%{B$COLOR_TITLE_BG} ${line#?} %{B-}%{F-}" + ;; + W*) + # bspwm's state + 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=0 + ;; + 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="%{S${on_focused_monitor}}${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}%{c}${title}%{r}${clock}" +done diff --git a/.local/bin/statusbar/panel b/.local/bin/statusbar/panel deleted file mode 100755 index c54338b..0000000 --- a/.local/bin/statusbar/panel +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -# General script that manages the panel/panel. - -STATUSBAR_FIFO=/tmp/panel-fifo -STATUSBAR_HEIGHT=20 -STATUSBAR_FONT="Noto Sans Mono:size=10" -STATUSBAR_EMOJI_FONT0="Noto Color Emoji" -STATUSBAR_EMOJI_FONT1="Font Awesome 5 Free" -STATUSBAR_EMOJI_FONT2="Font Awesome 5 Brands" -STATUSBAR_EMOJI_FONT3="Font Awesome 5 Free Solid" -STATUSBAR_WM_NAME=bspwm_panel -. panel_colors - - -if xdo id -a "$STATUSBAR_WM_NAME" > /dev/null ; then - printf "%s\n" "The status bar is already running. Try pkill -x panel." >&2 - exit 1 -fi - -trap 'trap - TERM; kill 0' INT TERM QUIT EXIT - - -# Create a new FIFO. (Pipe) -[ -e "$STATUSBAR_FIFO" ] && rm "$STATUSBAR_FIFO" -mkfifo "$STATUSBAR_FIFO" - - -# Here is where all the 'plugins' or 'blocks' for the panel -# are run. They're piped into the FIFO for later reading. -# In general you want them to print a letter at the beginning and then -# the actual stuff to show on scren, so you can distinguish between them on the actual bars. -xtitle -sf 'T%s\n' > "$STATUSBAR_FIFO" & -# date +"C%d/%m%y %r" > "$STATUSBAR_FIFO" & -bspc subscribe report > "$STATUSBAR_FIFO" & - - -# Here you can start N amount of bars and each one would be -# different if required. Piping into 'sh' is required for interaction -# with the bar. -panel_main < "$STATUSBAR_FIFO" | lemonbar -a 32 -u 2 -n "$STATUSBAR_WM_NAME" -g x$STATUSBAR_HEIGHT -f "$STATUSBAR_FONT" -f "$STATUSBAR_EMOJI_FONT0" -f "$STATUSBAR_EMOJI_FONT1" -f "$STATUSBAR_EMOJI_FONT2" -f "$STATUSBAR_EMOJI_FONT3" -F "$COLOR_DEFAULT_FG" -B "$COLOR_DEFAULT_BG" | sh & - - -# This only really works for one monitor. -# wid=$(xdo id -m -a "$STATUSBAR_WM_NAME") -# xdo above -t "$(xdo id -N Bspwm -n root | sort | head -n 1)" "$wid" - -# Set the bar only on top of the 'root' window, which is bspwm itself. -# This, so you can fullscreen a program and it stays on top. -bspid="$(xdo id -N Bspwm -n root | sort | head -n 1)" -# The first part of the pipe is the "wid" -xdo id -m -a "$STATUSBAR_WM_NAME" | while read wid; do - xdo above -t "$bspid" "$wid" -done - -wait diff --git a/.local/bin/statusbar/panel_colors b/.local/bin/statusbar/panel_colors deleted file mode 100644 index 4597036..0000000 --- a/.local/bin/statusbar/panel_colors +++ /dev/null @@ -1,24 +0,0 @@ -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" diff --git a/.local/bin/statusbar/panel_main b/.local/bin/statusbar/panel_main deleted file mode 100755 index 20fdbd5..0000000 --- a/.local/bin/statusbar/panel_main +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/sh - -. panel_colors - -while read -r line ; do - case $line in - C*) - clock="%{F$COLOR_SYS_FG}%{B$COLOR_SYS_BG} ${line#?} %{B-}%{F-}" - ;; - T*) - title="%{F$COLOR_TITLE_FG}%{B$COLOR_TITLE_BG} ${line#?} %{B-}%{F-}" - ;; - W*) - # bspwm's state - 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=0 - ;; - 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="%{S${on_focused_monitor}}${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}%{c}${title}%{r}${clock}" -done diff --git a/.local/bin/statusbar/polybar_panel b/.local/bin/statusbar/polybar_panel new file mode 100755 index 0000000..d3e198c --- /dev/null +++ b/.local/bin/statusbar/polybar_panel @@ -0,0 +1,21 @@ +#!/bin/sh + +# Terminate already running bar instances +killall -q polybar + +# Wait until the processes have been shut down +while pgrep -u "$(id -ru)" -x polybar >/dev/null; do sleep 1; done + +# Launch bar1 and bar2 +bar1=main +bar2=second +echo "---" | tee -a /tmp/$bar1.log /tmp/$bar2.log + +polybar $bar1 >>/tmp/$bar1.log 2>&1 & disown + +# externo=$(xrandr --query | grep "HDMI1") +# if [ ! "$externo" = "*disconnected*" ]; then +# MONITOR="HDMI1" polybar --reload $bar2 -c ~/.config/polybar/config >>/tmp/$bar2.log 2>&1 & +# fi + +echo "Bars launched..." -- cgit v1.2.3-54-g00ecf