OSDN Git Service

rework instantmonitor
authorpaperbenni <paperbenni@gmail.com>
Wed, 24 Jun 2020 21:31:47 +0000 (23:31 +0200)
committerpaperbenni <paperbenni@gmail.com>
Wed, 24 Jun 2020 21:31:47 +0000 (23:31 +0200)
autostart.sh
depend.sh
install.sh
installinstantos.sh
instantutils.sh
monitor.sh
repo.sh
rootinstall.sh

index db16c26..c65c09e 100755 (executable)
@@ -7,6 +7,7 @@
 # run userinstall to determine device properties
 if ! iconf -i userinstall; then
        /usr/share/instantutils/userinstall.sh
+       iconf -i userinstall 1
 fi
 
 # architecture detection
@@ -31,7 +32,7 @@ if ! iconf -i rangerplugins; then
        echo "installing ranger plugins"
        mkdir -p ~/.config/ranger/plugins
        cp -r /usr/share/rangerplugins/* ~/.config/ranger/plugins/
-
+       iconf -i rangerplugins 1
 fi
 
 # find out if it's a live session
@@ -40,15 +41,30 @@ if [ -e /usr/share/liveutils ] &>/dev/null; then
        echo "live session detected"
 fi
 
-# fix small graphical glitch on status bar startup
-NMON=$(iconf names | wc -l)
-for i in $(eval "echo {1..$NMON}"); do
-       echo "found monitor $i"
-       xdotool key super+comma
-       if iconf -i nobar; then
-               xdotool key super+b
+if iconf -i islaptop; then
+       export ISLAPTOP="true"
+       echo "laptop detected"
+else
+       echo "not a laptop"
+fi
+
+islive() {
+       if [ -n "$ISLIVE" ]; then
+               return 0
+       else
+               return 1
        fi
-done &
+}
+
+# optionally disable status bar
+if iconf -i nobar; then
+       NMON=$(iconf names | wc -l)
+       for i in $(eval "echo {1..$NMON}"); do
+               echo "found monitor $i"
+               xdotool key super+comma
+               xdotool key super+b
+       done &
+fi
 
 if [ -n "$ISRASPI" ]; then
        # enable double drawing for moving floating windows
@@ -63,13 +79,6 @@ if [ -n "$ISRASPI" ]; then
        fi
 fi
 
-if iconf -i islaptop; then
-       export ISLAPTOP="true"
-       echo "laptop detected"
-else
-       echo "not a laptop"
-fi
-
 if ! iconf -i notheming; then
        instantthemes a
        xrdb ~/.Xresources
@@ -106,10 +115,7 @@ onlinetrigger() {
 }
 
 # set up oh-my-zsh config if not existing already
-instantshell &
-if ! [ iconf -i userinstall ]; then
-       bash /usr/share/instantutils/userinstall.sh
-fi
+iconf -i nozsh || instantshell &
 
 # fix resolution on virtual machine
 if ! iconf -i novmfix && cat /proc/cpuinfo | grep -q hypervisor; then
@@ -149,7 +155,7 @@ Would you like to switch to a 1080p resolution?" | imenu -C; then
        fi
 fi
 
-if [ -z "$ISLIVE" ]; then
+if ! islive; then
        echo "not a live session"
        if [ -e /opt/instantos/installtrigger ]; then
                zenity --info --text "finishing installation in background" &
@@ -263,7 +269,7 @@ if iconf -b welcome; then
 fi &
 
 # prompt to fix configuration if installed from the AUR
-if ! iconf -i norootinstall && [ -z "$ISLIVE" ]; then
+if ! iconf -i norootinstall && ! islive; then
        if ! command -v imenu || ! command -v instantmenu; then
                notify-send "please install instantmenu and imenu"
        else
index 64fc5be..c32030f 100755 (executable)
--- a/depend.sh
+++ b/depend.sh
@@ -1,6 +1,7 @@
 #!/bin/bash
 
 # installs dependencies for instantOS
+# this is deprecated
 
 export LINK="https://raw.githubusercontent.com/instantos/instantos/master"
 
index 210c6a9..57eac8b 100755 (executable)
@@ -1,5 +1,7 @@
 #!/bin/bash
+
 # central installer script for instantOS
+# this is deprecated
 
 export PAPERSILENT="True"
 
@@ -35,5 +37,4 @@ echo "installing dependencies"
 echo "root: installing tools"
 /usr/share/instantutils/rootinstall.sh
 
-
 instantthemes f
index 534ea7e..9ad1910 100755 (executable)
@@ -1,2 +1,3 @@
 #!/bin/bash
+# wrapper for calamares
 sudo /usr/share/instantutils/install.sh
index 592c156..305b0f8 100644 (file)
@@ -1,4 +1,7 @@
 #!/bin/bash
+
+# wrapper script for other installation scripts
+
 USAGE="usage: instantutils install
 instantutils root
 instantutils user
index 9a19d75..3275289 100755 (executable)
@@ -1,7 +1,13 @@
 #!/bin/bash
 
+#####################################################
+# This script detects and saves screen resolutions ##
+# It resizes the wallpaper if things change        ##
+#####################################################
+
 command -v xrandr &>/dev/null ||
     (echo "please install xrandr" && exit 1)
+
 cd
 
 mkdir -p ~/instantos/monitor &>/dev/null
@@ -10,41 +16,45 @@ cd ~/instantos/monitor
 POSITIONS="$(xrandr | grep '[^s]connected' | grep -o '[0-9]*x[0-9]*+[0-9]*' | grep -o '[0-9]*$')"
 AMOUNT=$(wc -l <<<"$POSITIONS")
 
-# get monitor with highest resolution
 RESOLUTIONS=$(xrandr | grep '[^s]connected' | grep -Eo '[0-9]{1,}x[0-9]{1,}\+[0-9]{1,}\+[0-9]{1,}' |
     grep -o '[0-9]*x[0-9]*' | sed 's/ /\n/g')
 
-if OLDRES="$(iconf resolutions)"; then
+# check if resolutions are already configured
+# exit if no changes
+if iconf resolutions; then
+    OLDRES="$(iconf resolutions)"
     # see if resolution has changed
     if ! [ "$RESOLUTIONS" = "$OLDRES" ]; then
         iconf resolutions "$RESOLUTIONS"
         CHANGERES="True"
         echo "Resolution change detected"
+    else
+        echo "no resolution change"
+        [ "$1" = "-f" ] || exit
     fi
+else
+    iconf resolutions "$RESOLUTIONS"
 fi
 
 if [ $(echo "$RESOLUTIONS" | sort -u | wc -l) = "1" ]; then
     echo "resolutions identical"
-    iconf -i max $(head -1 <<<"$RESOLUTIONS")
+    iconf max $(head -1 <<<"$RESOLUTIONS")
 else
+    # get monitor with highest resolution
     let PIXELS1="$(head -1 <<<$RESOLUTIONS | grep -o '^[0-9]*') * $(head -1 <<<$RESOLUTIONS | grep -o '[0-9]*$')"
     let PIXELS2="$(tail -1 <<<$RESOLUTIONS | grep -o '^[0-9]*') * $(tail -1 <<<$RESOLUTIONS | grep -o '[0-9]*$')"
     if [ "$PIXELS1" -gt "$PIXELS2" ]; then
-        iconf -i max "$(head -1 <<<$RESOLUTIONS)"
+        iconf max "$(head -1 <<<$RESOLUTIONS)"
     else
-        iconf -i max "$(tail -1 <<<$RESOLUTIONS)"
+        iconf max "$(tail -1 <<<$RESOLUTIONS)"
     fi
 fi
 
 # rebuild wallpaper after resolution change
 changetrigger() {
-    if [ -z "$CHANGERES" ]; then
-        echo "no resolution change"
-    else
-        if [ -e ~/instantos/wallpapers ] && command -v instantwallpaper; then
-            rm -rf ~/instantos/wallpapers
-            instantwallpaper w
-        fi
+    if iconf -i setwallpaper; then
+        rm -rf ~/instantos/wallpapers
+        instantwallpaper resolution
     fi
 }
 
@@ -54,7 +64,7 @@ if [ "$AMOUNT" = "1" ]; then
     exit
 else
     if [ "$AMOUNT" -gt 2 ]; then
-        echo "only 2 monitors are supported"
+        echo "only 2 monitors are testes"
         exit
     fi
     echo "$AMOUNT monitors found"
@@ -65,11 +75,14 @@ iconf names "$(xrandr | grep '[^s]connected' | grep -o '^[^ ]*')"
 MONITOR1=$(head -1 <<<"$POSITIONS")
 MONITOR2=$(tail -1 <<<"$POSITIONS")
 
+# legacy leftover
+# in case some program ever needs it
 if [ "$MONITOR1" -gt "$MONITOR2" ]; then
     echo "Monitor 1 is ${MONITOR1}px on the right"
-    iconf -i right "$MONITOR2"
+    iconf right "$MONITOR2"
 else
     echo "Monitor 2 is ${MONITOR2}px on the right"
-    iconf -i right "$MONITOR2"
+    iconf right "$MONITOR2"
 fi
+
 changetrigger
diff --git a/repo.sh b/repo.sh
index 05317dd..5e8982c 100755 (executable)
--- a/repo.sh
+++ b/repo.sh
@@ -1,5 +1,9 @@
 #!/bin/bash
 
+###############################################################################
+## add repo containing instantOS programs and required prebuilt aur programs ##
+###############################################################################
+
 echo "adding instantOS repo"
 
 if ! uname -m | grep -q '^i'; then
index 585603f..45d39e4 100755 (executable)
@@ -1,8 +1,8 @@
 #!/bin/bash
 
-######################################################
-## installs all system wide programs for instantOS  ##
-######################################################
+####################################################
+## installs all system wide tweaks for instantOS  ##
+####################################################
 
 if ! [ $(whoami) = "root" ]; then
     echo "please run this as root"