poetician

launch.sh | Polybar dual screen top bar on both, bottom on secondary

Nov 18th, 2020
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # terminate already running bar instances
  4. killall -q polybar
  5.  
  6. # wait until the processes have been shut down
  7. while pgrep -u $UID -x polybar >/dev/null 2>&1; do sleep 1; done
  8.  
  9. # gather the list of monitors into an array
  10. mapfile -t MONITORS < <( polybar --list-monitors | cut -f 1 -d : )
  11.  
  12. # iterate through the array indexes
  13. for MON_IDX in "${!MONITORS[@]}"; do
  14. # launch the first bar at every monitor
  15. MONITOR="${MONITORS[$MON_IDX]}" polybar mainbar-i3 &
  16. # but launch the second one if only on the first one
  17. if [[ $MON_IDX -eq 0 ]]; then
  18. MONITOR="${MONITORS[$MON_IDX]}" polybar mainbar-i3-extra &
  19. fi
  20. # and we're done
  21. done
Advertisement
Add Comment
Please, Sign In to add comment