From 7380b60dfb29f0c1ac5fc3487e450bba6424b2bc Mon Sep 17 00:00:00 2001 From: speediegq Date: Sat, 15 Oct 2022 02:22:19 +0200 Subject: [PATCH] No more xsetroot dependency, we can now set the status using speedwm -s directly --- docs/dependencies | 1 - docs/doc-05 | 1 - docs/doc-06 | 2 +- docs/doc-07 | 3 +-- scripts/speedwm-compatcheck | 8 ------ scripts/speedwm-swal | 20 +------------- scripts/speedwm-utils | 54 ++++++++++++++++++------------------- scripts/speedwm-winnav | 2 +- scripts/speedwm_run | 10 +++---- speedwm.c | 9 +++++-- status | 2 +- 11 files changed, 44 insertions(+), 68 deletions(-) diff --git a/docs/dependencies b/docs/dependencies index 6a224ed..549961d 100644 --- a/docs/dependencies +++ b/docs/dependencies @@ -25,7 +25,6 @@ - xrdb (Install if you want .Xresources support) - pywal (Install if you want pywal support. Requires swal aka the default way to set wallpapers) - wmctrl (Needed for proper window management) - - xsetroot (Needed for most scripts including Pywal support) - slock (Required for screen locking) - If you want to display a message, you need the text patch. - If you have the background image patch, you can set the image to ~/.config/speedwm-de/swal/CurrentWallpaper. It is a symlink to the current wallpaper. diff --git a/docs/doc-05 b/docs/doc-05 index e7ef386..e15c1f0 100644 --- a/docs/doc-05 +++ b/docs/doc-05 @@ -23,7 +23,6 @@ It can be found in the speedwm source code directory. It is just a shell script You can edit the status bar simply by editing 'status' and running 'make clean install'. You can also configure it by editing '~/.config/speedwm-de/status/config'. -Please note that most status bars including the built in 'status' depends on xsetroot which must be installed. speedwm-compatcheck is going to tell you about this when compiling. If you want to change status bar, edit options.h and set 'static char status' to your status bar binary (must be in $PATH). Alternatively, you can also set "speedwm.status: " in .Xresources (See .Xresources and Pywal). diff --git a/docs/doc-06 b/docs/doc-06 index 71af69f..047c529 100644 --- a/docs/doc-06 +++ b/docs/doc-06 @@ -3,7 +3,7 @@ This fork of speedwm has .Xresources support thanks to the .Xresources patch. It Colors can be reloaded on-the-fly using the built in wallpaper utility. In order to implement speedwm reloading support to your own wallpaper utility, run shell command (/bin/sh) 'speedwm_run -r' to reload colors automatically. -Note that the 'xrdb' dependency is required for both pywal and .Xresources support and 'xsetroot' is required for automatic reloading of colors, the built in status bar, and more so you should install this. +Note that the 'xrdb' dependency is required for both pywal and .Xresources support. Below is a list of all .Xresources values you can define. The .Xresources file should be placed in ~ or ~/.config by the user. If it is not or you want it somewhere else, you can edit 'autostart.h' and 'make clean install'. diff --git a/docs/doc-07 b/docs/doc-07 index d626ccf..007e598 100644 --- a/docs/doc-07 +++ b/docs/doc-07 @@ -2,8 +2,7 @@ Thanks to the 'fsignal' patch available on suckless.org's website, we can easily write shell scripts to interact with dwm and therefore speedwm. I made some changes to this patch, because it has some.. questionable behaviour in my opinion. -In order to use 'fsignal', your system must have 'xsetroot' installed. -Then simply use the dwm-utils script. Syntax is dwm-utils -exec +To use signals, simply use the speedwm-utils script. Syntax is speedwm-utils -exec Below is a list of all signums and what they do. diff --git a/scripts/speedwm-compatcheck b/scripts/speedwm-compatcheck index 2061b2b..6e4abfe 100755 --- a/scripts/speedwm-compatcheck +++ b/scripts/speedwm-compatcheck @@ -18,13 +18,6 @@ else printf "Warning: ${BINDIR}wmctrl was not found\n" fi -# Check if xsetroot exists -if [ -e "${BINDIR}xsetroot" ]; then - xsetroot_exists=true -else - printf "Warning: ${BINDIR}xsetroot was not found\n" -fi - # Check if xwallpaper exists if [ -e "${BINDIR}xwallpaper" ]; then xwallpaper_exists=true @@ -44,4 +37,3 @@ command -v dmenu > /dev/null || printf "\nWARNING: dmenu was not found. This mea # Check if slock exists command -v slock > /dev/null || printf "\nWARNING: slock was not found. This means the shutdown menu can't lock your screen." -result="$(echo "$xrdb_exists$wmctrl_exists$xsetroot_exists$xwallpaper_exists$xmodmap_exists")" diff --git a/scripts/speedwm-swal b/scripts/speedwm-swal index 6846b30..385e368 100755 --- a/scripts/speedwm-swal +++ b/scripts/speedwm-swal @@ -100,23 +100,6 @@ SWAL_MKCONFIG() { printf "\nSWAL_RANDOMIZE=$SWAL_RANDOMIZE" >> $SWAL_EXPORTDIR/config } -# use a solid color -SWAL_SOLIDCOLOR() { - ISCOL="$(printf "#000000\n#bbbbbb" | $RUNLAUNCHER -l 2 $GRIDARG $GRIDNUM -p "Enter a hex color:")" - - echo $ISCOL | grep -q "#" || exit 1 - - xwallpaper --clear - xsetroot -solid "$ISCOL" - rm -f $SWAL_EXPORTDIR/swal_wm - xrdb -remove - xsetroot -name "#cmd:65" - printf "#!/bin/sh\nxsetroot -solid "$ISCOL"" > $SWAL_EXPORTDIR/swal_wm - command -v notify-send > /dev/null && notify-send " Solid color $ISCOL set as wallpaper." - - exit 0 -} - # Binary directory BINDIR="$(dirname $(command -v status))/" SWAL_OLDWALLPAPERDIR=$SWAL_WALLPAPERDIR @@ -162,7 +145,7 @@ SWAL_USAGE() { SWAL_SELWALLPAPER() { if [ "$ARG1" = "" ]; then - SWAL_SELWALLPAPER="$(printf "$(ls "$SWAL_WALLPAPERDIR")\n------\n..\nPreview\nPrevious\nSolid Color\nRandom\nFavorites\nAdd used wallpaper to favorites\nOptions\nHelp\nExit" | $RUNLAUNCHER $GRIDARG $GRIDNUM -l 100 -p "What wallpaper would you like to set?")" + SWAL_SELWALLPAPER="$(printf "$(ls "$SWAL_WALLPAPERDIR")\n------\n..\nPreview\nPrevious\nRandom\nFavorites\nAdd used wallpaper to favorites\nOptions\nHelp\nExit" | $RUNLAUNCHER $GRIDARG $GRIDNUM -l 100 -p "What wallpaper would you like to set?")" fi } @@ -184,7 +167,6 @@ SWAL_SETTYPE() "Random") SWAL_FULL="$(find $SWAL_WALLPAPERDIR/* -type f | shuf -n 1)" ; SWAL_WALLPAPERDIR="$(dirname "$SWAL_FULL")" ; SWAL_SELWALLPAPER="$(basename "$SWAL_FULL")" ; SWAL_SELWAL=$SWAL_SELWALLPAPER ;; "Previous") SWAL_PREVWAL=$(readlink $SWAL_EXPORTDIR/CurrentWallpaper_prev) ; SWAL_WALLPAPERDIR="$(dirname "$SWAL_PREVWAL")" ; SWAL_SELWALLPAPER="$(basename "$SWAL_PREVWAL")" ;; "Exit") exit 0 ;; - "Solid Color") SWAL_SOLIDCOLOR ;; "Help") SWAL_USAGE | $RUNLAUNCHER $GRIDARG $GRIDNUM -l 50 -p "How to use" && $0 && exit 0 ;; "------") $0 && exit 0 ;; esac diff --git a/scripts/speedwm-utils b/scripts/speedwm-utils index f7b9005..2ae1c7f 100755 --- a/scripts/speedwm-utils +++ b/scripts/speedwm-utils @@ -32,13 +32,13 @@ VARS GENERAL() { GENERALOPTS=$(printf "mfact +\nmfact -\nToggle Sticky\nToggle Bar\nToggle Fullscreen\nReset Layout/mfact\nReorganize Tags" | $RUNLAUNCHER -l 20 -p 'What do you want to do?') case "$GENERALOPTS" in -"mfact +") xsetroot -name "#cmd:18" ;; -"mfact -") xsetroot -name "#cmd:19" ;; -"Toggle Sticky") xsetroot -name "#cmd:20" ;; -"Toggle Bar") xsetroot -name "#cmd:21" ;; -"Toggle Fullscreen") xsetroot -name "#cmd:22" ;; -"Reorganize Tags") xsetroot -name "#cmd:25" ;; -"Reset Layout/mfact") xsetroot -name "#cmd:59" ;; +"mfact +") speedwm -s "#cmd:18" ;; +"mfact -") speedwm -s "#cmd:19" ;; +"Toggle Sticky") speedwm -s "#cmd:20" ;; +"Toggle Bar") speedwm -s "#cmd:21" ;; +"Toggle Fullscreen") speedwm -s "#cmd:22" ;; +"Reorganize Tags") speedwm -s "#cmd:25" ;; +"Reset Layout/mfact") speedwm -s "#cmd:59" ;; esac } @@ -79,14 +79,14 @@ L14="$(printf "L14: Custom\n")" case "$1" in "layout") SEL_LAYOUT=$(printf "${L1}\n${L2}\n${L3}\n${L4}\n${L5}\n${L6}\n${L7}\n${L8}\n${L9}\n${L10}\n${L11}\n${L12}\n${L13}\n${L14}\nPrevious Layout\nNext Layout\nEnter S expression" | $RUNLAUNCHER -l 21 -p "Pick a layout: ") ;; -"reloadcolors") xsetroot -name "#cmd:65" ;; -"list") sed 's|xsetroot -name "#cmd:||g; s|"||g; s| - ||g; s@|@-@g' /usr/share/speedwm/example.fsignal | head -n "$(expr "$(cat /usr/share/speedwm/example.fsignal | wc -l)" - 1)" ;; +"reloadcolors") speedwm -s "#cmd:65" ;; +"list") sed 's|speedwm -s "#cmd:||g; s|"||g; s| - ||g; s@|@-@g' /usr/share/speedwm/example.fsignal | head -n "$(expr "$(cat /usr/share/speedwm/example.fsignal | wc -l)" - 1)" ;; "-help") HELP ;; "exec") if [ "$2" = "" ]; then exit 0 else - xsetroot -name "#cmd:$2" + speedwm -s "#cmd:$2" fi ;; "-h") HELP ;; "-general") GENERAL ;; @@ -95,21 +95,21 @@ esac case "$SEL_LAYOUT" in "Exit") exit 0 ;; -"Previous Layout") xsetroot -name "#cmd:16" ;; -"Next Layout") xsetroot -name "#cmd:17" ;; -"L1: Tiling") xsetroot -name "#cmd:1" ;; -"L2: Floating") xsetroot -name "#cmd:2" ;; -"L3: Monocle") xsetroot -name "#cmd:3" ;; -"L4: Grid") xsetroot -name "#cmd:4" ;; -"L5: Deck") xsetroot -name "#cmd:5" ;; -"L6: Centered Master") xsetroot -name "#cmd:6" ;; -"L7: Centered Floating Master") xsetroot -name "#cmd:7" ;; -"L8: Dwindle") xsetroot -name "#cmd:8" ;; -"L9: Spiral") xsetroot -name "#cmd:9" ;; -"L10: Bottom Stack (Vertical)") xsetroot -name "#cmd:10" ;; -"L11: Bottom Stack (Horizontal)") xsetroot -name "#cmd:11" ;; -"L12: Grid (Horizontal)") xsetroot -name "#cmd:12" ;; -"L13: Dynamic Grid") xsetroot -name "#cmd:13" ;; -"L14: Custom") xsetroot -name "#cmd:1" && xsetroot -name "#cmd:17" ;; -"Enter S expression") xsetroot -name "#cmd:15" ;; +"Previous Layout") speedwm -s "#cmd:16" ;; +"Next Layout") speedwm -s "#cmd:17" ;; +"L1: Tiling") speedwm -s "#cmd:1" ;; +"L2: Floating") speedwm -s "#cmd:2" ;; +"L3: Monocle") speedwm -s "#cmd:3" ;; +"L4: Grid") speedwm -s "#cmd:4" ;; +"L5: Deck") speedwm -s "#cmd:5" ;; +"L6: Centered Master") speedwm -s "#cmd:6" ;; +"L7: Centered Floating Master") speedwm -s "#cmd:7" ;; +"L8: Dwindle") speedwm -s "#cmd:8" ;; +"L9: Spiral") speedwm -s "#cmd:9" ;; +"L10: Bottom Stack (Vertical)") speedwm -s "#cmd:10" ;; +"L11: Bottom Stack (Horizontal)") speedwm -s "#cmd:11" ;; +"L12: Grid (Horizontal)") speedwm -s "#cmd:12" ;; +"L13: Dynamic Grid") speedwm -s "#cmd:13" ;; +"L14: Custom") speedwm -s "#cmd:1" && speedwm -s "#cmd:17" ;; +"Enter S expression") speedwm -s "#cmd:15" ;; esac diff --git a/scripts/speedwm-winnav b/scripts/speedwm-winnav index 7e160f8..0949452 100755 --- a/scripts/speedwm-winnav +++ b/scripts/speedwm-winnav @@ -113,6 +113,6 @@ esac wmctrl -a "$target" && echo "Switched focus" # show hidden window -command -v xsetroot > /dev/null && xsetroot -name "#cmd:28" +speedwm -s "#cmd:28" RESTORE diff --git a/scripts/speedwm_run b/scripts/speedwm_run index c6d0e3f..a4b6bda 100755 --- a/scripts/speedwm_run +++ b/scripts/speedwm_run @@ -79,8 +79,8 @@ LOADCOLS() { if [ "$DONOTLOADCONFIG" = "true" ]; then DONOTLOADCONFIG=true else - xsetroot -name "#cmd:65" # reload colors - xsetroot -name "Loading" # hide ugly signal + speedwm -s "#cmd:65" # reload colors + speedwm -s "Loading" # hide ugly signal echo "Loaded colors" fi } @@ -97,9 +97,9 @@ RESET() { if [ "$DONOTRELOAD" = "true" ]; then DONOTRELOAD=true else - xsetroot -name "Loading" # To hide the ugly fsignal status - xsetroot -name "#cmd:27" # Send fsignal to restart speedwm - xsetroot -name "Loading" # To hide the ugly fsignal status + speedwm -s "Loading" # To hide the ugly fsignal status + speedwm -s "#cmd:27" # Send fsignal to restart speedwm + speedwm -s "Loading" # To hide the ugly fsignal status fi } diff --git a/speedwm.c b/speedwm.c index 389ee02..d2cdd44 100644 --- a/speedwm.c +++ b/speedwm.c @@ -6348,12 +6348,17 @@ main(int argc, char *argv[]) { if (argc == 2 && !strcmp("-v", argv[1])) die("speedwm-"VERSION); - else if (argc != 1) - die("usage: speedwm [-v]"); + else if (argc != 1 && strcmp("-s", argv[1])) + die("usage: speedwm [-v] [-s]"); if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) fputs("warning: no locale support\n", stderr); if (!(dpy = XOpenDisplay(NULL))) die("speedwm: cannot open display"); + if (argc > 1 && !strcmp("-s", argv[1])) { + XStoreName(dpy, RootWindow(dpy, DefaultScreen(dpy)), argv[2]); + XCloseDisplay(dpy); + return 0; + } if (!(xcon = XGetXCBConnection(dpy))) die("speedwm: cannot get xcb connection\n"); checkotherwm(); diff --git a/status b/status index 73fbded..9caa7af 100755 --- a/status +++ b/status @@ -18,7 +18,7 @@ # General settings REFRESHDELAY=1 # How long delay in seconds between each reload (num) DATEBINDIR="/bin/" # Directory where your 'date' binary is. Default should be fine for most people -SETMETHOD="xsetroot -name" # Method used to set the status bar +SETMETHOD="speedwm -s" # Method used to set the status bar SEPARATOR="❰" # Separator to use. Alternative separators: "❰", "<", "|" COLORFG=true # Color foreground (true/false) COLORBG=false # Color background (true/false)