소스 검색

Made a bit cleaner with a case

Samuel W. Flint 9 년 전
부모
커밋
e67e4595e3
1개의 변경된 파일18개의 추가작업 그리고 18개의 파일을 삭제
  1. 18 18
      switch-layout

+ 18 - 18
switch-layout

@@ -7,21 +7,21 @@ fi
 
 LAYOUT=$1
 
-if [[ ${LAYOUT} == "define" ]] ; then
-    arandr
-    exit
-fi
-
-if [[ ${LAYOUT} == "list" ]] ; then
-    for lout in ~/.screenlayout/*.sh ;
-    do
-        echo `basename -- "${lout}" .sh`
-    done
-    exit
-fi
-
-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
-fi
+case ${LAYOUT} in
+    define)
+        arandr
+        ;;
+    list)
+        for layout in ~/.screenlayout/*.sh ;
+        do
+            echo " - $(basename -- ${layout} .sh)"
+        done
+        ;;
+    *)
+        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
+        fi
+esac