| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 | #!/bin/zsh -fif [[ $# -eq 0 ]] ; then    echo "switch-layout [ name | list | dmenu | define ]"    exitfiLAYOUT=$1function list-layouts () {    for layout in ~/.screenlayout/*.sh ;    do        echo "$(basename -- ${layout} .sh)"    done}function apply-layout () {    if [[ -e ~/.screenlayout/${LAYOUT}.sh ]] ; then        sh ~/.screenlayout/${LAYOUT}.sh        [[ -e ~/.screenlayout/${LAYOUT}.sh-after ]] && \            sh ~/.screenlayout/${LAYOUT}.sh-after        echo Switched to ${LAYOUT} layout    else        echo "${LAYOUT} not available"    fi}function with-external-completion () {    if [[ -e `which rofi` ]] ; then        LAYOUT=`echo define | list-layouts | rofi -dmenu -p layout:`        [[ $LAYOUT != "" ]] && apply-layout    else        LAYOUT=`echo define | list-layouts | dmenu -p layout:`        [[ $LAYOUT != "" ]] && apply-layout    fi}case ${LAYOUT} in    define)        arandr        ;;    list)        list-layouts        ;;    dmenu)        with-external-completion        ;;    *)        apply-layoutesac
 |