Add bar argument to polybar launch script

Can launch multiple polybars (defined in polybar/config file) by passing
them to the command, e.g. `polybar-launch my-bar1 my-bar2`
This commit is contained in:
Marty Oehme 2019-12-02 20:58:36 +01:00
parent f3460e6ff1
commit 8be1b224f9
3 changed files with 11 additions and 7 deletions

View file

@ -201,7 +201,7 @@ bindsym $mod+Shift+r restart
exec_always --no-startup-id feh --bg-scale ~/pictures/wall.jpg
# launch polybar (script ensures only 1 instance existing at a time)
exec_always --no-startup-id polybar-launch
exec_always --no-startup-id polybar-launch simple-top
# default workspaces for most used apps
# assign [class="^qutebrowser$"] → number 1

View file

@ -45,7 +45,7 @@ throttle-input-for = 30
margin-top = 0
margin-bottom = 0
[bar/mine]
[bar/simple-top]
; Put the bar at the bottom of the screen
bottom=false

View file

@ -6,9 +6,13 @@ killall -q polybar
# Wait until the processes have been shut down
while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done
# Launch bar1 and bar2
echo "---" | tee -a /tmp/polybar1.log /tmp/polybar2.log
polybar mine >>/tmp/polybar1.log 2>&1 &
# polybar bar2 >>/tmp/polybar2.log 2>&1 &
startbars() {
for bar in "$@"; do
local logfile="/tmp/polybar-$bar.log"
printf -- "---\npolybar: %s starting...\n---\n" "$bar" | tee -a "$logfile"
polybar "$bar" >>"$logfile" 2>&1 &
done
}
echo "Polybar launched..."
startbars "$@"
echo "Polybars launched..."