[hackers] [dwm] config.def.h: ClkTagBar missing from comment || Hiltjo Posthuma
commit c3a2e016bb65c00bd44b6461b1b1bbaa61f20093 Author: Hiltjo Posthuma AuthorDate: Fri May 25 06:56:36 2018 +0200 Commit: Hiltjo Posthuma CommitDate: Fri May 25 06:56:36 2018 +0200 config.def.h: ClkTagBar missing from comment by Christopher Drelich Patch was mangled on the ML, also adjusted the order to be the same as the enum in dwm.c diff --git a/config.def.h b/config.def.h index a9ac303..1c0b587 100644 --- a/config.def.h +++ b/config.def.h @@ -97,7 +97,7 @@ static Key keys[] = { }; /* button definitions */ -/* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ +/* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ static Button buttons[] = { /* clickevent mask button function argument */ { ClkLtSymbol, 0, Button1,setlayout, {0} },
Re: [hackers] [dwm][PATCH] Status bar magic numbers replaced with configurable variables.
On Thu, May 24, 2018 at 10:48:27PM -0400, Christopher Drelich wrote: > Currently in dwm there are two magic numbers relating to the statusbar in > dwm.c: > > sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ > > bh = drw->fonts->h + 2; > > I made a patch that replaced these magic numbers with configurable > variables, plus a third configurable variable that made sense with > these: > > vertbarpad is vertical padding for the statusbar. > horizbarpad is horizontal padding for the statusbar. > statusrpad is right hand padding for StatusText in the statusbar. > > It would be possible to add a 'statuslpad' as well, or to just make > the padding for the StatusText the same as that for other elements of > the statusbar, or to divide it by 2 and just use that for the > rightpadding. > > I think that having StatusText have the same padding as other elements > in the statusbar would probably end up making things cleanest. > > The main purpose of this patch is to eliminate 'magic numbers,' so the > hope is to open up discussion on how to do that, be it by this patch, > a suggested variant of it, something else, or if people think they > should just stay. > Chris > How are they magic? Is any number in arithmetic some magic number for you? I don't see the point of this endless bikeshedding and refactoring. I won't apply this. > --- > > Removes two magic numbers and replaces them with configurable > variables in config.def.h > > A third configurable variable was added, as it made sense to be > there given the existence of the other two variables. > > vertbarpad is vertical padding for the statusbar. > horizbarpad is horizontal padding for the statusbar. > statusrpad is right hand padding for StatusText in the statusbar. > --- > config.def.h | 3 +++ > dwm.c| 8 > 2 files changed, 7 insertions(+), 4 deletions(-) > > diff --git a/config.def.h b/config.def.h > index a9ac303..4f03aa1 100644 > --- a/config.def.h > +++ b/config.def.h > @@ -5,6 +5,9 @@ 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 int horizbarpad= 0;/* horizontal bar padding */ > +static const int vertbarpad = 2;/* vertical bar padding */ > +static const int statusrpad = 2;/* right padding for > StatusText */ > static const char *fonts[] = { "monospace:size=10" }; > static const char dmenufont[] = "monospace:size=10"; > static const char col_gray1[] = "#22"; > diff --git a/dwm.c b/dwm.c > index bb95e26..9014261 100644 > --- a/dwm.c > +++ b/dwm.c > @@ -439,7 +439,7 @@ buttonpress(XEvent *e) > arg.ui = 1 << i; > } else if (ev->x < x + blw) > click = ClkLtSymbol; > - else if (ev->x > selmon->ww - TEXTW(stext)) > + else if (ev->x > selmon->ww - TEXTW(stext) + lrpad - > statusrpad) > click = ClkStatusText; > else > click = ClkWinTitle; > @@ -704,7 +704,7 @@ drawbar(Monitor *m) > /* draw status first so it can be overdrawn by tags later */ > if (m == selmon) { /* status is only drawn on selected monitor */ > drw_setscheme(drw, scheme[SchemeNorm]); > - sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ > + sw = TEXTW(stext) - lrpad + statusrpad; > drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0); > } > > @@ -1544,8 +1544,8 @@ setup(void) > drw = drw_create(dpy, screen, root, sw, sh); > if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) > die("no fonts could be loaded."); > - lrpad = drw->fonts->h; > - bh = drw->fonts->h + 2; > + lrpad = drw->fonts->h + horizbarpad; > + bh = drw->fonts->h + vertbarpad; > updategeom(); > /* init atoms */ > utf8string = XInternAtom(dpy, "UTF8_STRING", False); > -- > 2.7.4 > -- Kind regards, Hiltjo
[hackers] Re: [dwm][PATCH] Status bar magic numbers replaced with configurable variables.
Included below is the version of the patch that I would personally recommend using (if any are used.) It makes for cleaner code, fewer magic numbers, and more options for configuration. Unlike the other patch, this patch slightly changes dwm's appearance from pre-patch. The change being that StatusText now has both left and right padding equal to that of the rest of the items in statusbar, as opposed to having just right padding set by a magic number. Other than that, appearance remains the same when using the defaults in config.def.h Chris --- Replaces magic numbers in statusbar with configurable variables. horizpadbar for horizontal statusbar padding vertpadbar for vertical statusbar padding StatusText now has both left and right padding, as well as the vertical padding that all of the statusbar shares. Other than the addition of left padding to StatusText, appearance of the statusbar is identical to pre-patch when using the defaults in config.def.h --- config.def.h | 2 ++ dwm.c| 8 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/config.def.h b/config.def.h index a9ac303..5819399 100644 --- a/config.def.h +++ b/config.def.h @@ -5,6 +5,8 @@ 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 int horizpadbar= 2;/* horizontal padding for statusbar */ +static const int vertpadbar = 0;/* vertical padding for statusbar */ static const char *fonts[] = { "monospace:size=10" }; static const char dmenufont[] = "monospace:size=10"; static const char col_gray1[] = "#22"; diff --git a/dwm.c b/dwm.c index bb95e26..7b9ed42 100644 --- a/dwm.c +++ b/dwm.c @@ -704,8 +704,8 @@ drawbar(Monitor *m) /* draw status first so it can be overdrawn by tags later */ if (m == selmon) { /* status is only drawn on selected monitor */ drw_setscheme(drw, scheme[SchemeNorm]); - sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ - drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0); + sw = TEXTW(stext); + drw_text(drw, m->ww - sw, 0, sw, bh, lrpad / 2, stext, 0); } for (c = m->clients; c; c = c->next) { @@ -1544,8 +1544,8 @@ setup(void) drw = drw_create(dpy, screen, root, sw, sh); if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) die("no fonts could be loaded."); - lrpad = drw->fonts->h; - bh = drw->fonts->h + 2; + lrpad = drw->fonts->h + horizpadbar; + bh = drw->fonts->h + vertpadbar; updategeom(); /* init atoms */ utf8string = XInternAtom(dpy, "UTF8_STRING", False); -- 2.7.4 On Thu, May 24, 2018 at 10:48 PM, Christopher Drelich wrote: > Currently in dwm there are two magic numbers relating to the statusbar in > dwm.c: > > sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ > > bh = drw->fonts->h + 2; > > I made a patch that replaced these magic numbers with configurable > variables, plus a third configurable variable that made sense with > these: > > vertbarpad is vertical padding for the statusbar. > horizbarpad is horizontal padding for the statusbar. > statusrpad is right hand padding for StatusText in the statusbar. > > It would be possible to add a 'statuslpad' as well, or to just make > the padding for the StatusText the same as that for other elements of > the statusbar, or to divide it by 2 and just use that for the > rightpadding. > > I think that having StatusText have the same padding as other elements > in the statusbar would probably end up making things cleanest. > > The main purpose of this patch is to eliminate 'magic numbers,' so the > hope is to open up discussion on how to do that, be it by this patch, > a suggested variant of it, something else, or if people think they > should just stay. > Chris > > --- > > Removes two magic numbers and replaces them with configurable > variables in config.def.h > > A third configurable variable was added, as it made sense to be > there given the existence of the other two variables. > > vertbarpad is vertical padding for the statusbar. > horizbarpad is horizontal padding for the statusbar. > statusrpad is right hand padding for StatusText in the statusbar. > --- > config.def.h | 3 +++ > dwm.c| 8 > 2 files changed, 7 insertions(+), 4 deletions(-) > > diff --git a/config.def.h b/config.def.h > index a9ac303..4f03aa1 100644 > --- a/config.def.h > +++ b/config.def.h > @@ -5,6 +5,9 @@ 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 topb
[hackers] [dwm][PATCH] Status bar magic numbers replaced with configurable variables.
Currently in dwm there are two magic numbers relating to the statusbar in dwm.c: sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ bh = drw->fonts->h + 2; I made a patch that replaced these magic numbers with configurable variables, plus a third configurable variable that made sense with these: vertbarpad is vertical padding for the statusbar. horizbarpad is horizontal padding for the statusbar. statusrpad is right hand padding for StatusText in the statusbar. It would be possible to add a 'statuslpad' as well, or to just make the padding for the StatusText the same as that for other elements of the statusbar, or to divide it by 2 and just use that for the rightpadding. I think that having StatusText have the same padding as other elements in the statusbar would probably end up making things cleanest. The main purpose of this patch is to eliminate 'magic numbers,' so the hope is to open up discussion on how to do that, be it by this patch, a suggested variant of it, something else, or if people think they should just stay. Chris --- Removes two magic numbers and replaces them with configurable variables in config.def.h A third configurable variable was added, as it made sense to be there given the existence of the other two variables. vertbarpad is vertical padding for the statusbar. horizbarpad is horizontal padding for the statusbar. statusrpad is right hand padding for StatusText in the statusbar. --- config.def.h | 3 +++ dwm.c| 8 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/config.def.h b/config.def.h index a9ac303..4f03aa1 100644 --- a/config.def.h +++ b/config.def.h @@ -5,6 +5,9 @@ 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 int horizbarpad= 0;/* horizontal bar padding */ +static const int vertbarpad = 2;/* vertical bar padding */ +static const int statusrpad = 2;/* right padding for StatusText */ static const char *fonts[] = { "monospace:size=10" }; static const char dmenufont[] = "monospace:size=10"; static const char col_gray1[] = "#22"; diff --git a/dwm.c b/dwm.c index bb95e26..9014261 100644 --- a/dwm.c +++ b/dwm.c @@ -439,7 +439,7 @@ buttonpress(XEvent *e) arg.ui = 1 << i; } else if (ev->x < x + blw) click = ClkLtSymbol; - else if (ev->x > selmon->ww - TEXTW(stext)) + else if (ev->x > selmon->ww - TEXTW(stext) + lrpad - statusrpad) click = ClkStatusText; else click = ClkWinTitle; @@ -704,7 +704,7 @@ drawbar(Monitor *m) /* draw status first so it can be overdrawn by tags later */ if (m == selmon) { /* status is only drawn on selected monitor */ drw_setscheme(drw, scheme[SchemeNorm]); - sw = TEXTW(stext) - lrpad + 2; /* 2px right padding */ + sw = TEXTW(stext) - lrpad + statusrpad; drw_text(drw, m->ww - sw, 0, sw, bh, 0, stext, 0); } @@ -1544,8 +1544,8 @@ setup(void) drw = drw_create(dpy, screen, root, sw, sh); if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) die("no fonts could be loaded."); - lrpad = drw->fonts->h; - bh = drw->fonts->h + 2; + lrpad = drw->fonts->h + horizbarpad; + bh = drw->fonts->h + vertbarpad; updategeom(); /* init atoms */ utf8string = XInternAtom(dpy, "UTF8_STRING", False); -- 2.7.4
[hackers] Re: [dwm][PATCH] ClkTagBar missing from comment.
I sent this patch in last night, and though my message in my "Sent" box shows the patch contents, the message in the archives is blank. I'm resending with the patch below. My apologies if this was previously visible to those who received the email. Either way, any idea why this would not have shown up in the archives? For this send I'm removing the generated header that included a From/Date/Subject --- config.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index a9ac303..d3b3363 100644 --- a/config.def.h +++ b/config.def.h @@ -97,7 +97,7 @@ static Key keys[] = { }; /* button definitions */ -/* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */ +/* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, ClkRootWin, or ClkTagBar */ static Button buttons[] = { /* clickevent mask button functionargument */ { ClkLtSymbol, 0, Button1, setlayout, {0} }, -- 2.7.4 On Wed, May 23, 2018 at 11:22 PM, Christopher Drelich wrote: > From 3757bffb4cbaf852702509d77dfe63633d30da13 Mon Sep 17 00:00:00 2001 > From: Christopher Drelich > Date: Wed, 23 May 2018 23:14:35 -0400 > Subject: [PATCH] ClkTagBar missing from comment. > > --- > config.def.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/config.def.h b/config.def.h > index a9ac303..d3b3363 100644 > --- a/config.def.h > +++ b/config.def.h > @@ -97,7 +97,7 @@ static Key keys[] = { > }; > > /* button definitions */ > -/* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, > ClkClientWin, or ClkRootWin */ > +/* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, > ClkClientWin, ClkRootWin, or ClkTagBar */ > static Button buttons[] = { > /* clickevent mask button > functionargument */ > { ClkLtSymbol, 0, Button1, > setlayout, {0} }, > -- > 2.7.4
Re: [hackers] [slstatus][PATCH] backlight: implemented openbsd support
On Thu, May 24, 2018 at 02:55:28PM +0200, Aaron Marcher wrote: > Hi, > > > i have implemented basic support for the backlight function on OpenBSD. > > The problem here is that /dev/ttyC0 permission is 600 (root:wheel) so a > > user cannot read from the device without changing the permission or > > running slstatus as root. > > Running slstatus as root is no real option - however there are not that much > alternatives to reading from /dev/ttyC0. Linking against xcb-xrandr is > bloated and appearently doesn't work for every setup. > A possible workaround would be to set the group permissions of /dev/ttyC0 in > /etc/rc.local or crontab automatically - which is not perfect. > The question that comes up to my mind is: Do we need the backlight > component? I can literally "see" the current brightness of my screen. Tell > me what you think and we will come up with a sane solution. > > Cheers! > Aaron > > -- > Web: https://drkhsh.at/ or http://drkhsh5rv6pnahas.onion/ > Gopher: gopher://drkhsh.at or gopher://drkhsh5rv6pnahas.onion > GPG: 0x7A65E38D55BE96FE > Fingerprint: 4688 907C 8720 3318 0D9F AFDE 7A65 E38D 55BE 96FE > Hi, in my opinion, if nobody else comes up with a clever idea how to get the brightness on openbsd we should just drop that component. As you already said, the brightness can be seen obviously. Greetings, Tobias
Re: [hackers] [slstatus][PATCH] backlight: implemented openbsd support
Hi, i have implemented basic support for the backlight function on OpenBSD. The problem here is that /dev/ttyC0 permission is 600 (root:wheel) so a user cannot read from the device without changing the permission or running slstatus as root. Running slstatus as root is no real option - however there are not that much alternatives to reading from /dev/ttyC0. Linking against xcb-xrandr is bloated and appearently doesn't work for every setup. A possible workaround would be to set the group permissions of /dev/ttyC0 in /etc/rc.local or crontab automatically - which is not perfect. The question that comes up to my mind is: Do we need the backlight component? I can literally "see" the current brightness of my screen. Tell me what you think and we will come up with a sane solution. Cheers! Aaron -- Web: https://drkhsh.at/ or http://drkhsh5rv6pnahas.onion/ Gopher: gopher://drkhsh.at or gopher://drkhsh5rv6pnahas.onion GPG: 0x7A65E38D55BE96FE Fingerprint: 4688 907C 8720 3318 0D9F AFDE 7A65 E38D 55BE 96FE
[hackers] [slstatus] ram: fixed int overflow on pagetok macro || Tobias Tschinkowitz
commit 5db729fedbc4b6cb8742c58ff4934afb50732974 Author: Tobias Tschinkowitz AuthorDate: Thu May 24 12:09:26 2018 +0200 Commit: Aaron Marcher CommitDate: Thu May 24 14:51:30 2018 +0200 ram: fixed int overflow on pagetok macro diff --git a/components/ram.c b/components/ram.c index 0ac9753..0333b3b 100644 --- a/components/ram.c +++ b/components/ram.c @@ -75,7 +75,7 @@ #include #define LOG1024 10 - #define pagetok(size, pageshift) ((size) << (pageshift - LOG1024)) + #define pagetok(size, pageshift) (size_t)(size << (pageshift - LOG1024)) inline int load_uvmexp(struct uvmexp *uvmexp)
Re: [hackers] [slstatus][PATCH] ram: fixed int overflow on pagetok macro
Tobias, thank you very much. Cheers! Aaron -- Web: https://drkhsh.at/ or http://drkhsh5rv6pnahas.onion/ Gopher: gopher://drkhsh.at or gopher://drkhsh5rv6pnahas.onion GPG: 0x7A65E38D55BE96FE Fingerprint: 4688 907C 8720 3318 0D9F AFDE 7A65 E38D 55BE 96FE
[hackers] [slstatus][PATCH] ram: fixed int overflow on pagetok macro
--- components/ram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/ram.c b/components/ram.c index 0ac9753..0333b3b 100644 --- a/components/ram.c +++ b/components/ram.c @@ -75,7 +75,7 @@ #include #define LOG1024 10 - #define pagetok(size, pageshift) ((size) << (pageshift - LOG1024)) + #define pagetok(size, pageshift) (size_t)(size << (pageshift - LOG1024)) inline int load_uvmexp(struct uvmexp *uvmexp) -- 2.16.2
Re: [hackers] [slstatus][PATCH] backlight: implemented openbsd support
On Wed, May 23, 2018 at 08:41:17PM +0200, Tobias Tschinkowitz wrote: > Anyway, this is just an proposal. Hopefully there is > another solution to solve this. I know that we could also do this by > linking against xcb-xrandr (like xbacklight does) but i think we should > not do this for now. xbacklight never worked for me on any laptop, I'm not sure it uses the ACPI Video module. Example on a thinkpad X1C5 (works fine using /sys/class/backlight/* files): $ xbacklight -get No outputs have backlight property Regards, -- David