~raphi/public-inbox

somebar: patch: clickable tags using wtype v1 APPLIED

Ben Collerson: 1
 patch: clickable tags using wtype

 1 files changed, 77 insertions(+), 0 deletions(-)
#966214 archlinux.yml success
#966215 freebsd.yml success
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~raphi/public-inbox/patches/40111/mbox | git am -3
Learn more about email & git

[PATCH somebar] patch: clickable tags using wtype Export this patch

---
 contrib/clickable-tags-using-wtype.patch | 77 ++++++++++++++++++++++++
 1 file changed, 77 insertions(+)
 create mode 100644 contrib/clickable-tags-using-wtype.patch

diff --git a/contrib/clickable-tags-using-wtype.patch b/contrib/clickable-tags-using-wtype.patch
new file mode 100644
index 0000000..0906b3a
--- /dev/null
+++ b/contrib/clickable-tags-using-wtype.patch
@@ -0,0 +1,77 @@
From: Ben Collerson <benc@benc.cc>
Date: Sat, 1 Apr 2023 09:16:19 +1000
Subject: [PATCH somebar] clickable tags using wtype

---
 src/bar.cpp        |  3 ++-
 src/common.hpp     |  2 ++
 src/config.def.hpp |  2 ++
 src/main.cpp       | 11 +++++++++++
 4 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/bar.cpp b/src/bar.cpp
index 507ce62..c2f2a27 100644
--- a/src/bar.cpp
+++ b/src/bar.cpp
@@ -182,9 +182,10 @@ void Bar::click(Monitor* mon, int x, int, int btn)
 	} else if (x > _layoutCmp.x) {
 		control = ClkLayoutSymbol;
 	} else for (auto tag = _tags.size()-1; tag >= 0; tag--) {
+		// you may need logic to skip tags if they are hidden elsewhere.
 		if (x > _tags[tag].component.x) {
 			control = ClkTagBar;
-			arg.ui = 1<<tag;
+			arg.ui = tag;
 			argp = &arg;
 			break;
 		}
diff --git a/src/common.hpp b/src/common.hpp
index c905358..a386029 100644
--- a/src/common.hpp
+++ b/src/common.hpp
@@ -39,6 +39,8 @@ extern wl_compositor* compositor;
 extern wl_shm* shm;
 extern zwlr_layer_shell_v1* wlrLayerShell;
 
+void view(Monitor& m, const Arg& arg);
+void tag(Monitor& m, const Arg& arg);
 void spawn(Monitor&, const Arg& arg);
 void setCloexec(int fd);
 [[noreturn]] void die(const char* why);
diff --git a/src/config.def.hpp b/src/config.def.hpp
index 40a8c95..2bdf507 100644
--- a/src/config.def.hpp
+++ b/src/config.def.hpp
@@ -23,5 +23,7 @@ static std::vector<std::string> tagNames = {
 };
 
 constexpr Button buttons[] = {
+	{ ClkTagBar,       BTN_LEFT,   view,       {0} },
+	{ ClkTagBar,       BTN_RIGHT,  tag,        {0} },
 	{ ClkStatusText,   BTN_RIGHT,  spawn,      {.v = termcmd} },
 };
diff --git a/src/main.cpp b/src/main.cpp
index 6274959..14a6e4f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -85,6 +85,17 @@ static int statusFifoFd {-1};
 static int statusFifoWriter {-1};
 static bool quitting {false};
 
+// update keybindings to match your dwl
+void view(Monitor& m, const Arg& arg)
+{
+	int tag = arg.ui + 1;
+	system((std::string("wtype -M alt ") + std::to_string(tag) ).c_str());
+}
+void tag(Monitor& m, const Arg& arg)
+{
+	int tag = arg.ui + 1;
+	system((std::string("wtype -M alt -M shift ") + std::to_string(tag) ).c_str());
+}
 void spawn(Monitor&, const Arg& arg)
 {
 	if (fork() == 0) {
-- 
2.40.0

-- 
2.40.0
Thank

To git.sr.ht:~raphi/somebar
   af73bc3..b069830  master -> master
somebar/patches: SUCCESS in 48s

[patch: clickable tags using wtype][0] from [Ben Collerson][1]

[0]: https://lists.sr.ht/~raphi/public-inbox/patches/40111
[1]: mailto:benc@benc.cc

✓ #966214 SUCCESS somebar/patches/archlinux.yml https://builds.sr.ht/~raphi/job/966214
✓ #966215 SUCCESS somebar/patches/freebsd.yml   https://builds.sr.ht/~raphi/job/966215