OSDN Git Service

default settings for instantdisper
authorpaperbenni <paperbenni@gmail.com>
Sun, 2 Aug 2020 15:32:05 +0000 (17:32 +0200)
committerpaperbenni <paperbenni@gmail.com>
Sun, 2 Aug 2020 15:32:05 +0000 (17:32 +0200)
autostart.sh
programs/instantdisper
status.sh

index eeb0182..a9c8a77 100755 (executable)
@@ -310,6 +310,12 @@ if ! (iconf -i noautoswitch && iconf -i islaptop) || iconf -i autoswitch; then
                while :; do
                        NEWDISPLAYCOUNT="$(xrandr | grep -c '[^s]connected')"
                        if ! [ "$DISPLAYCOUNT" = "$NEWDISPLAYCOUNT" ]; then
+                               if [ "$NEWDISPLAYCOUNT" -gt 1 ]; then
+                                       instantdisper
+                                       echo "multi monitor setup"
+                               else
+                                       disper -e
+                               fi
                                echo "displays changed"
                                notify-send "display changed"
                                DISPLAYCOUNT="$NEWDISPLAYCOUNT"
@@ -322,7 +328,7 @@ if ! (iconf -i noautoswitch && iconf -i islaptop) || iconf -i autoswitch; then
        fi
 fi
 
-# welcome greeter app
+# welcome app
 if iconf -b welcome; then
        instantwelcome
 fi &
index 48bec94..f09f281 100755 (executable)
@@ -15,14 +15,66 @@ mainmenu() {
 
 defaultmenu() {
     echo '>>h Default projection settings
-           Extend
-           PC screen only
-           Second screen only
-               Duplicate
+             Extend
+             PC screen only
+             Second screen only
+                Duplicate
+:b Ask
 :r None
 :b Back' | instantmenu -l 20 -h -1 -w 400 -c -w -1 -bw 4 -q search
 }
 
+setdefault() {
+    DEFAULTLOOPING="true"
+    while [ -n "$DEFAULTLOOPING" ]; do
+        DEFAULTCHOICE="$(defaultmenu)"
+
+        if [ -z "$DEFAULTCHOICE" ]; then
+            continue
+        else
+            unset DEFAULTLOOPING
+        fi
+
+        case "$DEFAULTCHOICE" in
+        "*Second screen only")
+            iconf automon S
+            ;;
+        *Extend)
+            iconf automon e
+            ;;
+        "*PC screen only")
+            iconf automon s
+            ;;
+        *Duplicate)
+            iconf automon c
+            ;;
+        *None)
+            iconf automon n
+            ;;
+        *Ask)
+            iconf -d automon
+            ;;
+        *) # Back
+            instantdisper &
+            exit
+            ;;
+        esac
+    done
+}
+
+# apply saved setting
+applydefault() {
+    if ! iconf automon; then
+        echo "error applying default monitor setting"
+    fi
+    AUTOMON="$(iconf automon)"
+    if grep '^[esSc]$' <<<"$AUTOMON"; then
+        disper -"$AUTOMON"
+    else
+        echo "none"
+    fi
+}
+
 LOOPING="true"
 while [ -n "$LOOPING" ]; do
     CHOICE="$(mainmenu)"
@@ -41,6 +93,8 @@ while [ -n "$LOOPING" ]; do
         ;;
     *action)
         echo "setting default action"
+        setdefault
+        applydefault
         ;;
     esac
     unset LOOPING
index b746190..2d8a5ec 100755 (executable)
--- a/status.sh
+++ b/status.sh
@@ -4,6 +4,8 @@
 ## status monitor for instantWM ##
 ##################################
 
+# will be rewritten soon
+
 INTERNET="X"
 date=""