OSDN Git Service

formatting and commenting
authorpaperbenni <paperbenni@gmail.com>
Thu, 26 Dec 2019 13:33:37 +0000 (14:33 +0100)
committerpaperbenni <paperbenni@gmail.com>
Thu, 26 Dec 2019 13:33:37 +0000 (14:33 +0100)
autostart.sh
dotinstall.sh
programs/dswitch
themes/arc.sh
themes/dracula.sh
themes/mac.sh

index 4c10ebc..2ebf38a 100755 (executable)
@@ -45,7 +45,7 @@ INTERNET="X"
 
 REPETITIONS="xxxxxx"
 
-conky &
+command -v conky &>/dev/null && conky &
 
 # status bar loop
 while :; do
@@ -67,6 +67,7 @@ while :; do
 
                REPETITIONS="x"
        else
+               # increase counter
                REPETITIONS="$REPETITIONS"x
        fi
 
index 279d43a..1c938e4 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/bash
 echo "installing dotfiles"
-curl https://raw.githubusercontent.com/paperbenni/dotfiles/master/install.sh | bash
+curl -s https://raw.githubusercontent.com/paperbenni/dotfiles/master/install.sh | bash
 echo "installing suckless tools"
-curl https://raw.githubusercontent.com/paperbenni/suckless/master/install.sh | bash
+curl -s https://raw.githubusercontent.com/paperbenni/suckless/master/install.sh | bash
index 415486d..5121a6f 100755 (executable)
@@ -2,15 +2,19 @@
 
 ##############################################
 ## dwm popup to choose between open windows ##
-## does not change to respective monitor    ##
+## finally supports multi monitor           ##
 ##############################################
 
-if ! [ -n "$1" ]; then
+#############################################################
+## heavily commented, this was a nightmare to write        ##
+## look at the git history of this file before touching it ##
+#############################################################
 
+# alt tab like behaviour with rofi
+if ! [ -n "$1" ]; then
     num=$(wmctrl -l | sed 's/  / /' | cut -d " " -f 4- | nl -w 3 -n rn | sed -r 's/^([ 0-9]+)[ \t]*(.*)$/\1 - \2/' |
         rofi -dmenu -i -me-select-entry '' -me-accept-entry 'MousePrimary' -kb-row-down 'Alt+Tab,Down' -kb-row-up 'Alt+Ctrl+Tab,Up' -kb-accept-entry '!Alt_L,!Alt+Tab,Return' | cut -d '-' -f -1)
     [[ -z "$num" ]] && exit
-
     WID=$(wmctrl -l | sed -n "$num p" | cut -c -10)
 else
     WID="$1"
@@ -18,10 +22,26 @@ fi
 
 echo "focus target $WID"
 
+# focus $1, weird behaviour with multi monitor, see rest of the file
+focuswin() {
+    [[ $1 =~ "," ]] && echo "error focussing" && return 1
+    wmctrl -i -a "$1"
+}
+
+# single monitor like on a laptop is pretty straightforward
+if ! [ -e ~/paperbenni/ismultimonitor ]; then
+    focuswin "$WID"
+    echo "exiting"
+    exit
+fi
+
+# convert decimal to hexadecimal
 hex() {
     echo "0x0$(printf '%x\n' $1)"
 }
 
+# wmutils pfw sometimes returns one digit higher than xdotool
+# but xdotool behaves weird with the root window in focus
 pfw() {
     if command pfw | grep -q '0x000001e1'; then
         echo "0x000001e1"
@@ -31,17 +51,8 @@ pfw() {
     fi
 }
 
-focuswin() {
-    [[ $1 =~ "," ]] && echo "error focussing" && return 1
-    wmctrl -i -a "$1"
-}
-
-if ! [ -e ~/paperbenni/ismultimonitor ]; then
-    focuswin "$WID"
-    echo "exiting"
-    exit
-fi
-
+# warp mouse cursor to current window and get the monitor from the coordinates.
+# more reliable than using window positions because of the root window always returning 0
 getmonitor() {
     xdotool key 'super+W'
     XPOS=$(xdotool getmouselocation --shell | head -1 | grep -o '[0-9]*')
@@ -52,6 +63,7 @@ getmonitor() {
     fi
 }
 
+# sometimes there are trailing zeros, this only compares everything after these
 wincomp() {
     NEW=$(echo "$1" | sed 's/^0x0*//g')
     COMP=$(echo "$2" | sed 's/^0x0*//g')
@@ -63,6 +75,7 @@ wincomp() {
     fi
 }
 
+# already on focused window?
 wincomp "$WID" "$(pfw)" && exit
 
 OLD="$(pfw)"
@@ -70,8 +83,10 @@ OLDM="$(getmonitor)"
 
 focuswin "$WID"
 
+# solution for multi monitor glitches
 if ! wincomp "$(pfw)" "$WID"; then
     if ! [ "$OLDM" = "$(getmonitor)" ]; then
+        # do not attempt to focuswin the root window!!
         if ! [ "$OLD" = "0x000001e1" ]; then
             xdotool key 'super+comma'
             focuswin "$OLD"
index 76da3da..f06a623 100755 (executable)
@@ -28,9 +28,10 @@ gtkicons Papirus
 setcursor elementary
 
 # rofi setup
-mkdir -p ~/.config/rofi &> /dev/null
-curl -s "https://raw.githubusercontent.com/paperbenni/dotfiles/master/rofi/arc.rasi" >~/.config/rofi/arc.rasi
-echo 'rofi.theme: ~/.config/rofi/arc.rasi' > ~/.config/rofi/config
+mkdir -p ~/.config/rofi &>/dev/null
+[ -e ~/.config/rofi/arc.rasi ] ||
+    curl -s "https://raw.githubusercontent.com/paperbenni/dotfiles/master/rofi/arc.rasi" >~/.config/rofi/arc.rasi
+echo 'rofi.theme: ~/.config/rofi/arc.rasi' >~/.config/rofi/config
 
 curl -s "https://raw.githubusercontent.com/paperbenni/dotfiles/master/fonts/sourcecodepro.sh" | bash
 curl -s "https://raw.githubusercontent.com/paperbenni/dotfiles/master/fonts/roboto.sh" | bash
index 59f4672..10aa39f 100755 (executable)
@@ -22,9 +22,10 @@ gtkfont "Roboto 10"
 setcursor paper
 
 # rofi setup
-mkdir -p ~/.config/rofi &> /dev/null
-curl -s "https://raw.githubusercontent.com/paperbenni/dotfiles/master/rofi/dracula.rasi" >~/.config/rofi/dracula.rasi
-echo 'rofi.theme: ~/.config/rofi/dracula.rasi' > ~/.config/rofi/config
+mkdir -p ~/.config/rofi &>/dev/null
+[ -e ~/.config/rofi/dracula.rasi ] ||
+    curl -s "https://raw.githubusercontent.com/paperbenni/dotfiles/master/rofi/dracula.rasi" >~/.config/rofi/dracula.rasi
+echo 'rofi.theme: ~/.config/rofi/dracula.rasi' >~/.config/rofi/config
 
 curl -s "https://raw.githubusercontent.com/paperbenni/dotfiles/master/fonts/monaco.sh" | bash
 curl -s "https://raw.githubusercontent.com/paperbenni/dotfiles/master/fonts/roboto.sh" | bash
index e4c5449..e779d71 100755 (executable)
@@ -32,9 +32,10 @@ setcursor osx
 curl -s "https://raw.githubusercontent.com/paperbenni/dotfiles/master/fonts/sfpro.sh" | bash
 
 # rofi setup
-mkdir -p ~/.config/rofi &> /dev/null
-curl -s "https://raw.githubusercontent.com/paperbenni/dotfiles/master/rofi/mac.rasi" >~/.config/rofi/mac.rasi
-echo 'rofi.theme: ~/.config/rofi/mac.rasi' > ~/.config/rofi/config
+mkdir -p ~/.config/rofi &>/dev/null
+[ -e ~/.config/rofi/mac.rasi ] ||
+    curl -s "https://raw.githubusercontent.com/paperbenni/dotfiles/master/rofi/mac.rasi" >~/.config/rofi/mac.rasi
+echo 'rofi.theme: ~/.config/rofi/mac.rasi' >~/.config/rofi/config
 
 gtkfont 'SF Pro Display 10'
 gtkdocumentfont 'SF Pro Text 10'