sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 0710dfbec92581a81fc0052829c9081e1826dff8
parent 3e81b6a859ddacacf5988444d0fbfa347a4d8c7e
Author: elbachir-one <bachiralfa@gmail.com>
Date:   Fri, 24 Jan 2025 04:54:54 +0100

[dwm][patches][togglebar] Added patch

Toggle the bar visibility on any monitor

Diffstat:
Adwm.suckless.org/patches/togglebar/dwm-togglebar-20250124-15e8116.diff | 115+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adwm.suckless.org/patches/togglebar/index.md | 31+++++++++++++++++++++++++++++++
2 files changed, 146 insertions(+), 0 deletions(-)

diff --git a/dwm.suckless.org/patches/togglebar/dwm-togglebar-20250124-15e8116.diff b/dwm.suckless.org/patches/togglebar/dwm-togglebar-20250124-15e8116.diff @@ -0,0 +1,115 @@ +From 15e8116449d63e242c654f34632746b7b63fc737 Mon Sep 17 00:00:00 2001 +From: elbachir-one <bachiralfa@gmail.com> +Date: Fri, 24 Jan 2025 02:31:52 +0100 +Subject: [PATCH] Toggle the bar visibility on any monitor + +--- + config.def.h | 8 ++++++-- + dwm.c | 48 ++++++++++++++++++++++++++++++++++++++++++------ + 2 files changed, 48 insertions(+), 8 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 4412cb1..b01d5c9 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -5,6 +5,7 @@ static const unsigned int borderpx = 1; /* border pixel of windows */ + static const unsigned int snap = 32; /* snap pixel */ + static const int showbar = 1; /* 0 means no bar */ + static const int topbar = 1; /* 0 means bottom bar */ ++static int barstate = 1 | 2; /* the bar is on all monitors (1 and 2) */ + static const char *fonts[] = { "monospace:size=10" }; + static const char dmenufont[] = "monospace:size=10"; + static const char col_gray1[] = "#222222"; +@@ -64,11 +65,10 @@ static const 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_j, focusstack, {.i = +1 } }, + { MODKEY, XK_k, focusstack, {.i = -1 } }, + { MODKEY, XK_i, incnmaster, {.i = +1 } }, +- { MODKEY, XK_d, incnmaster, {.i = -1 } }, ++ { MODKEY, XK_o, incnmaster, {.i = -1 } }, + { MODKEY, XK_h, setmfact, {.f = -0.05} }, + { MODKEY, XK_l, setmfact, {.f = +0.05} }, + { MODKEY, XK_Return, zoom, {0} }, +@@ -85,6 +85,10 @@ static const Key keys[] = { + { MODKEY, XK_period, focusmon, {.i = +1 } }, + { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } }, + { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } }, ++ { MODKEY, XK_a, togglebar, {.ui = 0} }, ++ { MODKEY, XK_b, togglebar, {.ui = 1} }, ++ { MODKEY, XK_c, togglebar, {.ui = 2} }, ++ { MODKEY, XK_d, togglebar, {.ui = 4} }, + TAGKEYS( XK_1, 0) + TAGKEYS( XK_2, 1) + TAGKEYS( XK_3, 2) +diff --git a/dwm.c b/dwm.c +index 1443802..2127dae 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -24,6 +24,7 @@ + #include <locale.h> + #include <signal.h> + #include <stdarg.h> ++#include <stdbool.h> + #include <stdio.h> + #include <stdlib.h> + #include <string.h> +@@ -1712,12 +1713,47 @@ tile(Monitor *m) + } + + void +-togglebar(const Arg *arg) +-{ +- selmon->showbar = !selmon->showbar; +- updatebarpos(selmon); +- XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); +- arrange(selmon); ++togglebar(const Arg *arg) { ++ Monitor *m; ++ ++ switch (arg->ui) { ++ case 0: ++ barstate = 0; ++ break; ++ case 1: ++ barstate = 1; ++ break; ++ case 2: ++ barstate = 2; ++ break; ++ case 4: ++ barstate = 1 | 2; ++ break; ++ default: ++ barstate = (barstate == 0) ? (1 | 2) : 0; ++ break; ++ } ++ ++ for (m = mons; m; m = m->next) { ++ if (barstate & 1 && m == mons) { ++ m->showbar = 1; ++ } else if (m == mons) { ++ m->showbar = 0; ++ } ++ ++ if (barstate & 2 && m != mons) { ++ m->showbar = 1; ++ } else if (m != mons) { ++ m->showbar = 0; ++ } ++ ++ updatebarpos(m); ++ if (m->barwin) { ++ XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh); ++ } ++ } ++ ++ arrange(NULL); + } + + void +-- +2.48.1 + diff --git a/dwm.suckless.org/patches/togglebar/index.md b/dwm.suckless.org/patches/togglebar/index.md @@ -0,0 +1,31 @@ +togglebar +========= + +Description +----------- + +The **ToggleBar** patch for the Dynamic Window Manager (dwm) introduces +a powerful way to streamline your workflow. It enables you to show or hide the +dwm bar on any monitor with simple hotkeys. + +##### Notes + +**1. Default Keybindings:** + +* `Mode + a`: Hides all bars (value = 0). +* `Mode + b`: Displays the bar on monitor one (value = 1). +* `Mode + c`: Displays the bar on monitor two (value = 2). +* `Mode + d`: Displays the bar on all monitors (default behavior). + +**2. Customizing Defaults:** + +You can modify the default behavior by changing the values in the `config.def.h` +file. The default values are set to 1 and 2. + +Download +-------- +* [dwm-togglebar-20250124-15e8116.diff](dwm-togglebar-20250124-15e8116.diff) (2025-01-24) + +Author +------ +* [El Bachir](https://github.com/elbachir-one)