switch-layout 651 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/zsh -f
  2. if [[ $# -eq 0 ]] ; then
  3. echo "switch-layout [ name | list | define ]"
  4. exit
  5. fi
  6. LAYOUT=$1
  7. case ${LAYOUT} in
  8. define)
  9. arandr
  10. ;;
  11. list)
  12. for layout in ~/.screenlayout/*.sh ;
  13. do
  14. echo " - $(basename -- ${layout} .sh)"
  15. done
  16. ;;
  17. *)
  18. if [[ -e ~/.screenlayout/${LAYOUT}.sh ]] ; then
  19. sh ~/.screenlayout/${LAYOUT}.sh
  20. [[ -e ~/.screenlayout/${LAYOUT}.sh-after ]] && \
  21. sh ~/.screenlayout/${LAYOUT}.sh-after
  22. echo Switched to ${LAYOUT} layout
  23. else
  24. echo "${LAYOUT} not available"
  25. fi
  26. esac