[wiki] [sites] Added new patch for tabbed: basenames || Jacob F

From: <git_AT_suckless.org>
Date: Tue, 06 Jun 2023 02:12:13 +0200

commit c62f035c05c2db607b8ed1870dc43da0384957d2
Author: Jacob F <jacobcfong_AT_gmail.com>
Date: Mon Jun 5 17:07:19 2023 -0700

    Added new patch for tabbed: basenames
    
    Some tabbed clients (zathura) have full paths for names. When many are
    open, the bar is hard to read. This patch adds the option to draw only
    the basenames of client names in the bar. Commit includes screenshots.

diff --git a/tools.suckless.org/tabbed/patches/basenames/basenames.jpg b/tools.suckless.org/tabbed/patches/basenames/basenames.jpg
new file mode 100644
index 00000000..446637db
Binary files /dev/null and b/tools.suckless.org/tabbed/patches/basenames/basenames.jpg differ
diff --git a/tools.suckless.org/tabbed/patches/basenames/index.md b/tools.suckless.org/tabbed/patches/basenames/index.md
new file mode 100644
index 00000000..40facddb
--- /dev/null
+++ b/tools.suckless.org/tabbed/patches/basenames/index.md
_AT_@ -0,0 +1,22 @@
+Basenames
+=============
+Show only the basename of the tabbed title; useful with zathura.
+Toggle with `-b`.
+
+From this:
+
+![longnames_screenshot](longnames.jpg)
+
+To this:
+
+![basenames_screenshot](basenames.jpg)
+
+
+Download
+--------
+* [tabbed-basenames-0.7.diff](tabbed-basenames-0.7.diff)
+
+Author
+------
+* Jacob F <jacobcfong_AT_gmail.com>
+
diff --git a/tools.suckless.org/tabbed/patches/basenames/longnames.jpg b/tools.suckless.org/tabbed/patches/basenames/longnames.jpg
new file mode 100644
index 00000000..0f6c8008
Binary files /dev/null and b/tools.suckless.org/tabbed/patches/basenames/longnames.jpg differ
diff --git a/tools.suckless.org/tabbed/patches/basenames/tabbed-basenames-0.7.diff b/tools.suckless.org/tabbed/patches/basenames/tabbed-basenames-0.7.diff
new file mode 100644
index 00000000..5995ba98
--- /dev/null
+++ b/tools.suckless.org/tabbed/patches/basenames/tabbed-basenames-0.7.diff
_AT_@ -0,0 +1,104 @@
+From a682145f0daf599b6d2f6c1326f064ec67b30f73 Mon Sep 17 00:00:00 2001
+From: Jacob Fong <jacobcfong_AT_gmail.com>
+Date: Mon, 5 Jun 2023 15:57:54 -0700
+Subject: [PATCH] Added `-b` to display only basenames of tab titles.
+
+---
+ tabbed.1 | 3 +++
+ tabbed.c | 24 ++++++++++++++++++++++--
+ 2 files changed, 25 insertions(+), 2 deletions(-)
+
+diff --git a/tabbed.1 b/tabbed.1
+index 07bdbd7..4a9c110 100644
+--- a/tabbed.1
++++ b/tabbed.1
+_AT_@ -106,6 +106,9 @@ defines the urgent background color.
+ .BI \-U " urgfgbcol"
+ defines the urgent foreground color.
+ .TP
++.BI \-b
++print only basenames of tab titles.
++.TP
+ .B \-v
+ prints version information to stderr, then exits.
+ .SH USAGE
+diff --git a/tabbed.c b/tabbed.c
+index eafe28a..03b0c8c 100644
+--- a/tabbed.c
++++ b/tabbed.c
+_AT_@ -80,6 +80,7 @@ typedef struct {
+
+ typedef struct {
+ char name[256];
++ char *basename;
+ Window win;
+ int tabx;
+ Bool urgent;
+_AT_@ -106,6 +107,7 @@ static void focusonce(const Arg *arg);
+ static void focusurgent(const Arg *arg);
+ static void fullscreen(const Arg *arg);
+ static char *getatom(int a);
++static char *getbasename(const char *name);
+ static int getclient(Window w);
+ static XftColor getcolor(const char *colstr);
+ static int getfirsttab(void);
+_AT_@ -156,7 +158,7 @@ static int bh, obh, wx, wy, ww, wh;
+ static unsigned int numlockmask;
+ static Bool running = True, nextfocus, doinitspawn = True,
+ fillagain = False, closelastclient = False,
+- killclientsfirst = False;
++ killclientsfirst = False, basenametitles = False;
+ static Display *dpy;
+ static DC dc;
+ static Atom wmatom[WMLast];
+_AT_@ -367,7 +369,10 @@ drawbar(void)
+ } else {
+ col = clients[c]->urgent ? dc.urg : dc.norm;
+ }
+- drawtext(clients[c]->name, col);
++ if (basenametitles)
++ drawtext(clients[c]->basename, col);
++ else
++ drawtext(clients[c]->name, col);
+ dc.x += dc.w;
+ clients[c]->tabx = dc.x;
+ }
+_AT_@ -557,6 +562,16 @@ getatom(int a)
+ return buf;
+ }
+
++char *
++getbasename(const char *name)
++{
++ char *pos = strrchr(name, '/');
++ if (pos)
++ return pos+1;
++ else
++ return (char *)name;
++}
++
+ int
+ getclient(Window w)
+ {
+_AT_@ -1217,6 +1232,8 @@ updatetitle(int c)
+ sizeof(clients[c]->name)))
+ gettextprop(clients[c]->win, XA_WM_NAME, clients[c]->name,
+ sizeof(clients[c]->name));
++ if (basenametitles)
++ clients[c]->basename = getbasename(clients[c]->name);
+ if (sel == c)
+ xsettitle(win, clients[c]->name);
+ drawbar();
+_AT_@ -1333,6 +1350,9 @@ main(int argc, char *argv[])
+ case 'u':
+ urgbgcolor = EARGF(usage());
+ break;
++ case 'b':
++ basenametitles = True;
++ break;
+ case 'v':
+ die("tabbed-"VERSION", © 2009-2016 tabbed engineers, "
+ "see LICENSE for details.
");
+--
+2.40.0
+
Received on Tue Jun 06 2023 - 02:12:13 CEST

This archive was generated by hypermail 2.3.0 : Tue Jun 06 2023 - 02:12:55 CEST