add a few more keybinds, fix issue in #else in title.c

This commit is contained in:
speedie 2022-12-07 20:23:06 +01:00
parent 52719c5bd5
commit b98829bfb0
7 changed files with 83 additions and 12 deletions

View file

@ -32,8 +32,11 @@ draw_title_basic(Bar *bar, BarDrawArg *a)
padding = (w - TEXTW(c->name) + lrpad) / 2; padding = (w - TEXTW(c->name) + lrpad) / 2;
#if USEWINICON #if USEWINICON
drw_text(drw, x, 0, w, bh, padding + (c->icon ? c->icw + iconspacing : 0), c->name, 0, False); if (!selmon->hideicon)
if (c->icon) drw_text(drw, x, 0, w, bh, padding + (c->icon ? c->icw + iconspacing : 0), c->name, 0, False);
else
drw_text(drw, x, 0, w, bh, padding, c->name, 0, False);
if (c->icon && !selmon->hideicon)
drw_pic(drw, x + padding, (bh - c->ich) / 2, c->icw, c->ich, c->icon); drw_pic(drw, x + padding, (bh - c->ich) / 2, c->icw, c->ich, c->icon);
#else #else
drw_text(drw, x, 0, w, bh, padding, c->name, 0, False); drw_text(drw, x, 0, w, bh, padding, c->name, 0, False);

View file

@ -25,31 +25,48 @@ draw_title(Bar *bar, BarDrawArg *a)
n++; n++;
if (n > 0) { if (n > 0) {
remainder = w % n; if (!selmon->hideunselectedtitle) {
tabw = w / n; remainder = w % n;
tabw = w / n;
} else {
remainder = w;
tabw = w;
}
for (i = 0, c = bar->mon->clients; c; c = c->next, i++) { for (i = 0, c = bar->mon->clients; c; c = c->next, i++) {
if (!ISVISIBLE(c)) if (!ISVISIBLE(c))
continue; continue;
if (bar->mon->sel == c && colorselectedtitle) if (bar->mon->sel == c && colorselectedtitle)
scm = SchemeTitleSel; scm = SchemeTitleSel;
else if (!colorselectedtitle) else if (!colorselectedtitle)
scm = SchemeTitleNorm; scm = SchemeTitleNorm;
else if (HIDDEN(c)) else if (HIDDEN(c) && !selmon->hideunselectedtitle)
scm = SchemeTitleHidden; scm = SchemeTitleHidden;
else else if (!selmon->hideunselectedtitle)
scm = SchemeTitleNorm; scm = SchemeTitleNorm;
/* hide unselected title */
if (bar->mon->sel != c && selmon->hideunselectedtitle) {
continue;
}
padding = lrpad / 2; padding = lrpad / 2;
if (TEXTW(c->name) < tabw && titleposition) if (TEXTW(c->name) < tabw && titleposition)
padding = (tabw - TEXTW(c->name) + lrpad) / 2; padding = (tabw - TEXTW(c->name) + lrpad) / 2;
drw_setscheme(drw, scheme[scm]); drw_setscheme(drw, scheme[scm]);
#if USEWINICON #if USEWINICON
drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, padding + (c->name ? c->icw + iconspacing : 0), c->name, 0, False); if (!selmon->hideicon) {
if (c->icon) drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, padding + (c->name ? c->icw + iconspacing : 0), c->name, 0, False);
} else {
drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, padding, c->name, 0, False);
}
if (c->icon && !selmon->hideicon)
drw_pic(drw, x + padding, (bh - c->ich) / 2, c->icw, c->ich, c->icon); drw_pic(drw, x + padding, (bh - c->ich) / 2, c->icw, c->ich, c->icon);
#else #else
drw_text(drw, x, 0, tabw + padding (i < remainder ? 1 : 0), bh, padding, c->name, 0, False); drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, padding, c->name, 0, False);
#endif #endif
x += tabw + (i < remainder ? 1 : 0); x += tabw + (i < remainder ? 1 : 0);

View file

@ -116,4 +116,5 @@
- 116 - Toggle mark on a client. - 116 - Toggle mark on a client.
- 117 - Swap focus with the marked client. - 117 - Swap focus with the marked client.
- 118 - Swap the focused client with the marked client. - 118 - Swap the focused client with the marked client.
- 119 - Center the focused window

View file

@ -195,11 +195,13 @@ static Key keys[] = {
{ MODIFIER1, XK_p, XK_r, resetbarpadding, {0} }, { MODIFIER1, XK_p, XK_r, resetbarpadding, {0} },
/* Chained toggle keybinds */ /* Chained toggle keybinds */
{ MODIFIER1, XK_t, XK_t, togglebartags, {0} }, { MODIFIER1, XK_t, XK_t, togglebartags, {0} },
{ MODIFIER1, XK_t, XK_y, togglebaremptytags, {0} }, { MODIFIER1, XK_t, XK_y, togglebaremptytags, {0} },
{ MODIFIER1, XK_t, XK_w, togglebartitle, {0} }, { MODIFIER1, XK_t, XK_w, togglebartitle, {0} },
{ MODIFIER1, XK_t, XK_u, togglebarunseltitle, {0} },
{ MODIFIER1, XK_t, XK_s, togglebarstatus, {0} }, { MODIFIER1, XK_t, XK_s, togglebarstatus, {0} },
{ MODIFIER1, XK_t, XK_l, togglebarlt, {0} }, { MODIFIER1, XK_t, XK_l, togglebarlt, {0} },
{ MODIFIER1, XK_t, XK_i, togglebaricon, {0} },
{ MODIFIER1, XK_t, XK_o, toggleopacity, {0} }, { MODIFIER1, XK_t, XK_o, toggleopacity, {0} },
{ MODIFIER1, XK_t, XK_b, togglebarpos, {0} }, { MODIFIER1, XK_t, XK_b, togglebarpos, {0} },
//{ MODIFIER1, XK_t, XK_r, resetbar, {0} }, //{ MODIFIER1, XK_t, XK_r, resetbar, {0} },

View file

@ -117,6 +117,7 @@ static int underlinevoffset = 0; /* How far above the bottom o
static int hidebar = 0; /* Hide the bar (1) or show (0) */ static int hidebar = 0; /* Hide the bar (1) or show (0) */
static int hidelayout = 0; /* Hide layout indicator (1) or show (0) */ static int hidelayout = 0; /* Hide layout indicator (1) or show (0) */
static int hidetitle = 0; /* Hide the title part of the bar (1) or show (0) */ static int hidetitle = 0; /* Hide the title part of the bar (1) or show (0) */
static int hideunselectedtitle = 1; /* Hide unselected title (1) or show (0) */
static int hidestatus = 0; /* Hide status bar (1) or show (0) */ static int hidestatus = 0; /* Hide status bar (1) or show (0) */
static int hideicon = 0; /* Hide icon (1) or show (0) */ static int hideicon = 0; /* Hide icon (1) or show (0) */
static int hidetags = 0; /* Hide status bar (1) or show (0) */ static int hidetags = 0; /* Hide status bar (1) or show (0) */

View file

@ -65,6 +65,9 @@ static Signal signals[] = {
{ 58, scratchpad_remove, {0} }, { 58, scratchpad_remove, {0} },
{ 59, reset_layout, {0} }, { 59, reset_layout, {0} },
{ 60, resetmastercount, {0} }, { 60, resetmastercount, {0} },
#if USESYSTRAY
{ 61, togglesystray, {0} },
#endif
{ 62, hideall, {0} }, { 62, hideall, {0} },
{ 63, showall, {0} }, { 63, showall, {0} },
{ 64, reset_mfact, {0} }, { 64, reset_mfact, {0} },
@ -73,8 +76,24 @@ static Signal signals[] = {
#endif #endif
{ 66, viewtoleft_vacant, {0} }, { 66, viewtoleft_vacant, {0} },
{ 67, viewtoright_vacant, {0} }, { 67, viewtoright_vacant, {0} },
{ 68, togglebartags, {0} }, { 68, togglebartags, {0} },
{ 69, togglebaremptytags, {0} },
//{ 70, toggletagpowerline, {0} },
//{ 71, toggletitlepowerline, {0} },
//{ 72, togglepowerline, {0} },
//{ 73, toggletagplshape, {0} },
//{ 74, toggletitleplshape, {0} },
//{ 75, toggleplshape, {0} },
//{ 76, resetpowerline, {0} },
{ 77, togglebartitle, {0} },
{ 78, togglebarunseltitle, {0} },
{ 79, togglebarlt, {0} },
{ 80, togglebarstatus, {0} },
{ 81, togglebarfloat, {0} },
{ 82, togglebarsticky, {0} },
{ 83, togglebaricon, {0} },
{ 84, togglebarpos, {0} },
//{ 86, resetbar, {0} },
{ 87, setbarheight, {.i = +1 } }, { 87, setbarheight, {.i = +1 } },
{ 88, setbarheight, {.i = -1 } }, { 88, setbarheight, {.i = -1 } },
{ 89, resetbarheight, {0} }, { 89, resetbarheight, {0} },
@ -107,4 +126,5 @@ static Signal signals[] = {
{ 116, togglemark, {0} }, { 116, togglemark, {0} },
{ 117, swapfocus, {0} }, { 117, swapfocus, {0} },
{ 118, swapclient, {0} }, { 118, swapclient, {0} },
{ 119, centerwindow, {0} },
}; };

View file

@ -342,6 +342,7 @@ struct Monitor {
int hidefloating; int hidefloating;
int hidesticky; int hidesticky;
int hideclientindicator; int hideclientindicator;
int hideunselectedtitle;
/* powerline shape */ /* powerline shape */
int tagplshape; int tagplshape;
@ -653,6 +654,10 @@ static void togglebartags(const Arg *arg);
static void togglesystray(const Arg *arg); static void togglesystray(const Arg *arg);
#endif #endif
static void togglebaremptytags(const Arg *arg); static void togglebaremptytags(const Arg *arg);
static void togglebarunseltitle(const Arg *arg);
static void togglebarlt(const Arg *arg);
static void togglebarsticky(const Arg *arg);
static void togglebaricon(const Arg *arg);
static void togglebartitle(const Arg *arg); static void togglebartitle(const Arg *arg);
static void togglebarlt(const Arg *arg); static void togglebarlt(const Arg *arg);
static void togglebarstatus(const Arg *arg); static void togglebarstatus(const Arg *arg);
@ -1744,6 +1749,7 @@ createmon(void)
m->hidefloating = hidefloating; m->hidefloating = hidefloating;
m->hidesticky = hidesticky; m->hidesticky = hidesticky;
m->hideclientindicator = hideclientindicator; m->hideclientindicator = hideclientindicator;
m->hideunselectedtitle = hideunselectedtitle;
/* shape of powerlines */ /* shape of powerlines */
m->tagplshape = tagplshape; m->tagplshape = tagplshape;
@ -5525,6 +5531,13 @@ togglebaremptytags(const Arg *arg)
arrange(selmon); arrange(selmon);
} }
void
togglebarunseltitle(const Arg *arg)
{
selmon->hideunselectedtitle = !selmon->hideunselectedtitle;
arrange(selmon);
}
void void
togglebartitle(const Arg *arg) togglebartitle(const Arg *arg)
{ {
@ -5532,6 +5545,20 @@ togglebartitle(const Arg *arg)
arrange(selmon); arrange(selmon);
} }
void
togglebarsticky(const Arg *arg)
{
selmon->hidesticky = !selmon->hidesticky;
arrange(selmon);
}
void
togglebaricon(const Arg *arg)
{
selmon->hideicon = !selmon->hideicon;
arrange(selmon);
}
void void
togglebarlt(const Arg *arg) togglebarlt(const Arg *arg)
{ {