dwm-systray-toogle-6.2.diff (2465B)
1 From 727d0569a7bb7920887cb5b34707201ba72d1e76 Mon Sep 17 00:00:00 2001 2 From: Christopher Witt <github@ch-witt.de> 3 Date: Sat, 25 Apr 2020 21:37:15 +0200 4 Subject: [PATCH] systray-toggle to show/hide the systray 5 6 --- 7 config.def.h | 3 ++- 8 dwm.c | 14 ++++++++++++++ 9 2 files changed, 16 insertions(+), 1 deletion(-) 10 11 diff --git a/config.def.h b/config.def.h 12 index 2d824d1..fb7dc0c 100644 13 --- a/config.def.h 14 +++ b/config.def.h 15 @@ -6,7 +6,7 @@ static const unsigned int snap = 32; /* snap pixel */ 16 static const unsigned int systraypinning = 0; /* 0: sloppy systray follows selected monitor, >0: pin systray to monitor X */ 17 static const unsigned int systrayspacing = 2; /* systray spacing */ 18 static const int systraypinningfailfirst = 1; /* 1: if pinning fails, display systray on the first monitor, False: display systray on the last monitor*/ 19 -static const int showsystray = 1; /* 0 means no systray */ 20 +static int showsystray = 1; /* 0 means no systray */ 21 static const int showbar = 1; /* 0 means no bar */ 22 static const int topbar = 1; /* 0 means bottom bar */ 23 static const char *fonts[] = { "monospace:size=10" }; 24 @@ -68,6 +68,7 @@ static Key keys[] = { 25 { MODKEY, XK_p, spawn, {.v = dmenucmd } }, 26 { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, 27 { MODKEY, XK_b, togglebar, {0} }, 28 + { MODKEY|ShiftMask, XK_b, togglesystray, {0} }, 29 { MODKEY, XK_j, focusstack, {.i = +1 } }, 30 { MODKEY, XK_k, focusstack, {.i = -1 } }, 31 { MODKEY, XK_i, incnmaster, {.i = +1 } }, 32 diff --git a/dwm.c b/dwm.c 33 index 1b90b7b..530ef32 100644 34 --- a/dwm.c 35 +++ b/dwm.c 36 @@ -240,6 +240,7 @@ static void tag(const Arg *arg); 37 static void tagmon(const Arg *arg); 38 static void tile(Monitor *); 39 static void togglebar(const Arg *arg); 40 +static void togglesystray(); 41 static void togglefloating(const Arg *arg); 42 static void toggletag(const Arg *arg); 43 static void toggleview(const Arg *arg); 44 @@ -1908,6 +1909,19 @@ togglebar(const Arg *arg) 45 arrange(selmon); 46 } 47 48 +void 49 +togglesystray() 50 +{ 51 + if (showsystray) 52 + XUnmapWindow(dpy, systray->win); 53 + showsystray = !showsystray; 54 + updatesystray(); 55 + drawbar(selmon); 56 +} 57 + 58 void 59 togglefloating(const Arg *arg) 60 { 61 -- 62 2.26.2 63