Introduction
Introduction Statistics Contact Development Disclaimer Help
dwm-togglebar-20250124-15e8116.diff - sites - public wiki contents of suckless.…
git clone git://git.suckless.org/sites
Log
Files
Refs
---
dwm-togglebar-20250124-15e8116.diff (3954B)
---
1 From 15e8116449d63e242c654f34632746b7b63fc737 Mon Sep 17 00:00:00 2001
2 From: elbachir-one <[email protected]>
3 Date: Fri, 24 Jan 2025 02:31:52 +0100
4 Subject: [PATCH] Toggle the bar visibility on any monitor
5
6 ---
7 config.def.h | 8 ++++++--
8 dwm.c | 48 ++++++++++++++++++++++++++++++++++++++++++------
9 2 files changed, 48 insertions(+), 8 deletions(-)
10
11 diff --git a/config.def.h b/config.def.h
12 index 4412cb1..b01d5c9 100644
13 --- a/config.def.h
14 +++ b/config.def.h
15 @@ -5,6 +5,7 @@ static const unsigned int borderpx = 1; /* borde…
16 static const unsigned int snap = 32; /* snap pixel */
17 static const int showbar = 1; /* 0 means no bar */
18 static const int topbar = 1; /* 0 means bottom bar */
19 +static int barstate = 1 | 2; /* the bar is on all mo…
20 static const char *fonts[] = { "monospace:size=10" };
21 static const char dmenufont[] = "monospace:size=10";
22 static const char col_gray1[] = "#222222";
23 @@ -64,11 +65,10 @@ static const Key keys[] = {
24 /* modifier key function argu…
25 { MODKEY, XK_p, spawn, {.v …
26 { MODKEY|ShiftMask, XK_Return, spawn, {.v …
27 - { MODKEY, XK_b, togglebar, {0} …
28 { MODKEY, XK_j, focusstack, {.i …
29 { MODKEY, XK_k, focusstack, {.i …
30 { MODKEY, XK_i, incnmaster, {.i …
31 - { MODKEY, XK_d, incnmaster, {.i …
32 + { MODKEY, XK_o, incnmaster, {.i …
33 { MODKEY, XK_h, setmfact, {.f …
34 { MODKEY, XK_l, setmfact, {.f …
35 { MODKEY, XK_Return, zoom, {0} …
36 @@ -85,6 +85,10 @@ static const Key keys[] = {
37 { MODKEY, XK_period, focusmon, {.i …
38 { MODKEY|ShiftMask, XK_comma, tagmon, {.i …
39 { MODKEY|ShiftMask, XK_period, tagmon, {.i …
40 + { MODKEY, XK_a, togglebar, {.ui…
41 + { MODKEY, XK_b, togglebar, {.ui…
42 + { MODKEY, XK_c, togglebar, {.ui…
43 + { MODKEY, XK_d, togglebar, {.ui…
44 TAGKEYS( XK_1, 0)
45 TAGKEYS( XK_2, 1)
46 TAGKEYS( XK_3, 2)
47 diff --git a/dwm.c b/dwm.c
48 index 1443802..2127dae 100644
49 --- a/dwm.c
50 +++ b/dwm.c
51 @@ -24,6 +24,7 @@
52 #include <locale.h>
53 #include <signal.h>
54 #include <stdarg.h>
55 +#include <stdbool.h>
56 #include <stdio.h>
57 #include <stdlib.h>
58 #include <string.h>
59 @@ -1712,12 +1713,47 @@ tile(Monitor *m)
60 }
61
62 void
63 -togglebar(const Arg *arg)
64 -{
65 - selmon->showbar = !selmon->showbar;
66 - updatebarpos(selmon);
67 - XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, …
68 - arrange(selmon);
69 +togglebar(const Arg *arg) {
70 + Monitor *m;
71 +
72 + switch (arg->ui) {
73 + case 0:
74 + barstate = 0;
75 + break;
76 + case 1:
77 + barstate = 1;
78 + break;
79 + case 2:
80 + barstate = 2;
81 + break;
82 + case 4:
83 + barstate = 1 | 2;
84 + break;
85 + default:
86 + barstate = (barstate == 0) ? (1 | 2) : 0;
87 + break;
88 + }
89 +
90 + for (m = mons; m; m = m->next) {
91 + if (barstate & 1 && m == mons) {
92 + m->showbar = 1;
93 + } else if (m == mons) {
94 + m->showbar = 0;
95 + }
96 +
97 + if (barstate & 2 && m != mons) {
98 + m->showbar = 1;
99 + } else if (m != mons) {
100 + m->showbar = 0;
101 + }
102 +
103 + updatebarpos(m);
104 + if (m->barwin) {
105 + XMoveResizeWindow(dpy, m->barwin, m->wx, m->by,…
106 + }
107 + }
108 +
109 + arrange(NULL);
110 }
111
112 void
113 --
114 2.48.1
115
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.