You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
patches/dwm/dwm-barmodules-statusbutton...

128 lines
4.8 KiB
Diff

From 941d14787a5f49e5fe1be516a2b30858110ec35d Mon Sep 17 00:00:00 2001
From: Bakkeby <bakkeby@gmail.com>
Date: Mon, 10 Jan 2022 14:11:09 +0100
Subject: [PATCH 2/2] Adding statusbutton module
---
config.def.h | 5 ++++-
dwm.c | 2 +-
patch/bar_statusbutton.c | 21 +++++++++++++++++++++
patch/bar_statusbutton.h | 3 +++
patch/include.c | 3 ++-
patch/include.h | 3 ++-
6 files changed, 33 insertions(+), 4 deletions(-)
create mode 100644 patch/bar_statusbutton.c
create mode 100644 patch/bar_statusbutton.h
diff --git a/config.def.h b/config.def.h
index f870c41..14d47ad 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 const char buttonbar[] = "<O>";
static const char *fonts[] = { "monospace:size=10" };
static const char dmenufont[] = "monospace:size=10";
static const char col_gray1[] = "#222222";
@@ -45,6 +46,7 @@ static const Rule rules[] = {
*/
static const BarRule barrules[] = {
/* monitor bar alignment widthfunc drawfunc clickfunc name */
+ { -1, 0, BAR_ALIGN_LEFT, width_stbutton, draw_stbutton, click_stbutton, "statusbutton" },
{ -1, 0, BAR_ALIGN_LEFT, width_tags, draw_tags, click_tags, "tags" },
{ -1, 0, BAR_ALIGN_LEFT, width_ltsymbol, draw_ltsymbol, click_ltsymbol, "layout" },
{ 'A', 0, BAR_ALIGN_RIGHT, width_status, draw_status, click_status, "status" },
@@ -118,9 +120,10 @@ static Key keys[] = {
};
/* button definitions */
-/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
+/* click can be ClkButton, ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
static Button buttons[] = {
/* click event mask button function argument */
+ { ClkButton, 0, Button1, spawn, {.v = dmenucmd } },
{ ClkLtSymbol, 0, Button1, setlayout, {0} },
{ ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
{ ClkWinTitle, 0, Button2, zoom, {0} },
diff --git a/dwm.c b/dwm.c
index 86763d8..de465bc 100644
--- a/dwm.c
+++ b/dwm.c
@@ -65,7 +65,7 @@ enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
-enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
+enum { ClkButton, ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
enum {
BAR_ALIGN_LEFT,
diff --git a/patch/bar_statusbutton.c b/patch/bar_statusbutton.c
new file mode 100644
index 0000000..f5c9c9d
--- /dev/null
+++ b/patch/bar_statusbutton.c
@@ -0,0 +1,21 @@
+int
+width_stbutton(Bar *bar, BarWidthArg *a)
+{
+ return TEXTW(buttonbar);
+}
+
+int
+draw_stbutton(Bar *bar, BarDrawArg *a)
+{
+ #if BAR_PANGO_PATCH
+ return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, buttonbar, 0, False);
+ #else
+ return drw_text(drw, a->x, 0, a->w, bh, lrpad / 2, buttonbar, 0);
+ #endif // BAR_PANGO_PATCH
+}
+
+int
+click_stbutton(Bar *bar, Arg *arg, BarClickArg *a)
+{
+ return ClkButton;
+}
diff --git a/patch/bar_statusbutton.h b/patch/bar_statusbutton.h
new file mode 100644
index 0000000..8e9d6fe
--- /dev/null
+++ b/patch/bar_statusbutton.h
@@ -0,0 +1,3 @@
+static int width_stbutton(Bar *bar, BarWidthArg *a);
+static int draw_stbutton(Bar *bar, BarDrawArg *a);
+static int click_stbutton(Bar *bar, Arg *arg, BarClickArg *a);
\ No newline at end of file
diff --git a/patch/include.c b/patch/include.c
index d422f56..b731f2e 100644
--- a/patch/include.c
+++ b/patch/include.c
@@ -2,4 +2,5 @@
#include "bar_ltsymbol.c"
#include "bar_status.c"
#include "bar_tags.c"
-#include "bar_wintitle.c"
\ No newline at end of file
+#include "bar_wintitle.c"
+#include "bar_statusbutton.c"
\ No newline at end of file
diff --git a/patch/include.h b/patch/include.h
index 5f9a3fe..c2a1127 100644
--- a/patch/include.h
+++ b/patch/include.h
@@ -2,4 +2,5 @@
#include "bar_ltsymbol.h"
#include "bar_status.h"
#include "bar_tags.h"
-#include "bar_wintitle.h"
\ No newline at end of file
+#include "bar_wintitle.h"
+#include "bar_statusbutton.h"
\ No newline at end of file
--
2.19.1