Explorar el Código

feat(surfingkeys): expose settings via local server

Firefox extensions can't read from files, so to keep settings
automatically in sync, the file must be made readable via HTTP. This is
accomplished by launching python's default HTTP server module when
Firefox is launched.
Joe hace 1 año
padre
commit
0e2c199369
Se han modificado 2 ficheros con 27 adiciones y 16 borrados
  1. 21 16
      .config/surfingkeys/compile.sh
  2. 6 0
      .config/zsh/.zshenv

+ 21 - 16
.config/surfingkeys/compile.sh

@@ -6,21 +6,26 @@
 # `yabairc` for details. This often causes the process to fire twice, so the
 # program requires a lock. Detailed compilation logs are also kept.
 ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
+SURFINGKEYS_SETTINGS_SERVER_RUN_DIR=$XDG_CONFIG_HOME/surfingkeys/run/ &&
+mkdir -p $SURFINGKEYS_SETTINGS_SERVER_RUN_DIR &&
+nohup python3 -m http.server -d $SURFINGKEYS_SETTINGS_SERVER_RUN_DIR $SURFINGKEYS_SETTINGS_SERVER_PORT >&/dev/null &
+
 cd $XDG_CONFIG_HOME/surfingkeys/ &&
-	if mkdir compile.lock 2>/dev/null; then
-		echo "=== === === === === === === === === === ===" | tee -a compile.log
-		echo "                  STARTED                  " | tee -a compile.log
-		echo "=== === === === === === === === === === ===" | tee -a compile.log
-		echo "$(date 2>&1): Compiling" | tee -a compile.log
-		if [ ! -f package-lock.json ]; then
-		    echo "\t$(npm install 2>&1)" | tee -a compile.log
-		fi
-		echo "\t$(npm run build 2>&1)" | tee -a compile.log
-		rm -rf compile.lock
-		echo "=== === === === === === === === === === ===" | tee -a compile.log
-		echo "                  FINISHED                 " | tee -a compile.log
-		echo "=== === === === === === === === === === ===" | tee -a compile.log
-		echo "" | tee -a compile.log
-		tail -c 5M compile.log | tee compile.log.temp
+    if mkdir compile.lock 2>/dev/null; then
+        echo "=== === === === === === === === === === ===" | tee -a compile.log
+        echo "                  STARTED                  " | tee -a compile.log
+        echo "=== === === === === === === === === === ===" | tee -a compile.log
+        echo "$(date 2>&1): Compiling" | tee -a compile.log
+        if [ ! -f package-lock.json ]; then
+            echo "\t$(npm install 2>&1)" | tee -a compile.log
+        fi
+        echo "\t$(npm run build 2>&1)" | tee -a compile.log
+        rm -rf compile.lock
+        mv index.js run | tee -a compile.log
+        echo "=== === === === === === === === === === ===" | tee -a compile.log
+        echo "                  FINISHED                 " | tee -a compile.log
+        echo "=== === === === === === === === === === ===" | tee -a compile.log
+        echo "" | tee -a compile.log
+        tail -c 5M compile.log | tee compile.log.temp
         mv compile.log.temp compile.log
-	fi
+    fi

+ 6 - 0
.config/zsh/.zshenv

@@ -34,6 +34,12 @@ if [ -f $LIGHTMODE_TOGGLE_FLAG_FILE ]; then
     export JONATHANDARKER_COLOR_FA="$JONATHANDARKER_COLOR_08"
 fi
 
+################################################################################
+# Ports
+################################################################################
+
+export SURFINGKEYS_SETTINGS_SERVER_PORT="21212"
+
 ################################################################################
 # Aliases
 ################################################################################