Update fsignal patch, it now sucks less and doesn't shit the status text

This commit is contained in:
speediegq 2022-10-14 16:14:45 +02:00
parent c144319610
commit 20ddcbd098
10 changed files with 60 additions and 56 deletions

View file

@ -4,7 +4,7 @@ Instead, config.h is split into different parts to make it easier to edit. Inste
- autostart.h for starting stuff right before speedwm (For example xclip, pywal, etc.) - autostart.h for starting stuff right before speedwm (For example xclip, pywal, etc.)
- options.h for changing colors and applications to use with keybinds. - options.h for changing colors and applications to use with keybinds.
- fsignal.h for adding fake signals - signal.h for adding fake signals
- colors.h for changing alpha options and color options, most users won't need to edit it. - colors.h for changing alpha options and color options, most users won't need to edit it.
- xresources.h for adding/removing .Xresources options - xresources.h for adding/removing .Xresources options
- rules.h for adding/removing rules - rules.h for adding/removing rules

View file

@ -1,6 +1,6 @@
-- Fsignal -- -- Signals --
Thanks to the 'fsignal' patch available on suckless.org's website, we can easily write shell scripts to interact with dwm and therefore speedwm. Thanks to the 'fsignal' patch available on suckless.org's website, we can easily write shell scripts to interact with dwm and therefore speedwm.
This is exactly what I did and speedwm-utils, speedwm-swal, speedwm-shutdown and more take advantage of it. 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. In order to use 'fsignal', your system must have 'xsetroot' installed.
Then simply use the dwm-utils script. Syntax is dwm-utils -exec <signum> Then simply use the dwm-utils script. Syntax is dwm-utils -exec <signum>

View file

@ -45,7 +45,7 @@
* - If you're looking to disable a feature, see toggle.h (Disabling features) and toggle.mk (Disabling libraries the features depend on) * - If you're looking to disable a feature, see toggle.h (Disabling features) and toggle.mk (Disabling libraries the features depend on)
* - If you want to change IPC settings, you can find the IPC options in ipc.h (speedwm-msg source in toggle/) * - If you want to change IPC settings, you can find the IPC options in ipc.h (speedwm-msg source in toggle/)
* - If you want to add .Xresources values (All of them have already been added), that's in the xresources.h header. * - If you want to add .Xresources values (All of them have already been added), that's in the xresources.h header.
* - If you want to add an fsignal signum, it can be done in the fsignal.h header. * - If you want to add an signal signum, it can be done in the signal.h header.
* - If you want to add/remove autostart lines, that can be found in the autostart.h header. * - If you want to add/remove autostart lines, that can be found in the autostart.h header.
* - If you want to modify mouse binds, edit mouse.h. * - If you want to modify mouse binds, edit mouse.h.
* - If you want to extensively change alpha and color options (probably not necessary), you can modify the colors.h header. * - If you want to extensively change alpha and color options (probably not necessary), you can modify the colors.h header.

View file

@ -49,7 +49,7 @@ $DOCDIR/${PREFIX}example.fsignal \
$DOCDIR/${PREFIX}doc-08 \ $DOCDIR/${PREFIX}doc-08 \
$DOCDIR/${PREFIX}doc-09 \ $DOCDIR/${PREFIX}doc-09 \
$DOCDIR/${PREFIX}doc-10 \ $DOCDIR/${PREFIX}doc-10 \
| sed 's|xsetroot -name "fsignal:||g; s|"||g' | grep -v "!!")" > /tmp/${PREFIX}doc | grep -v "!!")" > /tmp/${PREFIX}doc
case "$ARG1" in case "$ARG1" in
"-w") tail -n $(expr $(cat /tmp/${PREFIX}doc | wc -l) "-" 1) /tmp/${PREFIX}doc > ../readme ;; "-w") tail -n $(expr $(cat /tmp/${PREFIX}doc | wc -l) "-" 1) /tmp/${PREFIX}doc > ../readme ;;
@ -69,7 +69,7 @@ case "$ARG1" in
sed "s|-- Software --|## Software|g" | \ sed "s|-- Software --|## Software|g" | \
sed "s|-- Important --|## Important|g" | \ sed "s|-- Important --|## Important|g" | \
sed "s|-- .Xresources and Pywal --|## .Xresources and Pywal|g" | \ sed "s|-- .Xresources and Pywal --|## .Xresources and Pywal|g" | \
sed "s|-- Fsignal --|## Fsignal|g" | \ sed "s|-- Signals --|## Signals|g" | \
sed "s|-- Additional note on autostart --|## Additional note on autostart|g" | \ sed "s|-- Additional note on autostart --|## Additional note on autostart|g" | \
sed "s|-- Maintaining settings easily --|## Maintaining settings easily|g" | \ sed "s|-- Maintaining settings easily --|## Maintaining settings easily|g" | \
sed "s|-- Switching run launcher --|## Switching run launcher|g" > ../README.md ;; sed "s|-- Switching run launcher --|## Switching run launcher|g" > ../README.md ;;
@ -90,7 +90,7 @@ case "$ARG1" in
sed "s|-- Software --|## Software|g" | \ sed "s|-- Software --|## Software|g" | \
sed "s|-- Important --|## Important|g" | \ sed "s|-- Important --|## Important|g" | \
sed "s|-- .Xresources and Pywal --|## .Xresources and Pywal|g" | \ sed "s|-- .Xresources and Pywal --|## .Xresources and Pywal|g" | \
sed "s|-- Fsignal --|## Fsignal|g" | \ sed "s|-- Signals --|## Signals|g" | \
sed "s|-- Maintaining settings easily --|## Maintaining settings easily|g" | \ sed "s|-- Maintaining settings easily --|## Maintaining settings easily|g" | \
sed "s|-- Additional note on autostart --|## Additional note on autostart|g" | \ sed "s|-- Additional note on autostart --|## Additional note on autostart|g" | \
sed "s|-- Switching run launcher --|## Switching run launcher|g" > ../README.md sed "s|-- Switching run launcher --|## Switching run launcher|g" > ../README.md
@ -98,7 +98,7 @@ case "$ARG1" in
"-whtml-wtemplate") test ../readme.html && cat ../docs/speedwm.html.template.1 ../readme.html ../docs/speedwm.html.template.2 >> ../speedwm.html && exit 0 "-whtml-wtemplate") test ../readme.html && cat ../docs/speedwm.html.template.1 ../readme.html ../docs/speedwm.html.template.2 >> ../speedwm.html && exit 0
printf "\nYou need to $0 -whtml first." ; exit 1 ;; printf "\nYou need to $0 -whtml first." ; exit 1 ;;
"") $0 -h && exit 0 ;; "") $0 -h && exit 0 ;;
"-h") printf "speedwm help\n\nNo arguments to view this list of arguments.\n-h | View this list of arguments.\n-a | View everything.\n-1 | What is speedwm?\n-2 | List of all keybinds\n-3 | List of all dependencies\n-4 | .Xresources/Pywal information.\n-5 | Fsignal information\n-6 | Switching run launcher\n-7 | Installation\n-8 | Layouts\n-9| Important information.\n-w | Write documentation to ../readme\n-wmd | Write documentation (Markdown)\n-whtml | Write documentation (HTML) using markdown-to-html.\n-whtml-wtemplate | Combine template 1, output of -whtml and template 2 (from docs/) to create a full HTML document.\n\nIf second argument is -o, the requested output will be sent to stdout.\n-o can be replaced with a text editor or reader of your choice (such as less, vim, emacs, etc.)\n"; exit 0 ;; "-h") printf "speedwm help\n\nNo arguments to view this list of arguments.\n-h | View this list of arguments.\n-a | View everything.\n-1 | What is speedwm?\n-2 | List of all keybinds\n-3 | List of all dependencies\n-4 | .Xresources/Pywal information.\n-5 | Signals information\n-6 | Switching run launcher\n-7 | Installation\n-8 | Layouts\n-9| Important information.\n-w | Write documentation to ../readme\n-wmd | Write documentation (Markdown)\n-whtml | Write documentation (HTML) using markdown-to-html.\n-whtml-wtemplate | Combine template 1, output of -whtml and template 2 (from docs/) to create a full HTML document.\n\nIf second argument is -o, the requested output will be sent to stdout.\n-o can be replaced with a text editor or reader of your choice (such as less, vim, emacs, etc.)\n"; exit 0 ;;
"-1") cat $DOCDIR/${PREFIX}doc-01 > /tmp/stdout ; $VIEWER /tmp/stdout ;; "-1") cat $DOCDIR/${PREFIX}doc-01 > /tmp/stdout ; $VIEWER /tmp/stdout ;;
"-2") cat $DOCDIR/${PREFIX}doc-04 $DOCDIR/${PREFIX}keybinds > /tmp/stdout ; $VIEWER /tmp/stdout ;; "-2") cat $DOCDIR/${PREFIX}doc-04 $DOCDIR/${PREFIX}keybinds > /tmp/stdout ; $VIEWER /tmp/stdout ;;
"-3") cat $DOCDIR/${PREFIX}dependencies > /tmp/stdout ; $VIEWER /tmp/stdout ;; "-3") cat $DOCDIR/${PREFIX}dependencies > /tmp/stdout ; $VIEWER /tmp/stdout ;;

View file

@ -110,7 +110,7 @@ SWAL_SOLIDCOLOR() {
xsetroot -solid "$ISCOL" xsetroot -solid "$ISCOL"
rm -f $SWAL_EXPORTDIR/swal_wm rm -f $SWAL_EXPORTDIR/swal_wm
xrdb -remove xrdb -remove
xsetroot -name "fsignal:65" xsetroot -name "cmd!65"
printf "#!/bin/sh\nxsetroot -solid "$ISCOL"" > $SWAL_EXPORTDIR/swal_wm printf "#!/bin/sh\nxsetroot -solid "$ISCOL"" > $SWAL_EXPORTDIR/swal_wm
command -v notify-send > /dev/null && notify-send " Solid color $ISCOL set as wallpaper." command -v notify-send > /dev/null && notify-send " Solid color $ISCOL set as wallpaper."

View file

@ -32,13 +32,13 @@ VARS
GENERAL() { 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?') 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 case "$GENERALOPTS" in
"mfact +") xsetroot -name "fsignal:18" ;; "mfact +") xsetroot -name "#cmd:18" ;;
"mfact -") xsetroot -name "fsignal:19" ;; "mfact -") xsetroot -name "#cmd:19" ;;
"Toggle Sticky") xsetroot -name "fsignal:20" ;; "Toggle Sticky") xsetroot -name "#cmd:20" ;;
"Toggle Bar") xsetroot -name "fsignal:21" ;; "Toggle Bar") xsetroot -name "#cmd:21" ;;
"Toggle Fullscreen") xsetroot -name "fsignal:22" ;; "Toggle Fullscreen") xsetroot -name "#cmd:22" ;;
"Reorganize Tags") xsetroot -name "fsignal:25" ;; "Reorganize Tags") xsetroot -name "#cmd:25" ;;
"Reset Layout/mfact") xsetroot -name "fsignal:59" ;; "Reset Layout/mfact") xsetroot -name "#cmd:59" ;;
esac esac
} }
@ -79,14 +79,14 @@ L14="$(printf "L14: Custom\n")"
case "$1" in 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: ") ;; "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 "fsignal:65" ;; "reloadcolors") xsetroot -name "#cmd:65" ;;
"list") sed 's|xsetroot -name "fsignal:||g; s|"||g; s| - ||g; s@|@-@g' /usr/share/speedwm/example.fsignal | head -n "$(expr "$(cat /usr/share/speedwm/example.fsignal | wc -l)" - 1)" ;; "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)" ;;
"-help") HELP ;; "-help") HELP ;;
"exec") "exec")
if [ "$2" = "" ]; then if [ "$2" = "" ]; then
exit 0 exit 0
else else
xsetroot -name "fsignal:$2" xsetroot -name "#cmd:$2"
fi ;; fi ;;
"-h") HELP ;; "-h") HELP ;;
"-general") GENERAL ;; "-general") GENERAL ;;
@ -95,21 +95,21 @@ esac
case "$SEL_LAYOUT" in case "$SEL_LAYOUT" in
"Exit") exit 0 ;; "Exit") exit 0 ;;
"Previous Layout") xsetroot -name "fsignal:16" ;; "Previous Layout") xsetroot -name "#cmd:16" ;;
"Next Layout") xsetroot -name "fsignal:17" ;; "Next Layout") xsetroot -name "#cmd:17" ;;
"L1: Tiling") xsetroot -name "fsignal:1" ;; "L1: Tiling") xsetroot -name "#cmd:1" ;;
"L2: Floating") xsetroot -name "fsignal:2" ;; "L2: Floating") xsetroot -name "#cmd:2" ;;
"L3: Monocle") xsetroot -name "fsignal:3" ;; "L3: Monocle") xsetroot -name "#cmd:3" ;;
"L4: Grid") xsetroot -name "fsignal:4" ;; "L4: Grid") xsetroot -name "#cmd:4" ;;
"L5: Deck") xsetroot -name "fsignal:5" ;; "L5: Deck") xsetroot -name "#cmd:5" ;;
"L6: Centered Master") xsetroot -name "fsignal:6" ;; "L6: Centered Master") xsetroot -name "#cmd:6" ;;
"L7: Centered Floating Master") xsetroot -name "fsignal:7" ;; "L7: Centered Floating Master") xsetroot -name "#cmd:7" ;;
"L8: Dwindle") xsetroot -name "fsignal:8" ;; "L8: Dwindle") xsetroot -name "#cmd:8" ;;
"L9: Spiral") xsetroot -name "fsignal:9" ;; "L9: Spiral") xsetroot -name "#cmd:9" ;;
"L10: Bottom Stack (Vertical)") xsetroot -name "fsignal:10" ;; "L10: Bottom Stack (Vertical)") xsetroot -name "#cmd:10" ;;
"L11: Bottom Stack (Horizontal)") xsetroot -name "fsignal:11" ;; "L11: Bottom Stack (Horizontal)") xsetroot -name "#cmd:11" ;;
"L12: Grid (Horizontal)") xsetroot -name "fsignal:12" ;; "L12: Grid (Horizontal)") xsetroot -name "#cmd:12" ;;
"L13: Dynamic Grid") xsetroot -name "fsignal:13" ;; "L13: Dynamic Grid") xsetroot -name "#cmd:13" ;;
"L14: Custom") xsetroot -name "fsignal:1" && xsetroot -name "fsignal:17" ;; "L14: Custom") xsetroot -name "#cmd:1" && xsetroot -name "#cmd:17" ;;
"Enter S expression") xsetroot -name "fsignal:15" ;; "Enter S expression") xsetroot -name "#cmd:15" ;;
esac esac

View file

@ -113,6 +113,6 @@ esac
wmctrl -a "$target" && echo "Switched focus" wmctrl -a "$target" && echo "Switched focus"
# show hidden window # show hidden window
command -v xsetroot > /dev/null && xsetroot -name "fsignal:28" command -v xsetroot > /dev/null && xsetroot -name "#cmd:28"
RESTORE RESTORE

View file

@ -79,7 +79,7 @@ LOADCOLS() {
if [ "$DONOTLOADCONFIG" = "true" ]; then if [ "$DONOTLOADCONFIG" = "true" ]; then
DONOTLOADCONFIG=true DONOTLOADCONFIG=true
else else
xsetroot -name "fsignal:65" # reload colors xsetroot -name "cmd!65" # reload colors
xsetroot -name "Loading" # hide ugly fsignal xsetroot -name "Loading" # hide ugly fsignal
echo "Loaded colors" echo "Loaded colors"
fi fi
@ -98,7 +98,7 @@ RESET() {
DONOTRELOAD=true DONOTRELOAD=true
else else
xsetroot -name "Loading" # To hide the ugly fsignal status xsetroot -name "Loading" # To hide the ugly fsignal status
xsetroot -name "fsignal:27" # Send fsignal to restart speedwm xsetroot -name "cmd!27" # Send fsignal to restart speedwm
xsetroot -name "Loading" # To hide the ugly fsignal status xsetroot -name "Loading" # To hide the ugly fsignal status
fi fi
} }

View file

View file

@ -420,7 +420,7 @@ static void incnmaster(const Arg *arg);
static int handlexevent(struct epoll_event *ev); static int handlexevent(struct epoll_event *ev);
#endif #endif
static void keypress(XEvent *e); static void keypress(XEvent *e);
static int fake_signal(void); static int getsignal(void);
static void killclient(const Arg *arg); static void killclient(const Arg *arg);
static void killunsel(const Arg *arg); static void killunsel(const Arg *arg);
#if USEMOUSE #if USEMOUSE
@ -733,7 +733,7 @@ static const char *statuscmd[] = { shell, "-c", NULL, NULL };
#include "statusbar.h" /* Include mouse statuscmd support */ #include "statusbar.h" /* Include mouse statuscmd support */
#endif #endif
#include "fsignal.h" /* Include fsignal support */ #include "signal.h" /* Include signal support */
unsigned int tagw[LENGTH(tags)]; unsigned int tagw[LENGTH(tags)];
@ -2831,24 +2831,25 @@ keypress(XEvent *e)
} }
int int
fake_signal(void) getsignal(void)
{ {
char fsignal[256]; char signal[256];
char indicator[9] = "fsignal:"; char indicator[9] = "#cmd:";
char str_signum[16]; char str_signum[16];
char *prevstatus = rawstext;
int i, v, signum; int i, v, signum;
size_t len_fsignal, len_indicator = strlen(indicator); size_t len_signal, len_indicator = strlen(indicator);
// Get root name property /* Get root name property */
if (gettextprop(root, XA_WM_NAME, fsignal, sizeof(fsignal))) { if (gettextprop(root, XA_WM_NAME, signal, sizeof(signal))) {
len_fsignal = strlen(fsignal); len_signal = strlen(signal);
// Check if this is indeed a fake signal /* Check if this is indeed a fake signal */
if (len_indicator > len_fsignal ? 0 : strncmp(indicator, fsignal, len_indicator) == 0) { if (len_indicator > len_signal ? 0 : strncmp(indicator, signal, len_indicator) == 0) {
memcpy(str_signum, &fsignal[len_indicator], len_fsignal - len_indicator); memcpy(str_signum, &signal[len_indicator], len_signal - len_indicator);
str_signum[len_fsignal - len_indicator] = '\0'; str_signum[len_signal - len_indicator] = '\0';
// Convert string value into managable integer /* Convert string value into managable integer */
for (i = signum = 0; i < strlen(str_signum); i++) { for (i = signum = 0; i < strlen(str_signum); i++) {
v = str_signum[i] - '0'; v = str_signum[i] - '0';
if (v >= 0 && v <= 9) { if (v >= 0 && v <= 9) {
@ -2856,13 +2857,16 @@ fake_signal(void)
} }
} }
// Check if a signal was found, and if so handle it /* Check if a signal was found, and if so handle it */
if (signum) if (signum)
for (i = 0; i < LENGTH(signals); i++) for (i = 0; i < LENGTH(signals); i++)
if (signum == signals[i].signum && signals[i].func) if (signum == signals[i].signum && signals[i].func)
signals[i].func(&(signals[i].arg)); signals[i].func(&(signals[i].arg));
// A fake signal was sent /* Set status bar to previous status */
strcpy(prevstatus, stext);
/* A fake signal was sent */
return 1; return 1;
} }
} }
@ -3949,7 +3953,7 @@ propertynotify(XEvent *e)
#endif #endif
if ((ev->window == root) && (ev->atom == XA_WM_NAME)) { if ((ev->window == root) && (ev->atom == XA_WM_NAME)) {
if (!fake_signal()) if (!getsignal())
updatestatus(); updatestatus();
} }
else if (ev->state == PropertyDelete) else if (ev->state == PropertyDelete)