commit c60a120fd3738654cfbe14e7c09da2b20152b9e0
Author: Gunther Klessinger <[email protected]>
Date: Sun Mar 6 11:57:49 2022 +0100
xfce4-panel: new version
- better monitor switch behaviour
- less intrusive patch
- improved docs (incl. refs to tools)
diff --git
a/dwm.suckless.org/patches/xfce4-panel/dwm-xfce4-panel-20220306-d39e2f3.diff
b/dwm.suckless.org/patches/xfce4-panel/dwm-xfce4-panel-20220306-d39e2f3.diff
new file mode 100644
index 00000000..67135f82
--- /dev/null
+++ b/dwm.suckless.org/patches/xfce4-panel/dwm-xfce4-panel-20220306-d39e2f3.diff
@@ -0,0 +1,147 @@
+From 2cf1eff75a6dc6ee21ed37f4f57a1eb4bf588b9f Mon Sep 17 00:00:00 2001
+From: Gunther Klessinger <[email protected]>
+Date: Sun, 6 Mar 2022 10:32:29 +0100
+Subject: [PATCH] fix: Fixing problems at monitor setup changes
+
+- Panel was sometimes out of place when monitor setup was changed on the
+ fly
+- Patch less intrusive than the previous one.
+- Tested with dwm6.3 and 6.2.
+---
+ config.def.h | 2 ++
+ dwm.c | 36 +++++++++++++++++++++++++++++-------
+ 2 files changed, 31 insertions(+), 7 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index a2ac963..eaf909e 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, 1, -1 },
+ };
+
+ /* layout(s) */
+diff --git a/dwm.c b/dwm.c
+index a96f33c..458f3dc 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);
+@@ -713,6 +714,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;
+@@ -796,11 +799,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]);
+@@ -833,6 +839,7 @@ focusmon(const Arg *arg)
+ focus(NULL);
+ }
+
++int focussed_panel = 0; // helper for focusstack, avoids loops when panel is
the only client
+ void
+ focusstack(const Arg *arg)
+ {
+@@ -857,6 +864,12 @@ focusstack(const Arg *arg)
+ focus(c);
+ restack(selmon);
+ }
++ // skipping the panel when switching focus:
++ if (ispanel(c) && focussed_panel == 0) {
++ focussed_panel = 1;
++ focusstack(arg);
++ focussed_panel = 0;
++ }
+ }
+
+ Atom
+@@ -967,6 +980,11 @@ grabkeys(void)
+ }
+ }
+
++int
++ispanel(Client *c) {
++ return !strcmp(c->name, panel[0]);
++}
++
+ void
+ incnmaster(const Arg *arg)
+ {
+@@ -1053,6 +1071,8 @@ manage(Window w, XWindowAttributes *wa)
+ && (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);
+@@ -1272,7 +1292,7 @@ recttomon(int x, int y, int w, int h)
+ void
+ resize(Client *c, int x, int y, int w, int h, int interact)
+ {
+- if (applysizehints(c, &x, &y, &w, &h, interact))
++ if (ispanel(c) || applysizehints(c, &x, &y, &w, &h, interact))
+ resizeclient(c, x, y, w, h);
+ }
+
+@@ -1286,6 +1306,8 @@ 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;
++ // nail it to no border & y=0:
++ 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);
+@@ -1994,7 +2016,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/index.md
b/dwm.suckless.org/patches/xfce4-panel/index.md
index af0821d2..f5671efb 100644
--- a/dwm.suckless.org/patches/xfce4-panel/index.md
+++ b/dwm.suckless.org/patches/xfce4-panel/index.md
@@ -4,38 +4,44 @@ xfce4-panel
Description
-----------
-When xfce4 tools are on the system anyway, it might make sense to use the
xfce4-panel in dwm.
+When xfce4 tools are on the system anyway, it might make sense to try
`xfce4-panel` in dwm.
+
This patch modifies dwm, so that it treats any window with name `xfce4-panel`
(default)
as a status bar, i.e.:
- it never has borders
-- it never has focus
-- always has y=0
+- always has y=0 on the monitor it is shown at (see below)
- it is never shown as active window in the tag indicators
- it is shown on all tags (via a tag rule in the config)
- it is ignored on `focusstack` (MOD+j / MOD+k)

-- The panel does act as systray for third party tools, i.e. the systray patch
is no more required
+- The panel does also act as **systray** for third party tools
- Looks best when background is set to same color as the dwm statusline (black
in the example)
- Using a compositor you can dimm or completely hide it, when not hovered
-The patch has been created against dwm6.2.
+The patch has been created against dwm6.3 but will apply on 6.2 as well.
Download
--------
-*
[dwm-xfce4-panel-20210701-67d76bd.diff](dwm-xfce4-panel-20210701-67d76bd.diff)
(2021-07-01)
+*
[dwm-xfce4-panel-20220306-d39e2f3.diff](dwm-xfce4-panel-20220306-d39e2f3.diff)
(2022-03-06)
+
+* Older version(s):
+
+ -
[dwm-xfce4-panel-20210701-67d76bd.diff](dwm-xfce4-panel-20210701-67d76bd.diff)
(2021-07-01)
Notes
-----
-- The workspace switcher won't work interactively, but dwm's interactive tag
indicators remain on the left anyway.
-- Some actions in the "session menu" applet (the one with your name as title)
won't work out of the box. You might supply your own sub menu or modify the
actions of the existing one.
-- The rest of xfce4's 40 or so panel apps _should_ work (if installed) and
also custom "applets" (see below) are working
-- Startup: A start via xinitrc should be fine. I use the
[autostart](https://dwm.suckless.org/patches/autostart/) patch to start
- in background:
+- The workspace switcher won't work interactively, but dwm's interactive tag
indicators remain on
+ the left anyway.
+- Some actions in the "session menu" applet (the one with your name as title)
won't work out of the
+ box. You might supply your own sub menu or modify the actions of the
existing one.
+- The rest of xfce4's 40 or so panel apps _should_ work (if installed) and
also custom "applets"
+ (see below) are working
+- 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
@@ -44,42 +50,56 @@ Notes
Panel Config
------------
-**dwm**
-In dwm's rules, the panel should be configured to be shown on all tags - see
the patch.
-
-**xrandr**:
-Since the panel will reside always at `y=0`, a matching xrandr screenlayout
must contain `--pos 0x0` for the monitor where the panel should be shown. That
monitor must be connected, otherwise the panel won't be visible or pop up in
the middle of another monitor. When you unplug that monitor, you need to have a
valid new screen layout loaded. I use the monitor marked `--primary`. The
[`arandr`](https://christian.amsuess.com/tools/arandr/) tool will create valid
configs. I always have a fallback layout, with the laptop display configured
primary, at `0x0`.
+**dwm**
- # Example:
- xrandr --output eDP-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal
+In dwm `config.h` rules, the panel should be configured to be shown on all
tags and floating - see the patch.
-You can verify your screen layout using e.g. the `xev` tool, which reports the
mouse coordinates relative to root.
+**xfce4-panel**
-**xfce4-panel config**:
-The rest of the config is done via XFCE4's internal tools, available e.g. via
`xfce4-settings-manager` -> panel:
+You can inspect and set attributes in the command line via `xconf-query` (you
could also do it via
+right mouse click and go to panel settings).
-- Configure exactly one Panel, e.g. via `xfce4-settings-manager` -> `panel`
-- At Tab Display:
+Here are *all* settings as I have it:
- - Mode Horizontal
- - Output: Your primary monitor (with y=0). Panel will stay there(!)
- - Lock Panel: false
- - Row size: Should probably match height of dwm statusbar, which depends
on your dwm font size.
- - Autom. increase the length: true
- - Length: 1% (will auto adapt)
+ ~ ❯ xfconf-query -c xfce4-panel -p /panels/panel-1 -lv
+ /panels/panel-1/autohide-behavior 0
+ /panels/panel-1/background-alpha 1
+ /panels/panel-1/background-rgba <<UNSUPPORTED>>
+ /panels/panel-1/background-style 1
+ /panels/panel-1/disable-struts true
+ /panels/panel-1/enter-opacity 100
+ /panels/panel-1/icon-size 0
+ /panels/panel-1/leave-opacity 45
+ /panels/panel-1/length 5
+ /panels/panel-1/length-adjust true
+ /panels/panel-1/nrows 1
+ /panels/panel-1/output-name Primary
+ /panels/panel-1/plugin-ids <<UNSUPPORTED>>
+ /panels/panel-1/position p=0;x=5000;y=0
+ /panels/panel-1/position-locked true
+ /panels/panel-1/size 21
+ /panels/panel-1/span-monitors false
-- At Tab Appearance:
+Discussion:
- - Adjust icon size automatically
- - Autohide when not hovered: Run a compositor e.g. `picom` and set panel's
"leave opacity" to 0. That way you could have a minimalistic dwm statusbar
normally and the full interactive status bar only on mouse over. I prefer to
rather dimm it down to an unobtrusive 30%.
+- `position`: Configure the position to be at `y=0` and `x=<a big number>` to
get a panel top right
+ (it will *use* the maximum possible x). See
[here](https://forum.xfce.org/viewtopic.php?id=12149) for more on that.
+ xfconf-query -c xfce4-panel -p /panels/panel-1/position -s
'p=0;x=5000;y=0' # -s: Set a value
+- `leave-opacity`: Requires a compositor like picom. Set it to 0 to completely
hide the panel when
+ not hovered.
+- `size`: 21 matches the height of dwm status bar
+- `output-name`: Set to "Primary" instead of a fixed display name, in order to
have support for
+ multi monitor layouts.
-Also the _content_ of the panel you configure "normally", i.e. by adding items
in the panel's items tab or via [CLI
tools](https://docs.xfce.org/xfce/xfconf/xfconf-query).
+**Multi Monitor Support**
-Tips:
+I recommend using
-- The warning `Failed to connect to session manager` at panel startup is
normal. I do not advise to start `xfce4-session` from within dwm to fix it.
This will try auto explore your available workspaces - and possibly conclude
you have `2**9 * monitor count`, writing that back into the xfce4 config. I had
to manually clean up the config via
[xfconf](https://docs.xfce.org/xfce/xfconf/xfconf-query).
-- Using xfconf and the panel config backup/restore tool might be the best way
to have *different* panel setups in xfce4 and dwm, should you want to use xfce4
as well, where people often run more than one panel.
+- [`arandr`](https://christian.amsuess.com/tools/arandr/) to *create* a new
layout
+- [`autorandr`](https://github.com/phillipberndt/autorandr) to store and
*apply* a layout automatically after
+ state changes (via `autorandr -c`). This also supports hooks after switching.
+---
Below is a usage example for adding your own information into the panel.