i3-layout 999 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/zsh -f
  2. if [[ $# -eq 0 ]] ; then
  3. echo "i3-layout [ name workspace | list | define workspace name | edit name ]"
  4. exit
  5. fi
  6. LAYOUT=$1
  7. WORKSPACE=$2
  8. case ${LAYOUT} in
  9. define)
  10. NAME=$3
  11. i3-save-tree --workspace ${WORKSPACE} > ~/.config/i3/layouts/${NAME}.json
  12. emacsclient --alternate-editor="" -n ~/.config/i3/layouts/${NAME}.json
  13. ;;
  14. edit)
  15. NAME=$3
  16. emacsclient --alternate-editor="" -n ~/.config/i3/layouts/${NAME}.json
  17. ;;
  18. list)
  19. for layout in ~/.config/i3/layouts/*.json ;
  20. do
  21. echo " - $(basename -- ${layout} .json)"
  22. done
  23. ;;
  24. *)
  25. if [[ -e ~/.config/i3/layouts/${LAYOUT}.json ]] ; then
  26. i3-msg "workspace ${WORKSPACE}; append_layout ~/.config/i3/layouts/${LAYOUT}.json"
  27. [[ -e ~/.config/i3/layouts/${LAYOUT}.after ]] && sh ~/.config/i3/layouts/${LAYOUT}.after
  28. else
  29. i3-nagbar -m "${LAYOUT} not available" -t error
  30. fi
  31. esac