diff options
author | Josh <eeei3.joshua0307lol@gmail.com> | 2024-12-21 19:10:56 -0500 |
---|---|---|
committer | Josh <eeei3.joshua0307lol@gmail.com> | 2024-12-21 19:10:56 -0500 |
commit | ac503169ed2ee1006377a53623bce8335cea90ff (patch) | |
tree | e4dfca4e1b8da1bd5bfa914e7826e2c1bab44ece | |
parent | cfb8627a80a334f200f68c2c8f3e384313ebbaf5 (diff) |
upgraded old version to 6.5
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | config.def.h | 104 | ||||
-rw-r--r-- | dwm.c | 194 | ||||
-rw-r--r-- | shiftview.c | 19 |
4 files changed, 287 insertions, 33 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8a283f2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +config.h +*.o +dwm diff --git a/config.def.h b/config.def.h index 9efa774..09abf77 100644 --- a/config.def.h +++ b/config.def.h @@ -1,17 +1,23 @@ /* See LICENSE file for copyright and license details. */ - /* appearance */ -static const unsigned int borderpx = 1; /* border pixel of windows */ -static const unsigned int snap = 32; /* snap pixel */ +static const unsigned int borderpx = 9; /* border pixel size of windows */ +static const unsigned int gappx = 15; /* gaps size between windows */ +static const unsigned int snap = 100; /* snap pixel */ static const int showbar = 1; /* 0 means no bar */ static const int topbar = 1; /* 0 means bottom bar */ -static const char *fonts[] = { "monospace:size=10" }; -static const char dmenufont[] = "monospace:size=10"; +static const int focusonwheel = 0; +static const char *fonts[] = { "monospace:size=25", "fontawesome:size=25" }; +static const char dmenufont[] = "monospace:size=25"; +//background color static const char col_gray1[] = "#222222"; +//inactive window border color static const char col_gray2[] = "#444444"; +//font color static const char col_gray3[] = "#bbbbbb"; +//current tag and current window font color static const char col_gray4[] = "#eeeeee"; -static const char col_cyan[] = "#005577"; +//Top bar second color (blue) and active window border color +static const char col_cyan[] = "#ffae00"; static const char *colors[][3] = { /* fg bg border */ [SchemeNorm] = { col_gray3, col_gray1, col_gray2 }, @@ -19,7 +25,8 @@ static const char *colors[][3] = { }; /* tagging */ -static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" }; +//tag names (upper left) +static const char *tags[] = { "", "2", "", "", "", "", "", " 1", " 2", " 3" }; static const Rule rules[] = { /* xprop(1): @@ -27,8 +34,14 @@ static const Rule rules[] = { * WM_NAME(STRING) = title */ /* class instance title tags mask isfloating monitor */ - { "Gimp", NULL, NULL, 0, 1, -1 }, - { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, + { "Gimp", NULL, NULL, 0, 0, -1 }, + { "firefox", NULL, "Picture-in-Picture", ~0, 1, -1 }, + { "firefox", NULL, "Library", 0, 1, -1 }, + { "thunderbird", "Mail", NULL, 1<<4, 0, -1 }, + { "discord", "discord",NULL, 1<<6, 0, -1 }, + { "spectacle", NULL, NULL, 0, 1, -1 }, + { "Steam", NULL, NULL, 0, 1, -1 }, + { "kitty", "kitty", NULL, 1<<5, 0, -1 }, }; /* layout(s) */ @@ -45,12 +58,16 @@ static const Layout layouts[] = { }; /* key definitions */ -#define MODKEY Mod1Mask +#define MODKEY Mod4Mask +#define ALTMOD Mod1Mask #define TAGKEYS(KEY,TAG) \ { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ - { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, + { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, \ + { ALTMOD, KEY, focusnthmon, {.i = TAG} }, \ + { ALTMOD|ShiftMask, KEY, tagnthmon, {.i = TAG} }, + /* helper for spawning shell commands in the pre dwm-5.0 fashion */ #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } @@ -58,33 +75,65 @@ static const Layout layouts[] = { /* commands */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; -static const char *termcmd[] = { "st", NULL }; +//static const char *filemanager[] = { " +//launches btop +static const char *monitor[] = { "alacritty", "-e", "btop" }; +//sets st as the default terminal +//static const char *termcmd[] = { "st", NULL }; +static const char *termcmd[] = { "tabbed", "alacritty", "--embed", NULL }; +static const char scratchpadname[] = "scratchpad"; +static const char *scratchpadcmd[] = {"alacritty", "-t", scratchpadname, "-e", "nvim", NULL }; +//static const char *pulseecmd[] = { "pulseeffects", NULL }; +//volume controls +static const char *upvol[] = { "wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", "5%+", NULL }; +static const char *downvol[] = { "wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", "5%-", "&&", "wpctl", "set-mute", "@DEFAULT_AUDIO_SINK@", "0", NULL }; +static const char *mutevol[] = { "wpctl", "set-mute", "@DEFAULT_AUDIO_SINK@", "toggle", NULL }; +static const char *upbright[] = {"/home/josh/dwm/bright.sh", "+", NULL}; +static const char *downbright[] = {"/home/josh/dwm/bright.sh", "-", NULL}; -static const Key keys[] = { +#include "shiftview.c" +#include <X11/XF86keysym.h> +static char *endx[] = { "/bin/sh", "-c", "endx", "externalpipe", NULL }; +static Key keys[] = { /* modifier key function argument */ - { MODKEY, XK_p, spawn, {.v = dmenucmd } }, - { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, - { MODKEY, XK_b, togglebar, {0} }, + { MODKEY, XK_d, spawn, {.v = dmenucmd } }, + { MODKEY, XK_Return, spawn, {.v = termcmd } }, + { MODKEY|ShiftMask, XK_Tab, spawn, {.v = monitor } }, + { MODKEY, XK_t, togglebar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } }, { MODKEY, XK_i, incnmaster, {.i = +1 } }, - { MODKEY, XK_d, incnmaster, {.i = -1 } }, + { MODKEY, XK_u, incnmaster, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, - { MODKEY, XK_Return, zoom, {0} }, + { MODKEY, XK_z, zoom, {0} }, { MODKEY, XK_Tab, view, {0} }, - { MODKEY|ShiftMask, XK_c, killclient, {0} }, - { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, - { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, - { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, - { MODKEY, XK_space, setlayout, {0} }, + { MODKEY, XK_q, killclient, {0} }, + { MODKEY|ShiftMask, XK_t, setlayout, {.v = &layouts[0]} }, + { MODKEY|ShiftMask, XK_f, setlayout, {.v = &layouts[1]} }, + { MODKEY|ShiftMask, XK_m, setlayout, {.v = &layouts[2]} }, + { MODKEY|ShiftMask, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, - { MODKEY, XK_0, view, {.ui = ~0 } }, - { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, + //{ MODKEY, XK_0, view, {.ui = ~0 } }, + { MODKEY|ShiftMask, XK_w, tag, {.ui = ~0 } }, { MODKEY, XK_comma, focusmon, {.i = -1 } }, { MODKEY, XK_period, focusmon, {.i = +1 } }, + { MODKEY, XK_minus, setgaps, {.i = -1 } }, + { MODKEY, XK_equal, setgaps, {.i = +1 } }, + { MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } }, { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, + { MODKEY, XK_n, shiftview, { .i = +1 } }, + { MODKEY, XK_b, shiftview, { .i = -1 } }, + { MODKEY, XK_F3, spawn, {.v = upvol } }, + { 0, XF86XK_AudioMute, spawn, {.v = mutevol} }, + { MODKEY, XK_F2, spawn, {.v = downvol } }, + { 0, XF86XK_AudioRaiseVolume, spawn, {.v = upvol}}, + { MODKEY, XK_F1, spawn, {.v = mutevol } }, + { 0, XF86XK_AudioLowerVolume, spawn, {.v = downvol}}, + { MODKEY, XK_grave, togglescratch, {.v=scratchpadcmd } }, + { 0, XF86XK_MonBrightnessUp, spawn, {.v = upbright}}, + { 0, XF86XK_MonBrightnessDown, spawn, {.v = downbright}}, TAGKEYS( XK_1, 0) TAGKEYS( XK_2, 1) TAGKEYS( XK_3, 2) @@ -94,12 +143,13 @@ static const Key keys[] = { TAGKEYS( XK_7, 6) TAGKEYS( XK_8, 7) TAGKEYS( XK_9, 8) - { MODKEY|ShiftMask, XK_q, quit, {0} }, + TAGKEYS( XK_0, 9) + { MODKEY|ShiftMask, XK_q, quitprompt, {0} }, }; /* button definitions */ /* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ -static const Button buttons[] = { +static Button buttons[] = { /* click event mask button function argument */ { ClkLtSymbol, 0, Button1, setlayout, {0} }, { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} }, @@ -40,6 +40,7 @@ #include <X11/extensions/Xinerama.h> #endif /* XINERAMA */ #include <X11/Xft/Xft.h> +#include <X11/XF86keysym.h> #include "drw.h" #include "util.h" @@ -110,6 +111,8 @@ typedef struct { void (*arrange)(Monitor *); } Layout; +typedef struct Pertag Pertag; + struct Monitor { char ltsymbol[16]; float mfact; @@ -118,6 +121,7 @@ struct Monitor { int by; /* bar geometry */ int mx, my, mw, mh; /* screen size */ int wx, wy, ww, wh; /* window area */ + int gappx; /* gaps between windows */ unsigned int seltags; unsigned int sellt; unsigned int tagset[2]; @@ -129,6 +133,7 @@ struct Monitor { Monitor *next; Window barwin; const Layout *lt[2]; + Pertag *pertag; }; typedef struct { @@ -160,6 +165,7 @@ static void destroynotify(XEvent *e); static void detach(Client *c); static void detachstack(Client *c); static Monitor *dirtomon(int dir); +static Monitor *numtomon(int num); static void drawbar(Monitor *m); static void drawbars(void); static void enternotify(XEvent *e); @@ -167,6 +173,7 @@ static void expose(XEvent *e); static void focus(Client *c); static void focusin(XEvent *e); static void focusmon(const Arg *arg); +static void focusnthmon(const Arg *arg); static void focusstack(const Arg *arg); static Atom getatomprop(Client *c, Atom prop); static int getrootptr(int *x, int *y); @@ -187,6 +194,7 @@ static Client *nexttiled(Client *c); static void pop(Client *c); static void propertynotify(XEvent *e); static void quit(const Arg *arg); +static void quitprompt(const Arg * arg); static Monitor *recttomon(int x, int y, int w, int h); static void resize(Client *c, int x, int y, int w, int h, int interact); static void resizeclient(Client *c, int x, int y, int w, int h); @@ -199,6 +207,7 @@ 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 setgaps(const Arg *arg); static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); @@ -207,9 +216,11 @@ static void showhide(Client *c); static void spawn(const Arg *arg); static void tag(const Arg *arg); static void tagmon(const Arg *arg); +static void tagnthmon(const Arg *arg); static void tile(Monitor *m); static void togglebar(const Arg *arg); static void togglefloating(const Arg *arg); +static void togglescratch(const Arg *arg); static void toggletag(const Arg *arg); static void toggleview(const Arg *arg); static void unfocus(Client *c, int setfocus); @@ -260,6 +271,7 @@ static void (*handler[LASTEvent]) (XEvent *) = { }; static Atom wmatom[WMLast], netatom[NetLast]; static int running = 1; +static int restart = 1; static Cur *cursor[CurLast]; static Clr **scheme; static Display *dpy; @@ -269,6 +281,19 @@ static Window root, wmcheckwin; /* configuration, allows nested code to access above variables */ #include "config.h" +struct Pertag { + unsigned int curtag, prevtag; + int nmasters[LENGTH(tags) + 1]; + float mfacts[LENGTH(tags) + 1]; + unsigned int sellts[LENGTH(tags) + 1]; + const Layout *ltidxs[LENGTH(tags) + 1][2]; + int showbars[LENGTH(tags) + 1]; + +}; + + + +static unsigned int scratchtag = 1 << LENGTH(tags); /* compile-time check if all tags fit into an unsigned int bit array. */ struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; @@ -633,6 +658,7 @@ Monitor * createmon(void) { Monitor *m; + unsigned int i; m = ecalloc(1, sizeof(Monitor)); m->tagset[0] = m->tagset[1] = 1; @@ -640,9 +666,23 @@ createmon(void) m->nmaster = nmaster; m->showbar = showbar; m->topbar = topbar; + m->gappx = gappx; m->lt[0] = &layouts[0]; m->lt[1] = &layouts[1 % LENGTH(layouts)]; strncpy(m->ltsymbol, layouts[0].symbol, sizeof m->ltsymbol); + m->pertag = ecalloc(1, sizeof(Pertag)); + m->pertag->curtag = m->pertag->prevtag = 1; + + for ( i = 0; i <= LENGTH(tags); i ++) { + m->pertag->nmasters[i] = m->nmaster; + m->pertag->mfacts[i] = m->mfact; + + m->pertag->ltidxs[i][0] = m->lt[0]; + m->pertag->ltidxs[i][1] = m->lt[1]; + m->pertag->sellts[i] = m->sellt; + + m->pertag->showbars[i] = m->showbar; + } return m; } @@ -678,6 +718,17 @@ detachstack(Client *c) c->mon->sel = t; } } +Monitor * +numtomon(int num) +{ + Monitor *m = NULL; + int i = 0; + + for(m = mons, i=0; m->next && i < num; m = m->next){ + i++; + } + return m; +} Monitor * dirtomon(int dir) @@ -835,6 +886,19 @@ focusmon(const Arg *arg) } void +focusnthmon(const Arg *arg) +{ + Monitor *m; + if(!mons->next) + return; + if((m = numtomon(arg->i)) == selmon) + return; + unfocus(selmon->sel, 0); + selmon = m; + focus(NULL); +} + +void focusstack(const Arg *arg) { Client *c = NULL, *i; @@ -860,6 +924,14 @@ focusstack(const Arg *arg) } } +void +tagnthmon(const Arg *arg) +{ + if (!selmon->sel || !mons->next) + return; + sendmon(selmon->sel, numtomon(arg->i)); +} + Atom getatomprop(Client *c, Atom prop) { @@ -979,7 +1051,7 @@ grabkeys(void) void incnmaster(const Arg *arg) { - selmon->nmaster = MAX(selmon->nmaster + arg->i, 0); + selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag] = MAX(selmon->nmaster + arg->i, 0); arrange(selmon); } @@ -1060,6 +1132,15 @@ manage(Window w, XWindowAttributes *wa) c->y = MAX(c->y, c->mon->wy); c->bw = borderpx; + selmon->tagset[selmon->seltags] &= ~scratchtag; + if (!strcmp(c->name, scratchpadname)) { + c->mon->tagset[c->mon->seltags] |= c->tags = scratchtag; + c->isfloating = True; + c->x = c->mon->wx + (c->mon->ww / 2 - WIDTH(c) / 2); + c->y = c->mon->wy + (c->mon->wh / 2 - HEIGHT(c) / 2); + + } + wc.border_width = c->bw; XConfigureWindow(dpy, w, CWBorderWidth, &wc); XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel); @@ -1201,6 +1282,31 @@ movemouse(const Arg *arg) } } +void +quitprompt(const Arg *arg) +{ + FILE *pp = popen("echo -e \"no\nrestart\nyes\" | dmenu -i -sb red -fn monospace:size=25 -p \"Quit DWM?\"", "r"); + if (pp != NULL) { + char buf[1024]; + if (fgets(buf, sizeof(buf), pp) == NULL) { + fprintf(stderr, "Quitprompt: Error reading pipe!\n"); + return; + } + if (strcmp(buf, "yes\n") == 0) { + pclose(pp); + restart = 0; + quit(NULL); + } else if (strcmp(buf, "restart\n") == 0) { + pclose(pp); + restart = 1; + quit(NULL); + } else if (strcmp(buf, "no\n") == 0) { + pclose(pp); + return; + } + } +} + Client * nexttiled(Client *c) { @@ -1282,6 +1388,16 @@ resize(Client *c, int x, int y, int w, int h, int interact) } void +setgaps(const Arg *arg) +{ + if ((arg->i == 0) || (selmon->gappx + arg->i < 0)) + selmon->gappx = 0; + else + selmon->gappx += arg->i; + arrange(selmon); +} + +void resizeclient(Client *c, int x, int y, int w, int h) { XWindowChanges wc; @@ -1510,9 +1626,9 @@ void setlayout(const Arg *arg) { if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) - selmon->sellt ^= 1; + selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag] ^= 1; if (arg && arg->v) - selmon->lt[selmon->sellt] = (Layout *)arg->v; + selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] = (Layout *)arg->v; strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol); if (selmon->sel) arrange(selmon); @@ -1531,7 +1647,7 @@ setmfact(const Arg *arg) f = arg->f < 1.0 ? arg->f + selmon->mfact : arg->f - 1.0; if (f < 0.05 || f > 0.95) return; - selmon->mfact = f; + selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag] = f; arrange(selmon); } @@ -1650,6 +1766,7 @@ spawn(const Arg *arg) if (arg->v == dmenucmd) dmenumon[0] = '0' + selmon->num; + selmon->tagset[selmon->seltags] &= ~scratchtag; if (fork() == 0) { if (dpy) close(ConnectionNumber(dpy)); @@ -1714,7 +1831,7 @@ tile(Monitor *m) void togglebar(const Arg *arg) { - selmon->showbar = !selmon->showbar; + selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar; updatebarpos(selmon); XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); arrange(selmon); @@ -1735,6 +1852,28 @@ togglefloating(const Arg *arg) } void +togglescratch(const Arg *arg) +{ + Client *c; + unsigned int found = 0; + + for (c = selmon->clients; c && !(found = c->tags & scratchtag); c = c->next); + if (found) { + unsigned int newtagset = selmon->tagset[selmon->seltags] ^ scratchtag; + if (newtagset) { + selmon->tagset[selmon->seltags] = newtagset; + focus(NULL); + arrange(selmon); + } + if (ISVISIBLE(c)) { + focus(c); + restack(selmon); + } + } else + spawn(arg); +} + +void toggletag(const Arg *arg) { unsigned int newtags; @@ -1753,9 +1892,28 @@ void toggleview(const Arg *arg) { unsigned int newtagset = selmon->tagset[selmon->seltags] ^ (arg->ui & TAGMASK); + int i; if (newtagset) { selmon->tagset[selmon->seltags] = newtagset; + if (newtagset == ~0) { + selmon->pertag->prevtag = selmon->pertag->curtag; + selmon->pertag->curtag = 0; + } + + if (!(newtagset & 1 << (selmon->pertag->curtag-1))) { + selmon->pertag->prevtag = selmon->pertag->curtag; + for (i = 0; !(newtagset & 1 << i); i++) ; + selmon->pertag->curtag = i + 1; + } + selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag]; + selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag]; + selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag]; + selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt]; + selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1]; + + if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag]) + togglebar(NULL); focus(NULL); arrange(selmon); } @@ -2052,11 +2210,32 @@ updatewmhints(Client *c) void view(const Arg *arg) { + int i; + unsigned int tmptag; if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) return; selmon->seltags ^= 1; /* toggle sel tagset */ - if (arg->ui & TAGMASK) + if (arg->ui & TAGMASK) { selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; + selmon->pertag->prevtag = selmon->pertag->curtag; + if (arg->ui == ~0) + selmon->pertag->curtag = 0; + else { + for (i = 0; !(arg->ui & 1 << i); i++) ; + selmon->pertag->curtag = i + 1; + } + } else { + tmptag = selmon->pertag->prevtag; + selmon->pertag->prevtag = selmon->pertag->curtag; + selmon->pertag->curtag = tmptag; + } + selmon->nmaster = selmon->pertag->nmasters[selmon->pertag->curtag]; + selmon->mfact = selmon->pertag->mfacts[selmon->pertag->curtag]; + selmon->sellt = selmon->pertag->sellts[selmon->pertag->curtag]; + selmon->lt[selmon->sellt] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt]; + selmon->lt[selmon->sellt^1] = selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt^1]; + if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag]) + togglebar(NULL); focus(NULL); arrange(selmon); } @@ -2160,5 +2339,8 @@ main(int argc, char *argv[]) run(); cleanup(); XCloseDisplay(dpy); + if (restart == 1) { + execlp("dwm", "dwm", NULL); + } return EXIT_SUCCESS; } diff --git a/shiftview.c b/shiftview.c new file mode 100644 index 0000000..e82053a --- /dev/null +++ b/shiftview.c @@ -0,0 +1,19 @@ +/** Function to shift the current view to the left/right + * + * @param: "arg->i" stores the number of tags to shift right (positive value) + * or left (negative value) + */ +void +shiftview(const Arg *arg) { + Arg shifted; + + if(arg->i > 0) // left circular shift + shifted.ui = (selmon->tagset[selmon->seltags] << arg->i) + | (selmon->tagset[selmon->seltags] >> (LENGTH(tags) - arg->i)); + + else // right circular shift + shifted.ui = selmon->tagset[selmon->seltags] >> (- arg->i) + | selmon->tagset[selmon->seltags] << (LENGTH(tags) + arg->i); + + view(&shifted); +} |