suckless-patches

My patches for http://suckless.org
git clone git://mahdi.pw/suckless-patches.git
Log | Files | Refs | README | LICENSE

commit 90f804030f8ab1826b2aff9e96c7b81d07510846
Author: MahdiMirzade <[email protected]>
Date:   Mon, 14 Mar 2022 20:59:50 +0330

add files

Diffstat:
AREADME.md | 13+++++++++++++
Adwm/dwm-bidi-20220309-0386419.diff | 132+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Ast/st-xresources-signal-reloading-20220312-6685098.diff | 165+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 310 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -0,0 +1,13 @@ +# suckless-patches +My patches for http://suckless.org/ (dwm) + +## dwm +- [dwm-bidi-20220309-0386419.diff](./dwm/dwm-bidi-20220309-0386419.diff) (https://dwm.suckless.org/patches/bidi/) +> Added support for RTL languages (Farsi, Arabic & Hebrew) + +## st +- [st-xresources-signal-reloading-20220312-6685098.diff](./st/st-xresources-signal-reloading-20220312-6685098.diff) (https://st.suckless.org/patches/xresources-with-reload-signal) +> This patch adds the ability to configure st via Xresources and signal reloading + +## Author +Mahdi Mirzade - [[email protected]](mailto:[email protected]) diff --git a/dwm/dwm-bidi-20220309-0386419.diff b/dwm/dwm-bidi-20220309-0386419.diff @@ -0,0 +1,132 @@ +From 0386419cfb5311d4a7516ece8f3f8fe923c43098 Mon Sep 17 00:00:00 2001 +From: MahdiMirzade <[email protected]> +Date: Wed, 9 Mar 2022 17:44:42 +0330 +Subject: [PATCH] [PATCH] Added support for RTL languages (Farsi, Arabic and + Hebrew using the FriBiDi library) - 9th Mar 2022 Fix + +--- + config.mk | 8 ++++++-- + dwm.c | 40 +++++++++++++++++++++++++++++++++------- + 2 files changed, 39 insertions(+), 9 deletions(-) + +diff --git a/config.mk b/config.mk +index b6eb7e0..5b60a24 100644 +--- a/config.mk ++++ b/config.mk +@@ -10,6 +10,8 @@ MANPREFIX = ${PREFIX}/share/man + X11INC = /usr/X11R6/include + X11LIB = /usr/X11R6/lib + ++BDINC = /usr/include/fribidi ++ + # Xinerama, comment if you don't want it + XINERAMALIBS = -lXinerama + XINERAMAFLAGS = -DXINERAMA +@@ -20,9 +22,11 @@ FREETYPEINC = /usr/include/freetype2 + # OpenBSD (uncomment) + #FREETYPEINC = ${X11INC}/freetype2 + ++BDLIBS = -lfribidi ++ + # includes and libs +-INCS = -I${X11INC} -I${FREETYPEINC} +-LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} ++INCS = -I${X11INC} -I${FREETYPEINC} -I$(BDINC) ++LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} $(BDLIBS) + + # flags + CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} +diff --git a/dwm.c b/dwm.c +index a96f33c..4f11fa0 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -40,6 +40,7 @@ + #include <X11/extensions/Xinerama.h> + #endif /* XINERAMA */ + #include <X11/Xft/Xft.h> ++#include <fribidi.h> + + #include "drw.h" + #include "util.h" +@@ -238,6 +239,7 @@ static void zoom(const Arg *arg); + /* variables */ + static const char broken[] = "broken"; + static char stext[256]; ++static char fribidi_text[BUFSIZ] = ""; + static int screen; + static int sw, sh; /* X display screen geometry width, height */ + static int bh, blw = 0; /* bar geometry */ +@@ -276,6 +278,26 @@ static Window root, wmcheckwin; + struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; + + /* function implementations */ ++static void ++apply_fribidi(char *str) ++{ ++ FriBidiStrIndex len = strlen(str); ++ FriBidiChar logical[BUFSIZ]; ++ FriBidiChar visual[BUFSIZ]; ++ FriBidiParType base = FRIBIDI_PAR_ON; ++ FriBidiCharSet charset; ++ fribidi_boolean result; ++ ++ fribidi_text[0] = 0; ++ if (len>0) ++ { ++ charset = fribidi_parse_charset("UTF-8"); ++ len = fribidi_charset_to_unicode(charset, str, len, logical); ++ result = fribidi_log2vis(logical, len, &base, visual, NULL, NULL, NULL); ++ len = fribidi_unicode_to_charset(charset, visual, len, fribidi_text); ++ } ++} ++ + void + applyrules(Client *c) + { +@@ -708,8 +730,9 @@ drawbar(Monitor *m) + /* draw status first so it can be overdrawn by tags later */ + if (m == selmon) { /* status is only drawn on selected monitor */ + drw_setscheme(drw, scheme[SchemeNorm]); +- tw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ +- drw_text(drw, m->ww - tw, 0, tw, bh, 0, stext, 0); ++ apply_fribidi(stext); ++ tw = TEXTW(fribidi_text) - lrpad + 2; /* 2px right padding */ ++ drw_text(drw, m->ww - tw, 0, tw, bh, 0, fribidi_text, 0); + } + + for (c = m->clients; c; c = c->next) { +@@ -719,23 +742,26 @@ drawbar(Monitor *m) + } + x = 0; + for (i = 0; i < LENGTH(tags); i++) { +- w = TEXTW(tags[i]); ++ apply_fribidi(tags[i]); ++ w = TEXTW(fribidi_text); + drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); +- drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i); ++ drw_text(drw, x, 0, w, bh, lrpad / 2, fribidi_text, urg & 1 << i); + if (occ & 1 << i) + drw_rect(drw, x + boxs, boxs, boxw, boxw, + m == selmon && selmon->sel && selmon->sel->tags & 1 << i, + urg & 1 << i); + x += w; + } +- w = blw = TEXTW(m->ltsymbol); ++ apply_fribidi(m->ltsymbol); ++ w = blw = TEXTW(fribidi_text); + drw_setscheme(drw, scheme[SchemeNorm]); +- x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); ++ x = drw_text(drw, x, 0, w, bh, lrpad / 2, fribidi_text, 0); + + if ((w = m->ww - tw - x) > bh) { + if (m->sel) { + drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); +- drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); ++ apply_fribidi(m->sel->name); ++ drw_text(drw, x, 0, w, bh, lrpad / 2, fribidi_text, 0); + if (m->sel->isfloating) + drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); + } else { +-- +2.35.1 + diff --git a/st/st-xresources-signal-reloading-20220312-6685098.diff b/st/st-xresources-signal-reloading-20220312-6685098.diff @@ -0,0 +1,165 @@ +From 6685098b4e368a750b200adda0be64198ac386a8 Mon Sep 17 00:00:00 2001 +From: MahdiMirzade <[email protected]> +Date: Sat, 12 Mar 2022 16:05:23 +0330 +Subject: [PATCH] handle st settings from Xresources + reload all st instances + by running 'pidof st | xargs kill -s USR1' + +--- + x.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 127 insertions(+) + +diff --git a/x.c b/x.c +index cd96575..61701b5 100644 +--- a/x.c ++++ b/x.c +@@ -14,6 +14,7 @@ + #include <X11/keysym.h> + #include <X11/Xft/Xft.h> + #include <X11/XKBlib.h> ++#include <X11/Xresource.h> + + char *argv0; + #include "arg.h" +@@ -2011,6 +2012,130 @@ run(void) + } + } + ++#define XRESOURCE_LOAD_META(NAME) \ ++ if(!XrmGetResource(xrdb, "st." NAME, "st." NAME, &type, &ret)) \ ++ XrmGetResource(xrdb, "*." NAME, "*." NAME, &type, &ret); \ ++ if (ret.addr != NULL && !strncmp("String", type, 64)) ++ ++#define XRESOURCE_LOAD_STRING(NAME, DST) \ ++ XRESOURCE_LOAD_META(NAME) \ ++ DST = ret.addr; ++ ++#define XRESOURCE_LOAD_CHAR(NAME, DST) \ ++ XRESOURCE_LOAD_META(NAME) \ ++ DST = ret.addr[0]; ++ ++#define XRESOURCE_LOAD_INTEGER(NAME, DST) \ ++ XRESOURCE_LOAD_META(NAME) \ ++ DST = strtoul(ret.addr, NULL, 10); ++ ++#define XRESOURCE_LOAD_FLOAT(NAME, DST) \ ++ XRESOURCE_LOAD_META(NAME) \ ++ DST = strtof(ret.addr, NULL); ++ ++void ++xrdb_load(void) ++{ ++ /* XXX */ ++ char *xrm; ++ char *type; ++ XrmDatabase xrdb; ++ XrmValue ret; ++ Display *dpy; ++ ++ if(!(dpy = XOpenDisplay(NULL))) ++ die("Can't open display\n"); ++ ++ XrmInitialize(); ++ xrm = XResourceManagerString(dpy); ++ ++ if (xrm != NULL) { ++ xrdb = XrmGetStringDatabase(xrm); ++ ++ /* handling colors here without macros to do via loop. */ ++ int i = 0; ++ char loadValue[12] = ""; ++ for (i = 0; i < 256; i++) ++ { ++ sprintf(loadValue, "%s%d", "st.color", i); ++ ++ if(!XrmGetResource(xrdb, loadValue, loadValue, &type, &ret)) ++ { ++ sprintf(loadValue, "%s%d", "*.color", i); ++ if (!XrmGetResource(xrdb, loadValue, loadValue, &type, &ret)) ++ /* reset if not found (unless in range for defaults). */ ++ if (i > 15) ++ colorname[i] = NULL; ++ } ++ ++ if (ret.addr != NULL && !strncmp("String", type, 64)) ++ colorname[i] = ret.addr; ++ } ++ ++ XRESOURCE_LOAD_STRING("foreground", colorname[defaultfg]); ++ XRESOURCE_LOAD_STRING("background", colorname[defaultbg]); ++ XRESOURCE_LOAD_STRING("cursorfg", colorname[defaultcs]) ++ else { ++ // this looks confusing because we are chaining off of the if ++ // in the macro. probably we should be wrapping everything blocks ++ // so this isn't possible... ++ defaultcs = defaultfg; ++ } ++ XRESOURCE_LOAD_STRING("reverse-cursor", colorname[defaultrcs]) ++ else { ++ // see above. ++ defaultrcs = defaultbg; ++ } ++ ++ XRESOURCE_LOAD_STRING("font", font); ++ XRESOURCE_LOAD_STRING("termname", termname); ++ ++ /* XRESOURCE_LOAD_INTEGER("xfps", xfps); */ ++ /* XRESOURCE_LOAD_INTEGER("actionfps", actionfps); */ ++ XRESOURCE_LOAD_INTEGER("blinktimeout", blinktimeout); ++ XRESOURCE_LOAD_INTEGER("bellvolume", bellvolume); ++ XRESOURCE_LOAD_INTEGER("borderpx", borderpx); ++ /* XRESOURCE_LOAD_INTEGER("borderless", borderless); */ ++ XRESOURCE_LOAD_INTEGER("cursorshape", cursorshape); ++ ++ /* cursorblinkstate = 1; // in case if cursor shape was changed from a blinking one to a non-blinking */ ++ /* XRESOURCE_LOAD_INTEGER("cursorthickness", cursorthickness); */ ++ /* XRESOURCE_LOAD_INTEGER("cursorblinkstyle", cursorblinkstyle); */ ++ /* XRESOURCE_LOAD_INTEGER("cursorblinkontype", cursorblinkontype); */ ++ ++ /* todo: https://github.com/gnotclub/xst/commit/1e82647b0e04077e975679a4b4cf1eb02b04e6bc */ ++ /* XRESOURCE_LOAD_INTEGER("mouseScrollLines", mousescrolllines); */ ++ ++ XRESOURCE_LOAD_FLOAT("cwscale", cwscale); ++ XRESOURCE_LOAD_FLOAT("chscale", chscale); ++ ++ /* XRESOURCE_LOAD_CHAR("prompt_char", prompt_char); */ ++ ++ } ++ XFlush(dpy); ++} ++ ++void ++reload(int sig) ++{ ++ xrdb_load(); ++ ++ /* colors, fonts */ ++ xloadcols(); ++ xunloadfonts(); ++ xloadfonts(font, 0); ++ ++ /* pretend the window just got resized */ ++ cresize(win.w, win.h); ++ ++ redraw(); ++ ++ /* triggers re-render if we're visible. */ ++ ttywrite("\033[O", 3, 1); ++ ++ signal(SIGUSR1, reload); ++} ++ + void + usage(void) + { +@@ -2084,6 +2209,8 @@ run: + + setlocale(LC_CTYPE, ""); + XSetLocaleModifiers(""); ++ xrdb_load(); ++ signal(SIGUSR1, reload); + cols = MAX(cols, 1); + rows = MAX(rows, 1); + tnew(cols, rows); +-- +2.35.1 +