sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 988a574e0282ea41079604200f5bb1762b182530
parent 827a6126fe89e04e40b978721b7ad4a7771b730c
Author: Gunther Klessinger <gunther.klessinger@axiros.com>
Date:   Fri, 11 Jun 2021 22:30:02 +0200

Bugfix: The Panel Was Getting Focus at Tag Switching

Minor Changes
- Made window name configurable
- Removed longer usage example from main wiki page

Since not released I just renamed the dwm patch incl. the fix.

Diffstat:
Mdwm.suckless.org/patches/xfce4-panel/cpu_mon.py | 6++++--
Ddwm.suckless.org/patches/xfce4-panel/dwm-xfce4-panel-20210606-67d76bd.diff | 77-----------------------------------------------------------------------------
Adwm.suckless.org/patches/xfce4-panel/dwm-xfce4-panel-20210611-67d76bd.diff | 123+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Adwm.suckless.org/patches/xfce4-panel/genmon.md | 21+++++++++++++++++++++
Mdwm.suckless.org/patches/xfce4-panel/index.md | 61++++++++++++++++++++++++++-----------------------------------
5 files changed, 174 insertions(+), 114 deletions(-)

diff --git a/dwm.suckless.org/patches/xfce4-panel/cpu_mon.py b/dwm.suckless.org/patches/xfce4-panel/cpu_mon.py @@ -1,7 +1,9 @@ #!/usr/bin/python # coding: utf-8 """ -Custom CPU monitor, mainly for panels. +GENMON APPLET USAGE EXAMPLE + +A Custom CPU monitor. Challenge: We want a bit of history and cpu monitoring anyway needs some delta t. @@ -12,7 +14,7 @@ Hightlights: - cpu per core - top cpu eating process, customized with own config (not colliding with yours of ~/.config/procps) - arbitray long symbol lists, will pick per percent -- output colorized using pandoc +- output colorized using pango Lowlights: Linux Only. Not hard to rewrite, but now it's just Linux, looking into /proc/stat diff --git a/dwm.suckless.org/patches/xfce4-panel/dwm-xfce4-panel-20210606-67d76bd.diff b/dwm.suckless.org/patches/xfce4-panel/dwm-xfce4-panel-20210606-67d76bd.diff @@ -1,77 +0,0 @@ -From 19e1abe590e3fde3244cac544472741fccc881cd Mon Sep 17 00:00:00 2001 -From: Gunther Klessinger <gklessinger@gmx.de> -Date: Sun, 6 Jun 2021 17:56:06 +0200 -Subject: [PATCH] Supporting xfce4-panel in dwm - -We basically treat the panel as special window which -- never has borders -- always has y=0 -- is never shown as active window in the indicators -- is shown on all tags - -Which window? "xfce4-panel" - hardcoded by window name in dwm.c. -=> Should work for other panels as well, if you adapt. - - ---- - config.def.h | 1 + - dwm.c | 10 +++++++++- - 2 files changed, 10 insertions(+), 1 deletion(-) - -diff --git a/config.def.h b/config.def.h -index 1c0b587..b772bd9 100644 ---- a/config.def.h -+++ b/config.def.h -@@ -29,6 +29,7 @@ static const Rule rules[] = { - /* class instance title tags mask isfloating monitor */ - { "Gimp", NULL, NULL, 0, 1, -1 }, - { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, -+ { "Xfce4-panel", NULL, NULL, (1 << 9)-1, 0, -1 }, - }; - - /* layout(s) */ -diff --git a/dwm.c b/dwm.c -index b0b3466..5fafd62 100644 ---- a/dwm.c -+++ b/dwm.c -@@ -710,6 +710,8 @@ drawbar(Monitor *m) - } - - for (c = m->clients; c; c = c->next) { -+ // prevent showing the panel as active application: -+ if (!strcmp(c->name, "xfce4-panel")) continue; - occ |= c->tags; - if (c->isurgent) - urg |= c->tags; -@@ -1049,6 +1051,9 @@ manage(Window w, XWindowAttributes *wa) - c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx) - && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my); - c->bw = borderpx; -+ // no border - even when active -+ // do not match on y, does not have it yet possibly: -+ if (!strcmp(c->name, "xfce4-panel")) c->bw = c->oldbw = 0; - - wc.border_width = c->bw; - XConfigureWindow(dpy, w, CWBorderWidth, &wc); -@@ -1283,6 +1288,9 @@ resizeclient(Client *c, int x, int y, int w, int h) - c->oldw = c->w; c->w = wc.width = w; - c->oldh = c->h; c->h = wc.height = h; - wc.border_width = c->bw; -+ if (!strcmp(c->name, "xfce4-panel")) { -+ c->y = c->oldy = c->bw = wc.y = wc.border_width = 0; -+ } - XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); - configure(c); - XSync(dpy, False); -@@ -1991,7 +1999,7 @@ void - updatestatus(void) - { - if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) -- strcpy(stext, "dwm-"VERSION); -+ strcpy(stext, " "); // no shining of dwm version thru altpanel, when transparent - drawbar(selmon); - } - --- -2.31.1 - diff --git a/dwm.suckless.org/patches/xfce4-panel/dwm-xfce4-panel-20210611-67d76bd.diff b/dwm.suckless.org/patches/xfce4-panel/dwm-xfce4-panel-20210611-67d76bd.diff @@ -0,0 +1,123 @@ +From 7a9b83d0d74f9aca800c1ec0d2e698449c166e86 Mon Sep 17 00:00:00 2001 +From: Gunther Klessinger <gunther.klessinger@axiros.com> +Date: Fri, 11 Jun 2021 21:54:29 +0200 +Subject: [PATCH] Supporting xfce4-panel in dwm + +We treat the panel as special window which +- never has borders +- never has focus +- always has y=0 +- is never shown as active window in the indicators +- is shown on all tags (via config rule) + +Which window? "xfce4-panel" - configurable in config.h + +=> Might work for other panels as well, if you adapt. +--- + config.def.h | 2 ++ + dwm.c | 27 ++++++++++++++++++++------- + 2 files changed, 22 insertions(+), 7 deletions(-) + +diff --git a/config.def.h b/config.def.h +index 1c0b587..3b9e7d6 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -3,6 +3,7 @@ + /* appearance */ + static const unsigned int borderpx = 1; /* border pixel of windows */ + static const unsigned int snap = 32; /* snap pixel */ ++static const char panel[][20] = { "xfce4-panel", "Xfce4-panel" }; /* name & cls of panel win */ + static const int showbar = 1; /* 0 means no bar */ + static const int topbar = 1; /* 0 means bottom bar */ + static const char *fonts[] = { "monospace:size=10" }; +@@ -29,6 +30,7 @@ static const Rule rules[] = { + /* class instance title tags mask isfloating monitor */ + { "Gimp", NULL, NULL, 0, 1, -1 }, + { "Firefox", NULL, NULL, 1 << 8, 0, -1 }, ++ { panel[1], NULL, NULL, (1 << 9) - 1, 0, -1 }, + }; + + /* layout(s) */ +diff --git a/dwm.c b/dwm.c +index b0b3466..a3b618b 100644 +--- a/dwm.c ++++ b/dwm.c +@@ -175,6 +175,7 @@ static long getstate(Window w); + static int gettextprop(Window w, Atom atom, char *text, unsigned int size); + static void grabbuttons(Client *c, int focused); + static void grabkeys(void); ++static int ispanel(Client *c); + static void incnmaster(const Arg *arg); + static void keypress(XEvent *e); + static void killclient(const Arg *arg); +@@ -710,6 +711,8 @@ drawbar(Monitor *m) + } + + for (c = m->clients; c; c = c->next) { ++ // prevent showing the panel as active application: ++ if (ispanel(c)) continue; + occ |= c->tags; + if (c->isurgent) + urg |= c->tags; +@@ -793,11 +796,14 @@ focus(Client *c) + selmon = c->mon; + if (c->isurgent) + seturgent(c, 0); +- detachstack(c); +- attachstack(c); +- grabbuttons(c, 1); +- XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel); +- setfocus(c); ++ // prevents the panel getting focus when tag switching: ++ if (!ispanel(c)) { ++ detachstack(c); ++ attachstack(c); ++ grabbuttons(c, 1); ++ XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel); ++ setfocus(c); ++ } + } else { + XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); + XDeleteProperty(dpy, root, netatom[NetActiveWindow]); +@@ -964,6 +970,11 @@ grabkeys(void) + } + } + ++int ++ispanel(Client *c) { ++ return !strcmp(c->name, panel[0]); ++} ++ + void + incnmaster(const Arg *arg) + { +@@ -1049,7 +1060,8 @@ manage(Window w, XWindowAttributes *wa) + c->y = MAX(c->y, ((c->mon->by == c->mon->my) && (c->x + (c->w / 2) >= c->mon->wx) + && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my); + c->bw = borderpx; +- ++ // no border - even when active ++ if (ispanel(c)) c->bw = c->oldbw = 0; + wc.border_width = c->bw; + XConfigureWindow(dpy, w, CWBorderWidth, &wc); + XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel); +@@ -1283,6 +1295,7 @@ resizeclient(Client *c, int x, int y, int w, int h) + c->oldw = c->w; c->w = wc.width = w; + c->oldh = c->h; c->h = wc.height = h; + wc.border_width = c->bw; ++ if (ispanel(c)) c->y = c->oldy = c->bw = wc.y = wc.border_width = 0; + XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); + configure(c); + XSync(dpy, False); +@@ -1991,7 +2004,7 @@ void + updatestatus(void) + { + if (!gettextprop(root, XA_WM_NAME, stext, sizeof(stext))) +- strcpy(stext, "dwm-"VERSION); ++ strcpy(stext, " "); // no shining of dwm version thru panel, when transparent + drawbar(selmon); + } + +-- +2.31.1 + diff --git a/dwm.suckless.org/patches/xfce4-panel/genmon.md b/dwm.suckless.org/patches/xfce4-panel/genmon.md @@ -0,0 +1,21 @@ +Using the `genmon` Applet +------------------------- + +Any panel offers the possibility to include generic scripts output. +In `xfce4-panel` this is done by the panel item: "Generic Monitor" (genmon). It features output styled with pango markup and mouseover/onclick hooks. + +Here are some `genmon` script collections: +- [xfce4-genmon-scripts](https://awesomeopensource.com/project/xtonousou/xfce4-genmon-scripts) +- [xfce4-genmon-scripts-2](https://github.com/almaceleste/xfce4-genmon-scripts) +- [xfce4-genmon-scripts-3](https://github.com/levimake/xfce4-genmon-panel-scripts) + +Manual is [here](https://docs.xfce.org/panel-plugins/xfce4-genmon-plugin/start#usage). + +Personally I wanted to have CPU monitor which shows the name of current high cpu eater(s) if present (next to current load by core) and on mouseover remembers the top output from the most recent high load situation in the past: + +![genmon.png](genmon.png) + +To get that, I cat the content of a file generated by this script, started in `autostart.sh` in the background: +[cpu_mon.py](cpu_mon.py). + + diff --git a/dwm.suckless.org/patches/xfce4-panel/index.md b/dwm.suckless.org/patches/xfce4-panel/index.md @@ -1,11 +1,15 @@ -# xfce4-panel +xfce4-panel +=========== -## Description +Description +----------- When xfce4 tools are on the system anyway, it might make sense to use the xfce4-panel in dwm. -This patch slightly modifies dwm, so that it treats window with name `xfce4-panel` properly as a status bar, i.e.: +This patch modifies dwm, so that it treats the window with name `xfce4-panel` (default) +as a status bar, i.e.: - it never has borders +- it never has focus - always has y=0 - it is never shown as active window in the tag indicators - it is shown on all tags (via a tag rule in the config) @@ -18,61 +22,48 @@ This patch slightly modifies dwm, so that it treats window with name `xfce4-pane The patch has been created against dwm6.2. -## Download +Download +-------- -* [dwm-xfce4-panel-20210606-67d76bd.diff](dwm-xfce4-panel-20210606-67d76bd.diff) (2021-06-06) +* [dwm-xfce4-panel-20210611-67d76bd.diff](dwm-xfce4-panel-20210611-67d76bd.diff) (2021-06-11) -## Notes +Notes +----- - The workspace switcher won't work (but dwm's tag switcher remains anyway on the left) -- The rest of xfce4's 40 or so panel apps should work (if installed) -- A start via xinitrc should be fine. I start it using the [autostart](https://dwm.suckless.org/patches/autostart/) patch, with `run ./panel.sh` in - `autostart.sh`, with `panel.sh`: +- The rest of xfce4's 40 or so panel apps _should_ work (if installed) +- Startup: A start via xinitrc should be fine. I use the [autostart](https://dwm.suckless.org/patches/autostart/) patch to start + in background: + sleep 0.3 xfce4-panel --disable-wm-check -## Panel Config +Panel Config +------------ + +Done via XFCE4 tools. - Configure exactly one Panel, e.g. via `xfce4-settings-manager` -> `panel` -- Under Tab Display: +- At Tab Display: - Mode Horizontal - - Output: Your top monitor (with y=0), panel will stick there + - Output: Your primary monitor (with y=0). Panel will stay there(!) - Lock Panel: false - Don't reserve space on borders: true - Row size: 23 pixel, 1 row works for me - Autom. increase the length: true -The content of the panel you configure "normally", i.e. by adding items in the panel's items tab or via CLI tools. +The _content_ of the panel you configure "normally", i.e. by adding items in the panel's items tab or via CLI tools. -Having *different* panels in a xfce4 than in a dwm session with the same user I did not try. I guess it should be -possible via the backup and restore tool of the panel UI and [xfconf](https://docs.xfce.org/xfce/xfconf/xfconf-query). +Having *different* panels in a xfce4 than in a dwm session with the same user I did not try. +I guess it should be possible via the backup and restore tool of the panel UI and [xfconf](https://docs.xfce.org/xfce/xfconf/xfconf-query). Tip: *Never* try start `xfce4-session` from within dwm, the warning `Failed to connect to session manager` at panel startup is normal. It will try autoexplore your available workspaces - and conclude you have `2**9`, writing that back into the xfce4 config... I had to manually clean up the config via `xfconf`. ----- - - -## Optional Read: Some Infos About `genmon` - -Any panel offers the possibility to include generic scripts output. -In `xfce4-panel` this is done by the panel item: "Generic Monitor" (genmon). It supports output styled with pango markup and mouseover/onclick hooks. - -Here are some genmon script acollections: -- [xfce4-genmon-scripts](https://awesomeopensource.com/project/xtonousou/xfce4-genmon-scripts) -- [xfce4-genmon-scripts-2](https://github.com/almaceleste/xfce4-genmon-scripts) -- [xfce4-genmon-scripts-3](https://github.com/levimake/xfce4-genmon-panel-scripts) - -Manual is [here](https://docs.xfce.org/panel-plugins/xfce4-genmon-plugin/start#usage). - -Personally I wanted to have CPU monitor which shows the name of current high cpu eater(s) if present (next to current load by core) and on mouseover remembers the top output from the most recent high load situation in the past: - -![genmon.png](genmon.png) +[Here](./genmon.html) is a usage example. -To get that, I cat the content of a file generated by this script, started in `autostart.sh` in the background: -[cpu_mon.py](cpu_mon.py). Author