From d78e893c344ea8ea32d864e9b437fcf2da931c92 Mon Sep 17 00:00:00 2001 From: Thomas Dehaeze Date: Thu, 4 Apr 2019 10:26:07 +0200 Subject: [PATCH] Add script to toggle polybar --- dotfiles/i3.org | 6 +++--- dotfiles/polybar.org | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/dotfiles/i3.org b/dotfiles/i3.org index c3b74bf..c06f28c 100644 --- a/dotfiles/i3.org +++ b/dotfiles/i3.org @@ -95,8 +95,8 @@ bindsym XF86LaunchB fullscreen toggle bindsym $mod+Ctrl+d exec --no-startup-id setxkbmap -layout us -variant intl -option caps:escape bindsym $mod+Shift+d exec --no-startup-id setxkbmap -layout us -option caps:escape # Toggle poylbar - bindsym $mod+t exec --no-startup-id ~/.config/polybar/bin/toggle.sh bottom - bindsym $mod+Shift+t exec --no-startup-id ~/.config/polybar/bin/toggle.sh top + bindsym $mod+t exec --no-startup-id ~/.config/polybar/scripts/toggle.sh bottom + bindsym $mod+Shift+t exec --no-startup-id ~/.config/polybar/scripts/toggle.sh top #+end_src * Vim Anywhere @@ -497,7 +497,7 @@ To display names or symbols instead of plain workspace numbers you can use somet exec --no-startup-id /usr/bin/emacs --fg-daemon # TODO - Start polybar - exec_always --no-startup-id $HOME/.config/polybar/bin/launch.sh + exec_always --no-startup-id $HOME/.config/polybar/scripts/launch.sh #+end_src * Start Foreground Applications diff --git a/dotfiles/polybar.org b/dotfiles/polybar.org index 8afee10..d7a1155 100644 --- a/dotfiles/polybar.org +++ b/dotfiles/polybar.org @@ -901,3 +901,41 @@ click-left = blurlock click-left = catt play click-right = catt pause #+END_SRC +* Scripts +** Launch + :PROPERTIES: + :header-args: :tangle ~/.config/polybar/scripts/launch.sh + :header-args+: :comments both :mkdirp yes + :header-args+: :shebang "#!/usr/bin/env bash" + :END: + +#+begin_src bash + # Terminate already running bar instances + killall -q polybar + + # Wait until the processes have been shut down + while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done + + # Launch Polybar, using default config location ~/.config/polybar/config + polybar top & + polybar bottom & + + echo "Polybar launched..." +#+end_src + +** Toggle + :PROPERTIES: + :header-args: :tangle ~/.config/polybar/scripts/toggle.sh + :header-args+: :comments both :mkdirp yes + :header-args+: :shebang "#!/usr/bin/env bash" + :END: + +#+begin_src bash + # Usage : toggle.sh top + + pid=$(pgrep -f "polybar $1") + + if [ ! -z "$pid" ]; then + polybar-msg -p $pid cmd toggle >/dev/null 2>&1 + fi +#+end_src