Add script to toggle polybar

This commit is contained in:
Thomas Dehaeze 2019-04-04 10:26:07 +02:00
parent 50fcefa58b
commit d78e893c34
2 changed files with 41 additions and 3 deletions

View File

@ -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

View File

@ -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