Add viewtoleft and viewtoright

This commit is contained in:
Alex Selimov 2025-06-27 22:24:45 -04:00
parent 7e42ab3f4f
commit e9f05098d8
3 changed files with 55 additions and 31 deletions

View File

@ -19,7 +19,7 @@ static int smartgaps =
static const int showbar = 1; /* 0 means no bar */ static const int showbar = 1; /* 0 means no bar */
static const int topbar = 1; /* 0 means bottom bar */ static const int topbar = 1; /* 0 means bottom bar */
static const char *fonts[] = { 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[] = static const char dmenufont[] =
"SauceCodePro Nerd Font:size=10:antialias=true:autohint=true"; "SauceCodePro Nerd Font:size=10:antialias=true:autohint=true";
static const char col_gray1[] = "#191919"; static const char col_gray1[] = "#191919";
@ -37,7 +37,7 @@ static const unsigned int borderalpha = OPAQUE;
static const char *colors[][3] = { static const char *colors[][3] = {
/* fg bg border */ /* fg bg border */
[SchemeNorm] = {col_gray3, col_gray1, col_gray1}, [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}, [SchemeStatus] = {col_gray3, col_gray1, col_gray1},
[SchemeTagsSel] = {col_gray3, col_gray1, col_gray1}, [SchemeTagsSel] = {col_gray3, col_gray1, col_gray1},
// Tagbar left unselected {text,background,not used but cannot be empty} // 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}}; [SchemeUrgent] = {OPAQUE, baralpha, borderalpha}};
/* tagging */ /* tagging */
static const char *tags[] = {"", "", "", "", "", ""}; static const char *tags[] = {
static const char *alttags[] = {"", "", "", "", "", ""}; "", "", "", "", "",
};
static const char *alttags[] = {
"", "", "", "", "",
};
static const Rule rules[] = { static const Rule rules[] = {
/* xprop(1): /* xprop(1):
@ -74,7 +78,6 @@ static const Rule rules[] = {
/* class instance title tags mask isfloating isterminal /* class instance title tags mask isfloating isterminal
noswallow, monitor */ noswallow, monitor */
{"Gimp", NULL, NULL, 0, 1, 0, 0, -1}, {"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}, {"mpv", NULL, NULL, 0, 1, 0, 0, -1},
{"sxiv", NULL, NULL, 0, 1, 0, 1, -1}, {"sxiv", NULL, NULL, 0, 1, 0, 1, -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}, {"Python3", NULL, NULL, 0, 1, 0, 1, -1},
//{ "" , NULL , NULL , 0 , 1 , 0 , 1 , -1 } , //{ "" , NULL , NULL , 0 , 1 , 0 , 1 , -1 } ,
{"St", NULL, NULL, 0, 0, 1, 0, -1}, {"St", NULL, NULL, 0, 0, 1, 0, -1},
{"Firefox", NULL, NULL, 1 << 5, 0, 0, 0, -1}, {"Firefox", NULL, NULL, 1 << 4, 0, 0, 0, -1},
{"Navigator", NULL, NULL, 1 << 5, 0, 0, 0, -1}, {"Navigator", NULL, NULL, 1 << 4, 0, 0, 0, -1},
{"zen", NULL, NULL, 1 << 5, 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},
{"Dragon", NULL, NULL, 0, 1, 0, 1, -1}, {"Dragon", NULL, NULL, 0, 1, 0, 1, -1},
{"zbar", 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 */ /* key definitions */
#define MODKEY Mod4Mask #define MODKEY Mod1Mask
#define TAGKEYS(KEY, TAG) \ #define TAGKEYS(KEY, TAG) \
{MODKEY, KEY, view, {.ui = 1 << TAG}}, \ {MODKEY, KEY, view, {.ui = 1 << TAG}}, \
{MODKEY | ControlMask, KEY, toggleview, {.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_k, focusstack, {.i = -1}},
{MODKEY, XK_i, incnmaster, {.i = +1}}, {MODKEY, XK_i, incnmaster, {.i = +1}},
{MODKEY, XK_d, incnmaster, {.i = -1}}, {MODKEY, XK_d, incnmaster, {.i = -1}},
{MODKEY, XK_h, setmfact, {.f = -0.05}}, {MODKEY | ShiftMask, XK_h, setmfact, {.f = -0.05}},
{MODKEY, XK_l, 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_Return, zoom, {0}},
{MODKEY, XK_Tab, view, {0}}, {MODKEY, XK_Tab, view, {0}},
{MODKEY | ShiftMask, XK_c, killclient, {0}}, {MODKEY | ShiftMask, XK_c, killclient, {0}},

22
dwm.c
View File

@ -291,6 +291,8 @@ static void updatetitle(Client *c);
static void updatewindowtype(Client *c); static void updatewindowtype(Client *c);
static void updatewmhints(Client *c); static void updatewmhints(Client *c);
static void view(const Arg *arg); 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 void warp(const Client *c);
static Client *wintoclient(Window w); static Client *wintoclient(Window w);
static Monitor *wintomon(Window w); static Monitor *wintomon(Window w);
@ -2333,6 +2335,26 @@ void view(const Arg *arg) {
arrange(selmon); 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) { void warp(const Client *c) {
int x, y; int x, y;

7
util.c
View File

@ -6,9 +6,7 @@
#include "util.h" #include "util.h"
void * void *ecalloc(size_t nmemb, size_t size) {
ecalloc(size_t nmemb, size_t size)
{
void *p; void *p;
if (!(p = calloc(nmemb, size))) if (!(p = calloc(nmemb, size)))
@ -16,8 +14,7 @@ ecalloc(size_t nmemb, size_t size)
return p; return p;
} }
void void die(const char *fmt, ...) {
die(const char *fmt, ...) {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);