From 8be1b224f9974260d151dc2a4a4ebbd1882b0ea8 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 2 Dec 2019 20:58:36 +0100 Subject: [PATCH] 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` --- .config/i3/config | 2 +- .config/polybar/config | 2 +- .local/bin/polybar-launch | 14 +++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.config/i3/config b/.config/i3/config index d36c4c2..a5dcf9a 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -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 diff --git a/.config/polybar/config b/.config/polybar/config index 115dc30..51250f0 100644 --- a/.config/polybar/config +++ b/.config/polybar/config @@ -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 diff --git a/.local/bin/polybar-launch b/.local/bin/polybar-launch index e8d298b..c718d8c 100755 --- a/.local/bin/polybar-launch +++ b/.local/bin/polybar-launch @@ -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..."