sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 815859e5e27f61ab9e59eb27246ee1a02437abf6
parent 3f42a4b7ce2549972bbee2c59d771f6b84591bde
Author: Adham Zahran <lordadamson@gmail.com>
Date:   Wed, 27 May 2020 18:42:20 +0200

[dwm][patch][launcher] Adding a new patch

Diffstat:
Adwm.suckless.org/patches/launcher/dwm-launchers-20200527-f09418b.diff | 101+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adwm.suckless.org/patches/launcher/index.md | 35+++++++++++++++++++++++++++++++++++
2 files changed, 136 insertions(+), 0 deletions(-)

diff --git a/dwm.suckless.org/patches/launcher/dwm-launchers-20200527-f09418b.diff b/dwm.suckless.org/patches/launcher/dwm-launchers-20200527-f09418b.diff @@ -0,0 +1,101 @@ +From 6b5e23cdf8108a9033acc7c21c8926c0c72647fc Mon Sep 17 00:00:00 2001 +From: Adham Zahran <adhamzahranfms@gmail.com> +Date: Wed, 27 May 2020 18:07:57 +0200 +Subject: [PATCH] Top bar now has buttons that launches programs + +--- + config.def.h | 8 ++++++++ + dwm.c | 36 ++++++++++++++++++++++++++++++++++-- + 2 files changed, 42 insertions(+), 2 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 1c0b587..9231cd5 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -21,6 +21,14 @@ static const char *colors[][3] = { + /* tagging */ + static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; + ++/* launcher commands (They must be NULL terminated) */ ++static const char* surf[] = { "surf", "duckduckgo.com", NULL }; ++ ++static const Launcher launchers[] = { ++ /* command name to display */ ++ { surf, "surf" }, ++}; ++ + static const Rule rules[] = { + /* xprop(1): + * WM_CLASS(STRING) = instance, class +diff --git a/dwm.c b/dwm.c +index 9fd0286..79e7e20 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -141,6 +141,11 @@ typedef struct { + int monitor; + } Rule; + ++typedef struct { ++ const char** command; ++ const char* name; ++} Launcher; ++ + /* function declarations */ + static void applyrules(Client *c); + static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact); +@@ -438,9 +443,26 @@ buttonpress(XEvent *e) + if (i < LENGTH(tags)) { + click = ClkTagBar; + arg.ui = 1 << i; +- } else if (ev->x < x + blw) ++ goto execute_handler; ++ } else if (ev->x < x + blw) { + click = ClkLtSymbol; +- else if (ev->x > selmon->ww - TEXTW(stext)) ++ goto execute_handler; ++ } ++ ++ x += blw; ++ ++ for(i = 0; i < LENGTH(launchers); i++) { ++ x += TEXTW(launchers[i].name); ++ ++ if (ev->x < x) { ++ Arg a; ++ a.v = launchers[i].command; ++ spawn(&a); ++ return; ++ } ++ } ++ ++ if (ev->x > selmon->ww - TEXTW(stext)) + click = ClkStatusText; + else + click = ClkWinTitle; +@@ -450,6 +472,9 @@ buttonpress(XEvent *e) + XAllowEvents(dpy, ReplayPointer, CurrentTime); + click = ClkClientWin; + } ++ ++execute_handler: ++ + for (i = 0; i < LENGTH(buttons); i++) + if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button + && CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)) +@@ -728,6 +753,13 @@ drawbar(Monitor *m) + w = blw = TEXTW(m->ltsymbol); + drw_setscheme(drw, scheme[SchemeNorm]); + x = drw_text(drw, x, 0, w, bh, lrpad / 2, m->ltsymbol, 0); ++ ++ for (i = 0; i < LENGTH(launchers); i++) ++ { ++ w = TEXTW(launchers[i].name); ++ drw_text(drw, x, 0, w, bh, lrpad / 2, launchers[i].name, urg & 1 << i); ++ x += w; ++ } + + if ((w = m->ww - tw - x) > bh) { + if (m->sel) { +-- +2.17.1 + diff --git a/dwm.suckless.org/patches/launcher/index.md b/dwm.suckless.org/patches/launcher/index.md @@ -0,0 +1,35 @@ +launcher +======== + +Description +----------- +The bar at the top will have buttons that you can click to launch programs and commands. + +Usage: +------ +In config.h make a command: + + + /* launcher command (Must be NULL terminated) */ + static const char* surf[] = { "surf", "duckduckgo.com", NULL }; + + +Then add it to the launchers array: + + + static const Launcher launchers[] = { + /* command name to display */ + { surf, "surf" }, + }; + + +The result will be a little button that says "surf" at the top bar. When you click it, it launches surf. Have fun :D + +Download +-------- +* [dwm-launchers-20200527-f09418b.diff](dwm-launchers-20200527-f09418b.diff) + +Author +------ +* [Adham Zahran](mailto:adhamzahranfms@gmail.com) +