diff --git a/config.def.h b/config.def.h index 0408b02..abc61df 100644 --- a/config.def.h +++ b/config.def.h @@ -514,6 +514,9 @@ static Signal signals[] = { { "toggleverticalexpand", toggleverticalexpand }, { "togglemaximize", togglemaximize }, #endif // EXRESIZE_PATCH + #if KEYMODES_PATCH + { "setkeymode", setkeymode }, + #endif // KEYMODES_PATCH #if TRANSFER_PATCH { "transfer", transfer }, #endif // TRANSFER_PATCH @@ -532,6 +535,7 @@ static Signal signals[] = { { "incrovgaps", incrovgaps }, { "togglegaps", togglegaps }, { "defaultgaps", defaultgaps }, + { "setgaps", setgapsex }, #endif // VANITYGAPS_PATCH { "view", view }, { "viewall", viewallex }, diff --git a/patch/dwmc b/patch/dwmc index 10ec990..3bfde22 100755 --- a/patch/dwmc +++ b/patch/dwmc @@ -47,7 +47,7 @@ case $# in signal $1 ;; *) - echo "Unknown command or missing one argument." + echo "Unknown command ($1) or missing one argument." exit 1 ;; esac @@ -58,6 +58,7 @@ case $# in explace) ;& moveplace) ;& mpdchange) ;& + setkeymode) ;& switchtag) ;& togglescratch) ;& view) @@ -70,6 +71,7 @@ case $# in tagex) ;& toggletagex) ;& setborderpx) ;& + setgaps) ;& setlayoutex) ;& setlayoutaxisex) ;& swapfocus) ;& @@ -99,13 +101,30 @@ case $# in signal $1 f $2 ;; *) - echo "Unknown command or one too many arguments." + echo "Unknown command ($1) or too many arguments" + exit 1 + ;; + esac + ;; +5) + case $1 in + setgaps) + # Expects "setgaps oh ov ih iv" where -1 means to keep existing values + [ $2 = -1 ] && oh=128 || oh=$2 + [ $3 = -1 ] && ov=128 || ov=$3 + [ $4 = -1 ] && ih=128 || ih=$4 + [ $5 = -1 ] && iv=128 || iv=$5 + echo $(((oh << 24) + (ov << 16) + (ih << 8) + iv)) + signal $1 i $(((oh << 24) + (ov << 16) + (ih << 8) + iv)) + ;; + *) + echo "Unknown command ($1) or too many arguments" exit 1 ;; esac ;; *) - echo "Too many arguments." + echo "Unknown command ($1) or too many arguments" exit 1 ;; esac diff --git a/patch/vanitygaps.c b/patch/vanitygaps.c index d1f0505..d8db675 100644 --- a/patch/vanitygaps.c +++ b/patch/vanitygaps.c @@ -18,6 +18,60 @@ setgaps(int oh, int ov, int ih, int iv) arrange(selmon); } +#if DWMC_PATCH +/* External function that takes one integer and splits it + * into four gap values: + * - outer horizontal (oh) + * - outer vertical (ov) + * - inner horizontal (ih) + * - inner vertical (iv) + * + * Each value is represented as one byte with the uppermost + * bit of each byte indicating whether or not to keep the + * current value. + * + * Example: + * + * 10000000 10000000 00001111 00001111 + * | | | | + * + keep oh + keep ov + ih 15px + iv 15px + * + * This gives an int of: + * 10000000100000000000111100001111 = 2155876111 + * + * Thus this command should set inner gaps to 15: + * xsetroot -name "fsignal:setgaps i 2155876111" + */ +static void +setgapsex(const Arg *arg) +{ + int oh = selmon->gappoh; + int ov = selmon->gappov; + int ih = selmon->gappih; + int iv = selmon->gappiv; + + if (!(arg->i & (1 << 31))) + oh = (arg->i & 0x7f000000) >> 24; + if (!(arg->i & (1 << 23))) + ov = (arg->i & 0x7f0000) >> 16; + if (!(arg->i & (1 << 15))) + ih = (arg->i & 0x7f00) >> 8; + if (!(arg->i & (1 << 7))) + iv = (arg->i & 0x7f); + + /* Auto enable gaps if disabled */ + #if PERTAG_PATCH + if (!selmon->pertag->enablegaps[selmon->pertag->curtag]) + selmon->pertag->enablegaps[selmon->pertag->curtag] = 1; + #else + if (!enablegaps) + enablegaps = 1; + #endif // PERTAG_PATCH + + setgaps(oh, ov, ih, iv); +} +#endif // DWMC_PATCH + static void togglegaps(const Arg *arg) { diff --git a/patch/vanitygaps.h b/patch/vanitygaps.h index 6c8d5cf..1c5f0d7 100644 --- a/patch/vanitygaps.h +++ b/patch/vanitygaps.h @@ -13,4 +13,7 @@ static void togglegaps(const Arg *arg); #if DRAGMFACT_PATCH || CENTEREDMASTER_LAYOUT || CENTEREDFLOATINGMASTER_LAYOUT || COLUMNS_LAYOUT || DECK_LAYOUT || FIBONACCI_DWINDLE_LAYOUT || FIBONACCI_SPIRAL_LAYOUT || GAPPLESSGRID_LAYOUT || NROWGRID_LAYOUT || HORIZGRID_LAYOUT || BSTACK_LAYOUT || BSTACKHORIZ_LAYOUT || GRIDMODE_LAYOUT || FLEXTILE_DELUXE_LAYOUT || TILE_LAYOUT || (VANITYGAPS_MONOCLE_PATCH && MONOCLE_LAYOUT) static void getgaps(Monitor *m, int *oh, int *ov, int *ih, int *iv, unsigned int *nc); #endif -static void setgaps(int oh, int ov, int ih, int iv); \ No newline at end of file +static void setgaps(int oh, int ov, int ih, int iv); +#if DWMC_PATCH +static void setgapsex(const Arg *arg); +#endif // DWMC_PATCH \ No newline at end of file