Advertisement
Guest User

i3-show-desktop

a guest
Oct 8th, 2018
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.67 KB | None | 0 0
  1. #!bin/bash
  2.  
  3. # This script opens a new workspace in the currently active monitor
  4. #
  5. # First gets a list of all of the active workspaces with i3-msg and jq
  6. #
  7. # Then, if there are other available workspaces, moves to one; the lowest number
  8. #
  9. # If all of the workspaces are full moves to workspace #11; whi
  10.  
  11. readarray -t activeWorkspaces < <(i3-msg -t get_workspaces | jq 'map(.num)' | tr -dc '[:alnum:]\n\r' | sort -g)
  12.  
  13. number=$(echo "${activeWorkspaces[@]}" | awk -v RS='\\s+' '{ a[$1] } END { for(i=1; i in a; ++i); print i }')
  14.  
  15. if [ $# -eq 0 ]
  16.         then
  17.                 i3-msg workspace $number
  18.         else
  19.                 i3-msg workspace $number; exec $1
  20. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement