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.)
- 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.
- xresources.h for adding/removing .Xresources options
- 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.
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.
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 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 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 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.

View file

@ -49,7 +49,7 @@ $DOCDIR/${PREFIX}example.fsignal \
$DOCDIR/${PREFIX}doc-08 \
$DOCDIR/${PREFIX}doc-09 \
$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
"-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|-- Important --|## Important|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|-- Maintaining settings easily --|## Maintaining settings easily|g" | \
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|-- Important --|## Important|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|-- Additional note on autostart --|## Additional note on autostart|g" | \
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
printf "\nYou need to $0 -whtml first." ; exit 1 ;;
"") $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 ;;
"-2") cat $DOCDIR/${PREFIX}doc-04 $DOCDIR/${PREFIX}keybinds > /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"
rm -f $SWAL_EXPORTDIR/swal_wm
xrdb -remove
xsetroot -name "fsignal:65"
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."

View file

@ -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 "fsignal:18" ;;
"mfact -") xsetroot -name "fsignal:19" ;;
"Toggle Sticky") xsetroot -name "fsignal:20" ;;
"Toggle Bar") xsetroot -name "fsignal:21" ;;
"Toggle Fullscreen") xsetroot -name "fsignal:22" ;;
"Reorganize Tags") xsetroot -name "fsignal:25" ;;
"Reset Layout/mfact") xsetroot -name "fsignal:59" ;;
"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" ;;
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 "fsignal: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)" ;;
"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)" ;;
"-help") HELP ;;
"exec")
if [ "$2" = "" ]; then
exit 0
else
xsetroot -name "fsignal:$2"
xsetroot -name "#cmd:$2"
fi ;;
"-h") HELP ;;
"-general") GENERAL ;;
@ -95,21 +95,21 @@ esac
case "$SEL_LAYOUT" in
"Exit") exit 0 ;;
"Previous Layout") xsetroot -name "fsignal:16" ;;
"Next Layout") xsetroot -name "fsignal:17" ;;
"L1: Tiling") xsetroot -name "fsignal:1" ;;
"L2: Floating") xsetroot -name "fsignal:2" ;;
"L3: Monocle") xsetroot -name "fsignal:3" ;;
"L4: Grid") xsetroot -name "fsignal:4" ;;
"L5: Deck") xsetroot -name "fsignal:5" ;;
"L6: Centered Master") xsetroot -name "fsignal:6" ;;
"L7: Centered Floating Master") xsetroot -name "fsignal:7" ;;
"L8: Dwindle") xsetroot -name "fsignal:8" ;;
"L9: Spiral") xsetroot -name "fsignal:9" ;;
"L10: Bottom Stack (Vertical)") xsetroot -name "fsignal:10" ;;
"L11: Bottom Stack (Horizontal)") xsetroot -name "fsignal:11" ;;
"L12: Grid (Horizontal)") xsetroot -name "fsignal:12" ;;
"L13: Dynamic Grid") xsetroot -name "fsignal:13" ;;
"L14: Custom") xsetroot -name "fsignal:1" && xsetroot -name "fsignal:17" ;;
"Enter S expression") xsetroot -name "fsignal:15" ;;
"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" ;;
esac

View file

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

View file

@ -79,7 +79,7 @@ LOADCOLS() {
if [ "$DONOTLOADCONFIG" = "true" ]; then
DONOTLOADCONFIG=true
else
xsetroot -name "fsignal:65" # reload colors
xsetroot -name "cmd!65" # reload colors
xsetroot -name "Loading" # hide ugly fsignal
echo "Loaded colors"
fi
@ -98,7 +98,7 @@ RESET() {
DONOTRELOAD=true
else
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
fi
}

View file

View file

@ -420,7 +420,7 @@ static void incnmaster(const Arg *arg);
static int handlexevent(struct epoll_event *ev);
#endif
static void keypress(XEvent *e);
static int fake_signal(void);
static int getsignal(void);
static void killclient(const Arg *arg);
static void killunsel(const Arg *arg);
#if USEMOUSE
@ -733,7 +733,7 @@ static const char *statuscmd[] = { shell, "-c", NULL, NULL };
#include "statusbar.h" /* Include mouse statuscmd support */
#endif
#include "fsignal.h" /* Include fsignal support */
#include "signal.h" /* Include signal support */
unsigned int tagw[LENGTH(tags)];
@ -2831,24 +2831,25 @@ keypress(XEvent *e)
}
int
fake_signal(void)
getsignal(void)
{
char fsignal[256];
char indicator[9] = "fsignal:";
char signal[256];
char indicator[9] = "#cmd:";
char str_signum[16];
char *prevstatus = rawstext;
int i, v, signum;
size_t len_fsignal, len_indicator = strlen(indicator);
size_t len_signal, len_indicator = strlen(indicator);
// Get root name property
if (gettextprop(root, XA_WM_NAME, fsignal, sizeof(fsignal))) {
len_fsignal = strlen(fsignal);
/* Get root name property */
if (gettextprop(root, XA_WM_NAME, signal, sizeof(signal))) {
len_signal = strlen(signal);
// Check if this is indeed a fake signal
if (len_indicator > len_fsignal ? 0 : strncmp(indicator, fsignal, len_indicator) == 0) {
memcpy(str_signum, &fsignal[len_indicator], len_fsignal - len_indicator);
str_signum[len_fsignal - len_indicator] = '\0';
/* Check if this is indeed a fake signal */
if (len_indicator > len_signal ? 0 : strncmp(indicator, signal, len_indicator) == 0) {
memcpy(str_signum, &signal[len_indicator], len_signal - len_indicator);
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++) {
v = str_signum[i] - '0';
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)
for (i = 0; i < LENGTH(signals); i++)
if (signum == signals[i].signum && signals[i].func)
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;
}
}
@ -3949,7 +3953,7 @@ propertynotify(XEvent *e)
#endif
if ((ev->window == root) && (ev->atom == XA_WM_NAME)) {
if (!fake_signal())
if (!getsignal())
updatestatus();
}
else if (ev->state == PropertyDelete)