From bf647ff2fdb11352ec0c6ccf04fa7bccfeb20e02 Mon Sep 17 00:00:00 2001 From: filip <“filip.rabiega@gmail.com”> Date: Fri, 10 Oct 2025 09:29:02 +0200 Subject: added a program launcher --- dwm.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'dwm.c') diff --git a/dwm.c b/dwm.c index 12d0838..9599373 100644 --- a/dwm.c +++ b/dwm.c @@ -208,12 +208,14 @@ static void sendmon(Client *c, Monitor *m); static void setclientstate(Client *c, long state); static void setfocus(Client *c); static void setfullscreen(Client *c, int fullscreen); +static void setlasttag(int tagbit); static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); static void seturgent(Client *c, int urg); static void showhide(Client *c); static void spawn(const Arg *arg); +static void spawndefault(); static void tag(const Arg *arg); static void tagmon(const Arg *arg); static void tile(Monitor *m); @@ -280,6 +282,9 @@ static Drw *drw; static Monitor *mons, *selmon; static Window root, wmcheckwin; +static int lastchosentag[8]; +static int previouschosentag[8]; + /* configuration, allows nested code to access above variables */ #include "config.h" @@ -1526,6 +1531,24 @@ setfullscreen(Client *c, int fullscreen) } } +void +setlasttag(int tagbit) { + const int mon = selmon->num; + if (tagbit > 0) { + int i = 1, pos = 0; + while (!(i & tagbit)) { + i = i << 1; + ++pos; + } + previouschosentag[mon] = lastchosentag[mon]; + lastchosentag[mon] = pos; + } else { + const int tempTag = lastchosentag[mon]; + lastchosentag[mon] = previouschosentag[mon]; + previouschosentag[mon] = tempTag; + } +} + void setlayout(const Arg *arg) { @@ -1890,6 +1913,17 @@ altTabStart(const Arg *arg) } } +void +spawndefault() +{ + const char *app = defaulttagapps[lastchosentag[selmon->num]]; + if (app) { + const char *defaultcmd[] = {app, NULL}; + Arg a = {.v = defaultcmd}; + spawn(&a); + } +} + void tag(const Arg *arg) { @@ -1990,6 +2024,7 @@ toggleview(const Arg *arg) if (newtagset) { selmon->tagset[selmon->seltags] = newtagset; + setlasttag(newtagset); focus(NULL); arrange(selmon); } @@ -2288,6 +2323,7 @@ view(const Arg *arg) { if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) return; + setlasttag(arg->ui); selmon->seltags ^= 1; /* toggle sel tagset */ if (arg->ui & TAGMASK) selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; -- cgit v1.2.3