Compare commits

...

10 Commits

Author SHA1 Message Date
Sravan Balaji
d8b91c7e8b Add window rule for heroic games launcher 2024-08-13 18:24:06 -04:00
Sravan Balaji
d0f7c11925 Merge remote-tracking branch 'upstream/master' 2024-08-06 15:29:09 -04:00
bakkeby
36cbcf53a2 IPC: do not bail on events from unknown file descriptors ref. #433
The natural cycle for dwm-msg is that:
   - the client registers
   - the client sends a message
   - a response is sent back
   - the client deregisters

There is a race condition such that a new client may end up with the same
file descriptor as another command that is deregistering, resulting in a
message to come through from a file descriptor that is not registered.

The handling of this situation is that the IPC patch will log:

   Got event from unknown fd 7, ptr 0x7, u32 7, u64 7 with events 17

before gracefully stopping (exiting) dwm.

The consequence of the error itself seems benign and the proposal here is
to allow dwm to keep running despite not being able to process the dwm-msg
command successfully.
2024-08-01 14:56:48 +02:00
Sravan Balaji
bbfe23ff81 Merge remote-tracking branch 'upstream/master' 2024-07-14 09:14:30 -04:00
bakkeby
f4258747be Swallow + noborder compatibility changes ref. #430 2024-07-14 14:27:11 +02:00
bakkeby
3bc91e187c Removing debug print statement 2024-07-14 14:26:45 +02:00
Sravan Balaji
a10bfa96db Merge remote-tracking branch 'upstream/master' 2024-07-12 20:06:29 -04:00
bakkeby
f67b8be209 status2d: make sure to terminate the copied text with a NULL character 2024-07-12 19:22:24 +02:00
bakkeby
df75e113a9 launcher + status2d: correct spacing to be the same as when not using status2d 2024-07-12 16:28:46 +02:00
bakkeby
b4b19e3a4c Adding launcher patch 2024-07-11 22:38:58 +02:00
13 changed files with 187 additions and 11 deletions

View File

@@ -19,6 +19,8 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6
### Changelog:
2024-07-11 - Added variant of the launcher patch
2024-01-31 - Added the placedir patch
2023-12-22 - Added the do-not-die-on-color-allocation-failure patch
@@ -522,6 +524,9 @@ Browsing patches? There is a [map of patches](https://coggle.it/diagram/X9IiSSM6
- [killunsel](https://dwm.suckless.org/patches/killunsel/)
- kills all visible clients that are not selected (only the selected client will remain)
- [launcher](https://dwm.suckless.org/patches/launcher/)
- adds buttons to the bar that can be used to launch applications
- [~leftlayout~](http://dwm.suckless.org/patches/leftlayout/)
- ~moves the layout symbol in the status bar to the left hand side~

View File

@@ -19,6 +19,7 @@
- [[#dwm-blocks][DWM Blocks]]
- [[#fancy-bar][Fancy Bar]]
- [[#flex-win-title][Flex Win Title]]
- [[#bar-launcher][Bar Launcher]]
- [[#layout-menu][Layout Menu]]
- [[#layout-symbol][Layout Symbol]]
- [[#powerline][Powerline]]
@@ -198,6 +199,7 @@
- [[#make-config][Make Config]]
- [[#makefile][Makefile]]
- [[#dwm-configuration][DWM Configuration]]
- [[#helper-macros-for-spawning-commands][Helper Macros for Spawning Commands]]
- [[#appearance][Appearance]]
- [[#indicators][Indicators]]
- [[#colors][Colors]]
@@ -209,6 +211,7 @@
- [[#set-colors][Set Colors]]
- [[#powerline-1][Powerline]]
- [[#layout-menu-1][Layout Menu]]
- [[#bar-launcher-1][Bar Launcher]]
- [[#autostart][Autostart]]
- [[#scratchpads][Scratchpads]]
- [[#tags-1][Tags]]
@@ -309,6 +312,8 @@ Browsing patches? There is a [[https://coggle.it/diagram/X9IiSSM6PTWOM9Wz][map o
** Changelog
2024-07-11 - Added variant of the launcher patch
2024-01-31 - Added the placedir patch
2023-12-22 - Added the do-not-die-on-color-allocation-failure patch
@@ -771,6 +776,9 @@ Browsing patches? There is a [[https://coggle.it/diagram/X9IiSSM6PTWOM9Wz][map o
- [[https://dwm.suckless.org/patches/killunsel/][killunsel]]
- kills all visible clients that are not selected (only the selected client will remain)
- [[https://dwm.suckless.org/patches/launcher/][launcher]]
- adds buttons to the bar that can be used to launch applications
- +[[http://dwm.suckless.org/patches/leftlayout/][leftlayout]]+
- +moves the layout symbol in the status bar to the left hand side+
@@ -1210,6 +1218,16 @@ Being an evolution of the bartabgroups patch the flexwintitle patch specifically
#define BAR_FLEXWINTITLE_PATCH 0
#+END_SRC
*** Bar Launcher
Adds buttons to the bar that can be used to launch applications.
https://dwm.suckless.org/patches/launcher/
#+BEGIN_SRC c :tangle patches.def.h
#define BAR_LAUNCHER_PATCH 0
#+END_SRC
*** Layout Menu
This patch adds a context menu for layout switching.
@@ -3677,6 +3695,13 @@ uninstall:
* DWM Configuration
** Helper Macros for Spawning Commands
#+BEGIN_SRC c :tangle config.def.h
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
#define CMD(...) { .v = (const char*[]){ __VA_ARGS__, NULL } }
#+END_SRC
** Appearance
#+BEGIN_SRC c :tangle config.def.h
@@ -4212,6 +4237,18 @@ static const char *layoutmenu_cmd = "layoutmenu.sh";
#endif
#+END_SRC
** Bar Launcher
#+BEGIN_SRC c :tangle config.def.h
#if BAR_LAUNCHER_PATCH
static const Launcher launchers[] = {
/* icon to display command */
{ "surf", CMD("surf", "duckduckgo.com") },
};
#endif // BAR_LAUNCHER_PATCH
#+END_SRC
** Autostart
#+BEGIN_SRC c :tangle config.def.h
@@ -4364,6 +4401,7 @@ static const Rule rules[] = {
RULE(.class = "PrismLauncher", .tags = 1 << 7)
RULE(.class = "antimicrox", .tags = 1 << 7)
RULE(.class = "ProtonUp-Qt", .tags = 1 << 7)
RULE(.class = "heroic", .tags = 1 << 7)
RULE(.class = "Thunar", .tags = 1 << 8)
RULE(.class = "Syncthing GTK", .tags = 1 << 8)
RULE(.class = "Nyrna", .tags = 1 << 8)
@@ -4431,6 +4469,9 @@ static const BarRule barrules[] = {
#if BAR_STATUSBUTTON_PATCH
{ -1, 0, BAR_ALIGN_LEFT, width_stbutton, draw_stbutton, click_stbutton, NULL, "statusbutton" },
#endif // BAR_STATUSBUTTON_PATCH
#if BAR_LAUNCHER_PATCH
{ -1, 0, BAR_ALIGN_LEFT, width_launcher, draw_launcher, click_launcher, NULL, "launcher" },
#endif // BAR_LAUNCHER_PATCH
#if BAR_POWERLINE_TAGS_PATCH
{ 0, 0, BAR_ALIGN_LEFT, width_pwrl_tags, draw_pwrl_tags, click_pwrl_tags, hover_pwrl_tags, "powerline_tags" },
#endif // BAR_POWERLINE_TAGS_PATCH
@@ -4767,11 +4808,6 @@ static const char *xkb_layouts[] = {
#endif // BAR_HOLDBAR_PATCH
#+END_SRC
#+BEGIN_SRC c :tangle config.def.h
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
#+END_SRC
#+BEGIN_SRC c :tangle config.def.h
#if !NODMENU_PATCH
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */

View File

@@ -1,3 +1,6 @@
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
#define CMD(...) { .v = (const char*[]){ __VA_ARGS__, NULL } }
#if ROUNDED_CORNERS_PATCH
static const unsigned int borderpx = 0; /* border pixel of windows */
static const int corner_radius = 10;
@@ -425,6 +428,13 @@ static char *statuscolors[][ColCount] = {
static const char *layoutmenu_cmd = "layoutmenu.sh";
#endif
#if BAR_LAUNCHER_PATCH
static const Launcher launchers[] = {
/* icon to display command */
{ "surf", CMD("surf", "duckduckgo.com") },
};
#endif // BAR_LAUNCHER_PATCH
#if COOL_AUTOSTART_PATCH
static const char *const autostart[] = {
"st", NULL,
@@ -511,6 +521,7 @@ static const Rule rules[] = {
RULE(.class = "PrismLauncher", .tags = 1 << 7)
RULE(.class = "antimicrox", .tags = 1 << 7)
RULE(.class = "ProtonUp-Qt", .tags = 1 << 7)
RULE(.class = "heroic", .tags = 1 << 7)
RULE(.class = "Thunar", .tags = 1 << 8)
RULE(.class = "Syncthing GTK", .tags = 1 << 8)
RULE(.class = "Nyrna", .tags = 1 << 8)
@@ -553,6 +564,9 @@ static const BarRule barrules[] = {
#if BAR_STATUSBUTTON_PATCH
{ -1, 0, BAR_ALIGN_LEFT, width_stbutton, draw_stbutton, click_stbutton, NULL, "statusbutton" },
#endif // BAR_STATUSBUTTON_PATCH
#if BAR_LAUNCHER_PATCH
{ -1, 0, BAR_ALIGN_LEFT, width_launcher, draw_launcher, click_launcher, NULL, "launcher" },
#endif // BAR_LAUNCHER_PATCH
#if BAR_POWERLINE_TAGS_PATCH
{ 0, 0, BAR_ALIGN_LEFT, width_pwrl_tags, draw_pwrl_tags, click_pwrl_tags, hover_pwrl_tags, "powerline_tags" },
#endif // BAR_POWERLINE_TAGS_PATCH
@@ -860,9 +874,6 @@ static const char *xkb_layouts[] = {
#define HOLDKEY 0 // replace 0 with the keysym to activate holdbar
#endif // BAR_HOLDBAR_PATCH
/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
#if !NODMENU_PATCH
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
#endif // NODMENU_PATCH

1
dwm.c
View File

@@ -3313,7 +3313,6 @@ run(void)
event_fd, events[i].data.ptr, events[i].data.u32,
events[i].data.u64);
fprintf(stderr, " with events %d\n", events[i].events);
return;
}
}
}

81
patch/bar_launcher.c Normal file
View File

@@ -0,0 +1,81 @@
#if BAR_STATUS2D_PATCH
int
width_launcher(Bar *bar, BarArg *a)
{
int i, x = 0;
for (i = 0; i < LENGTH(launchers); i++) {
x += status2dtextlength(launchers[i].name) + lrpad;
}
return x;
}
int
draw_launcher(Bar *bar, BarArg *a)
{
int i, w = 0;;
for (i = 0; i < LENGTH(launchers); i++) {
w = status2dtextlength(launchers[i].name);
drawstatusbar(a, launchers[i].name);
a->x += w + lrpad;
}
return a->x ;
}
int
click_launcher(Bar *bar, Arg *arg, BarArg *a)
{
int i, x = 0;
for (i = 0; i < LENGTH(launchers); i++) {
x += status2dtextlength(launchers[i].name) + lrpad;
if (a->x < x) {
spawn(&launchers[i].command);
break;
}
}
return -1;
}
#else
int
width_launcher(Bar *bar, BarArg *a)
{
int i, x = 0;
for (i = 0; i < LENGTH(launchers); i++) {
x += TEXTW(launchers[i].name);
}
return x;
}
int
draw_launcher(Bar *bar, BarArg *a)
{
int i, x = 0, w = 0;;
for (i = 0; i < LENGTH(launchers); i++) {
w = TEXTW(launchers[i].name);
drw_text(drw, x, 0, w, bh, lrpad / 2, launchers[i].name, 0, True);
x += w;
}
return x;
}
int
click_launcher(Bar *bar, Arg *arg, BarArg *a)
{
int i, x = 0;
for (i = 0; i < LENGTH(launchers); i++) {
x += TEXTW(launchers[i].name);
if (a->x < x) {
spawn(&launchers[i].command);
break;
}
}
return -1;
}
#endif // BAR_STATUS2D_PATCH

8
patch/bar_launcher.h Normal file
View File

@@ -0,0 +1,8 @@
typedef struct {
char* name;
const Arg command;
} Launcher;
static int width_launcher(Bar *bar, BarArg *a);
static int draw_launcher(Bar *bar, BarArg *a);
static int click_launcher(Bar *bar, Arg *arg, BarArg *a);

View File

@@ -15,4 +15,3 @@ click_ltsymbol(Bar *bar, Arg *arg, BarArg *a)
{
return ClkLtSymbol;
}

View File

@@ -1,4 +1,3 @@
static int width_ltsymbol(Bar *bar, BarArg *a);
static int draw_ltsymbol(Bar *bar, BarArg *a);
static int click_ltsymbol(Bar *bar, Arg *arg, BarArg *a);

View File

@@ -96,6 +96,7 @@ drawstatusbar(BarArg *a, char* stext)
#else
memcpy(text, stext, len);
#endif // BAR_STATUSCMD_PATCH
text[len] = '\0';
x += lrpad / 2;
drw_setscheme(drw, scheme[LENGTH(colors)]);

View File

@@ -21,6 +21,9 @@
#if COMBO_PATCH
#include "combo.c"
#endif
#if BAR_LAUNCHER_PATCH
#include "bar_launcher.c"
#endif
#if BAR_LTSYMBOL_PATCH
#include "bar_ltsymbol.c"
#endif

View File

@@ -24,6 +24,9 @@
#if BAR_HOLDBAR_PATCH
#include "bar_holdbar.h"
#endif
#if BAR_LAUNCHER_PATCH
#include "bar_launcher.h"
#endif
#if BAR_LTSYMBOL_PATCH
#include "bar_ltsymbol.h"
#endif

View File

@@ -13,6 +13,9 @@ swallow(Client *p, Client *c)
{
Client *s;
XWindowChanges wc;
#if NOBORDER_PATCH
int border_padding = 0;
#endif // NOBORDER_PATCH
if (c->noswallow > 0 || c->isterminal)
return 0;
@@ -46,9 +49,21 @@ swallow(Client *p, Client *c)
setfloatinghint(s);
#endif // BAR_EWMHTAGS_PATCH
#if NOBORDER_PATCH
wc.border_width = p->bw;
if (noborder(p)) {
wc.border_width = 0;
border_padding = p->bw * 2;
}
XConfigureWindow(dpy, p->win, CWBorderWidth, &wc);
XMoveResizeWindow(dpy, p->win, s->x, s->y, s->w + border_padding, s->h + border_padding);
#else
wc.border_width = p->bw;
XConfigureWindow(dpy, p->win, CWBorderWidth, &wc);
XMoveResizeWindow(dpy, p->win, s->x, s->y, s->w, s->h);
#endif // NOBORDER_PATCH
#if !BAR_FLEXWINTITLE_PATCH
XSetWindowBorder(dpy, p->win, scheme[SchemeNorm][ColBorder].pixel);
#endif // BAR_FLEXWINTITLE_PATCH
@@ -65,6 +80,9 @@ unswallow(Client *c)
{
XWindowChanges wc;
c->win = c->swallowing->win;
#if NOBORDER_PATCH
int border_padding = 0;
#endif // NOBORDER_PATCH
free(c->swallowing);
c->swallowing = NULL;
@@ -80,9 +98,20 @@ unswallow(Client *c)
arrange(c->mon);
XMapWindow(dpy, c->win);
#if NOBORDER_PATCH
wc.border_width = c->bw;
if (noborder(c)) {
wc.border_width = 0;
border_padding = c->bw * 2;
}
XConfigureWindow(dpy, c->win, CWBorderWidth, &wc);
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w + border_padding, c->h + border_padding);
#else
wc.border_width = c->bw;
XConfigureWindow(dpy, c->win, CWBorderWidth, &wc);
XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
#endif // NOBORDER_PATCH
#if !BAR_FLEXWINTITLE_PATCH
XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel);
#endif // BAR_FLEXWINTITLE_PATCH

View File

@@ -8,6 +8,8 @@
#define BAR_FLEXWINTITLE_PATCH 0
#define BAR_LAUNCHER_PATCH 0
#define BAR_LAYOUTMENU_PATCH 0
#define BAR_LTSYMBOL_PATCH 0