From f5115d1b1eecadb2633cf7fd2a830ba91907225f Mon Sep 17 00:00:00 2001 From: speediegq Date: Mon, 3 Oct 2022 16:49:24 +0200 Subject: [PATCH] Add new MUCH faster reload function and use it instead when possible --- README.md | 2 +- docs/example.fsignal | 1 + fsignal.h | 1 + scripts/speedwm-swal | 8 ++++---- scripts/speedwm_run | 14 +++++++++++++- speedwm.c | 11 +++++++++++ 6 files changed, 31 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 69361ce..369c5a7 100644 --- a/README.md +++ b/README.md @@ -196,7 +196,7 @@ Please let me know if any keybinds are missing as these have been manually added - Music button | Open your defined music player - WLAN button | Disconnect from WLAN - -- Mouse -- + ### Mouse These binds can be activated using your mouse diff --git a/docs/example.fsignal b/docs/example.fsignal index 692158a..847c606 100644 --- a/docs/example.fsignal +++ b/docs/example.fsignal @@ -63,4 +63,5 @@ - 63 | Reset layout/mfact - 64 | Reset nmaster - 65 | Show/Hide systray + - 66 | Reload .Xresources on the fly diff --git a/fsignal.h b/fsignal.h index 0c95e21..1d7986c 100644 --- a/fsignal.h +++ b/fsignal.h @@ -51,6 +51,7 @@ static Signal signals[] = { { 63, reset_layout, {0} }, { 64, resetnmaster, {0} }, { 65, togglesystray, {0} }, + { 66, reloadcolors, {0} }, #if LAYOUT_TILE { 1, setlayout, {.v = &layouts[0]} }, /* Tiling layout */ diff --git a/scripts/speedwm-swal b/scripts/speedwm-swal index be957ea..5092328 100755 --- a/scripts/speedwm-swal +++ b/scripts/speedwm-swal @@ -315,11 +315,11 @@ SWAL_EXPORT_SCRIPT_WAL() rm -f $SWAL_EXPORTDIR/CurrentWallpaper ; ln -s "$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER" $SWAL_EXPORTDIR/CurrentWallpaper command -v wal > /dev/null && wal -nqi "$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER" - command -v speedwm_run > /dev/null && speedwm_run -loadconfig # For speedie.gq/speedwm - command -v speedwm_run > /dev/null && speedwm_run -rnoload # For speedie.gq/speedwm + #command -v speedwm_run > /dev/null && speedwm_run -loadconfig # uncomment if you're having issues with this + #command -v speedwm_run > /dev/null && speedwm_run -rnoload # uncomment if you're having issues with this + command -v speedwm_run > /dev/null && speedwm_run -rcolors - pgrep -x status && pkill -x status ; status & # For speedie.gq/speedwm - pgrep -x stellar && pkill -x stellar ; stellar & # For speedie.gq/stellar + pgrep -x speedwm_status > /dev/null && pkill speedwm_status ; speedwm_status & } # Send notification diff --git a/scripts/speedwm_run b/scripts/speedwm_run index 44e5100..15272b8 100755 --- a/scripts/speedwm_run +++ b/scripts/speedwm_run @@ -75,6 +75,17 @@ LOADSWAL() { fi } +# Load colors +LOADCOLS() { + if [ "$DONOTLOADCONFIG" = "true" ]; then + DONOTLOADCONFIG=true + else + xsetroot -name "fsignal:66" # reload colors + xsetroot -name "Loading" # hide the ugly fsignal + echo "Loaded colors" + fi +} + # Autostart AUTOSTART() { if [ -e "$HOME/.config/speedwm-de/autostart_once.sh" ]; then @@ -186,6 +197,7 @@ case "$ARGS" in "-s") ISSFLAG=true ; CHECKEXISTINGWM ; XRESOURCES ; AUTOSTART ; LOADSWAL ; LOADCONFIG ; RESET ; START_SPEEDWM ; exit 0 ;; "-configure") CONFIGURE ; exit 0 ;; "-r") XRESOURCES ; LOADSWAL ; LOADCONFIG ; RESET ; echo "Restarted speedwm." ; exit 0 ;; +"-rcolors") XRESOURCES ; LOADCONFIG ; LOADCOLS ; echo "Restarted speedwm." ; exit 0 ;; "-rnoload") RESET ; echo "Restarted speedwm." ; exit 0 ;; "-h") HELP ; exit 0 ;; "-f") CARG="force" ; XRESOURCES ; AUTOSTART ; LOADSWAL ; LOADCONFIG ; RESET ; START_SPEEDWM ; exit 0 ;; @@ -193,7 +205,7 @@ case "$ARGS" in "-unloadconfig") UNLOADCONFIG ; RESET ; exit 0 ;; "-deleteconfig") DELETECONFIG ; RESET ; exit 0 ;; "-noxrdb") START_SPEEDWM ; exit 0 ;; -"-stop") pgrep -x speedwm && pkill -x speedwm ; echo "speedwm has been stopped." ; exit 0 +"-stop") pgrep -x speedwm && pkill -x speedwm && echo "speedwm has been stopped." ; exit echo "speedwm is not running, cannot stop it." ; exit 1 ;; "-nomkconfig") CHECKEXISTINGWM ; XRESOURCES ; AUTOSTART ; LOADSWAL ; RESET ; START_SPEEDWM ; exit 0 ;; esac diff --git a/speedwm.c b/speedwm.c index 6778672..f5574bd 100644 --- a/speedwm.c +++ b/speedwm.c @@ -562,6 +562,7 @@ static int xerrorstart(Display *dpy, XErrorEvent *ee); static void xinitvisual(); static void zoom(const Arg *arg); static void load_xresources(void); +static void reloadcolors(const Arg *arg); static void resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst); static pid_t getparentprocess(pid_t p); static int isdescprocess(pid_t p, pid_t c); @@ -4584,6 +4585,16 @@ showtagpreview(unsigned int i) } #endif +void +reloadcolors(const Arg *arg) +{ + // reload colors + load_xresources(); + setup(); + focus(NULL); + arrange(NULL); +} + void sigchld(int unused) {