From aefae1c570d90cec187291781563b17acd4bed32 Mon Sep 17 00:00:00 2001 From: Dita Aji Pratama Date: Tue, 24 Dec 2024 10:38:32 +0700 Subject: [PATCH] Update aji.c for cyclelayout and custom shift-tools --- aji.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ config.h | 2 +- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 aji.c diff --git a/aji.c b/aji.c new file mode 100644 index 0000000..84181df --- /dev/null +++ b/aji.c @@ -0,0 +1,54 @@ +void +cyclelayout(const Arg *arg) { + Layout *next; + for (next = (Layout *)layouts; next != selmon->lt[selmon->sellt]; next++); + if ((++next - layouts) >= LENGTH(layouts)) + next = (Layout *)layouts; + setlayout(&(Arg) { .v = next }); +} + +/** 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 +shifttag(const Arg *arg) { + if(selmon->sel){ + + 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); + + selmon->sel->tags = shifted.ui & TAGMASK; + arrange(selmon); + view(&shifted); + } +} + +/** 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); +} diff --git a/config.h b/config.h index 1629a56..4d0dd10 100644 --- a/config.h +++ b/config.h @@ -102,7 +102,7 @@ static const char *nmcedit[] = { "nm-connection-editor" , NULL }; static const char *top[] = { "kitty" , "htop" , NULL }; -#include "shift-tools.c" +#include "aji.c" static const Key keys[] = { /* modifier key function argument */