From e9f05098d8bccc5a933309caf64870aa2ace0f23 Mon Sep 17 00:00:00 2001 From: Alex Selimov Date: Fri, 27 Jun 2025 22:24:45 -0400 Subject: [PATCH] Add viewtoleft and viewtoright --- config.h | 27 ++++++++++++++++----------- dwm.c | 22 ++++++++++++++++++++++ util.c | 37 +++++++++++++++++-------------------- 3 files changed, 55 insertions(+), 31 deletions(-) diff --git a/config.h b/config.h index e083b94..c05101f 100644 --- a/config.h +++ b/config.h @@ -19,7 +19,7 @@ static int smartgaps = static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ static const char *fonts[] = { - "DepartureMono Nerd Font:size=13:antialias=true:autohint=true"}; + "IosevkaTermSlab Nerd Font Propo:size=13:antialias=true:autohint=true"}; static const char dmenufont[] = "SauceCodePro Nerd Font:size=10:antialias=true:autohint=true"; static const char col_gray1[] = "#191919"; @@ -37,7 +37,7 @@ static const unsigned int borderalpha = OPAQUE; static const char *colors[][3] = { /* fg bg border */ [SchemeNorm] = {col_gray3, col_gray1, col_gray1}, - [SchemeSel] = {col_gray3, col_cyan, col_gray3}, + [SchemeSel] = {col_gray3, col_cyan, col_gray2}, [SchemeStatus] = {col_gray3, col_gray1, col_gray1}, [SchemeTagsSel] = {col_gray3, col_gray1, col_gray1}, // Tagbar left unselected {text,background,not used but cannot be empty} @@ -63,8 +63,12 @@ static const unsigned int alphas[][3] = { [SchemeUrgent] = {OPAQUE, baralpha, borderalpha}}; /* tagging */ -static const char *tags[] = {"", "", "", "", "", ""}; -static const char *alttags[] = {"", "", "", "", "", ""}; +static const char *tags[] = { + "", "", "", "", "", +}; +static const char *alttags[] = { + "", "", "", "", "", +}; static const Rule rules[] = { /* xprop(1): @@ -74,7 +78,6 @@ static const Rule rules[] = { /* class instance title tags mask isfloating isterminal noswallow, monitor */ {"Gimp", NULL, NULL, 0, 1, 0, 0, -1}, - {"Brave-browser", NULL, NULL, 0, 0, 0, 0, 1}, {"mpv", NULL, NULL, 0, 1, 0, 0, -1}, {"sxiv", NULL, NULL, 0, 1, 0, 1, -1}, {"Sxiv", NULL, NULL, 0, 1, 0, 1, -1}, @@ -96,9 +99,9 @@ static const Rule rules[] = { {"Python3", NULL, NULL, 0, 1, 0, 1, -1}, //{ "" , NULL , NULL , 0 , 1 , 0 , 1 , -1 } , {"St", NULL, NULL, 0, 0, 1, 0, -1}, - {"Firefox", NULL, NULL, 1 << 5, 0, 0, 0, -1}, - {"Navigator", NULL, NULL, 1 << 5, 0, 0, 0, -1}, - {"zen", NULL, NULL, 1 << 5, 0, 0, 0, -1}, + {"Firefox", NULL, NULL, 1 << 4, 0, 0, 0, -1}, + {"Navigator", NULL, NULL, 1 << 4, 0, 0, 0, -1}, + {"zen", NULL, NULL, 1 << 4, 0, 0, 0, -1}, {"dragon", NULL, NULL, 0, 1, 0, 1, -1}, {"Dragon", NULL, NULL, 0, 1, 0, 1, -1}, {"zbar", NULL, NULL, 0, 1, 0, 1, -1}, @@ -125,7 +128,7 @@ static const Layout layouts[] = { }; /* key definitions */ -#define MODKEY Mod4Mask +#define MODKEY Mod1Mask #define TAGKEYS(KEY, TAG) \ {MODKEY, KEY, view, {.ui = 1 << TAG}}, \ {MODKEY | ControlMask, KEY, toggleview, {.ui = 1 << TAG}}, \ @@ -157,8 +160,10 @@ static Key keys[] = { {MODKEY, XK_k, focusstack, {.i = -1}}, {MODKEY, XK_i, incnmaster, {.i = +1}}, {MODKEY, XK_d, incnmaster, {.i = -1}}, - {MODKEY, XK_h, setmfact, {.f = -0.05}}, - {MODKEY, XK_l, setmfact, {.f = +0.05}}, + {MODKEY | ShiftMask, XK_h, setmfact, {.f = -0.05}}, + {MODKEY | ShiftMask, XK_l, setmfact, {.f = +0.05}}, + {MODKEY, XK_h, viewtoleft, {0}}, + {MODKEY, XK_l, viewtoright, {0}}, {MODKEY, XK_Return, zoom, {0}}, {MODKEY, XK_Tab, view, {0}}, {MODKEY | ShiftMask, XK_c, killclient, {0}}, diff --git a/dwm.c b/dwm.c index b1caccc..02892b4 100644 --- a/dwm.c +++ b/dwm.c @@ -291,6 +291,8 @@ static void updatetitle(Client *c); static void updatewindowtype(Client *c); static void updatewmhints(Client *c); static void view(const Arg *arg); +static void viewtoleft(const Arg *arg); +static void viewtoright(const Arg *arg); static void warp(const Client *c); static Client *wintoclient(Window w); static Monitor *wintomon(Window w); @@ -2333,6 +2335,26 @@ void view(const Arg *arg) { arrange(selmon); } +void viewtoleft(const Arg *arg) { + if (__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 && + selmon->tagset[selmon->seltags] > 1) { + selmon->seltags ^= 1; /* toggle sel tagset */ + selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] >> 1; + focus(NULL); + arrange(selmon); + } +} + +void viewtoright(const Arg *arg) { + if (__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1 && + selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) { + selmon->seltags ^= 1; /* toggle sel tagset */ + selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] << 1; + focus(NULL); + arrange(selmon); + } +} + void warp(const Client *c) { int x, y; diff --git a/util.c b/util.c index fe044fc..aa43f69 100644 --- a/util.c +++ b/util.c @@ -6,30 +6,27 @@ #include "util.h" -void * -ecalloc(size_t nmemb, size_t size) -{ - void *p; +void *ecalloc(size_t nmemb, size_t size) { + void *p; - if (!(p = calloc(nmemb, size))) - die("calloc:"); - return p; + if (!(p = calloc(nmemb, size))) + die("calloc:"); + return p; } -void -die(const char *fmt, ...) { - va_list ap; +void die(const char *fmt, ...) { + va_list ap; - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); - if (fmt[0] && fmt[strlen(fmt)-1] == ':') { - fputc(' ', stderr); - perror(NULL); - } else { - fputc('\n', stderr); - } + if (fmt[0] && fmt[strlen(fmt) - 1] == ':') { + fputc(' ', stderr); + perror(NULL); + } else { + fputc('\n', stderr); + } - exit(1); + exit(1); }