You are not logged in.

#1551 2019-12-05 23:48:04

2ManyDogs
Forum Moderator
Registered: 2012-01-15
Posts: 3,401

Re: DWM Hackers Unite! Share (or request) dwm patches.

zanculmarktum wrote:

How about having `dwm -q` creating a file called ~/.dwm/quit to give dwm a signal to quit? Can you please do that?

Don't make this more complicated than it needs to be.

Trilby wrote:

How about just `killall dwm`?  Or similarly, `killall xinit` (or startx depending on which you use).  Or you could just use a different key binding that you're less likely to hit by accident.

Offline

#1552 2019-12-06 00:47:08

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 24,454
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

zanculmarktum wrote:

How about having `dwm -q` creating a file called ~/.dwm/quit to give dwm a signal to quit? Can you please do that?

That'd require dwm to constantly check for that file's presence which which would be horribly ugly and inefficient.  It'd be easy to code, but as I'd see that as defacing a masterpiece, no, I will not do that.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Online

#1553 2019-12-07 21:20:36

zanculmarktum
Member
Registered: 2016-09-25
Posts: 10

Re: DWM Hackers Unite! Share (or request) dwm patches.

I've decided to use signal big_smile
The problem with `killall dwm` is that it terminates dwm without giving it chance to run cleanup() function.
https://gitlab.com/zanc/dwm/blob/master … quit.patch

Offline

#1554 2019-12-23 10:14:08

dpx
Member
Registered: 2017-01-09
Posts: 35

Re: DWM Hackers Unite! Share (or request) dwm patches.

With 16:9 monitor, opening single terminal with tiling WM makes text being 'too far to the left', especially with bigger monitors. I got tired of having to sit facing left half of my monitor, so here is modified tile() layout:

  • With single window open, it will center that window simulating old 5:4 monitor size. That was the aspect ratio when monitor aspect ratios made sense.

  • More than one window and it will use standard tile layout.

void
tile54(Monitor *m)
{
        unsigned int i, n, h, mw, my, ty, move;
        Client *c;

        for (n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
        if (n == 0)
                return;

        if (n == 1) {
                mw = m->ww * 0.703125;  // 16:9 to horizontal 5:4
                //mw = m->ww * 0.45;    // 16:9 to vertical 5:4
                move = (m->ww - mw) / 2;
                h = m->wh;
                c = nexttiled(m->clients);
                i = my = ty = 0;
                resize(c, m->wx + move, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
                return;
        }

        if (n > m->nmaster)
                mw = m->nmaster ? m->ww * m->mfact : 0;
        else
                mw = m->ww;
        for (i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
                if (i < m->nmaster) {
                        h = (m->wh - my) / (MIN(n, m->nmaster) - i);
                        resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), 0);
                        my += HEIGHT(c);
                } else {
                        h = (m->wh - ty) / (n - i);
                        resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), 0);
                        ty += HEIGHT(c);
                }
}

Last edited by dpx (2019-12-23 16:30:26)

Offline

#1555 2020-04-20 04:04:05

ltsdw
Member
Registered: 2020-04-20
Posts: 24

Re: DWM Hackers Unite! Share (or request) dwm patches.

So, I was trying to adapt this patch dwm-statuscolors-6.1.diff to apply a top of dwm-6.2, everything was fine and marvelous, until I get into these lines at the dwm.c file:

	for(int i = 0; i < NUMCOLORS; i++){
		scheme[i].border = drw_clr_create(drw, colors[i][0]);
		scheme[i].fg = drw_clr_create(drw, colors[i][1]);
		scheme[i].bg = drw_clr_create(drw, colors[i][2]);
	}

Because it is already used something similar that modifies almost the same lines by this patch dwm-alpha-6.2.diff:

	scheme = ecalloc(LENGTH(colors), sizeof(Clr *));
	for (i = 0; i < LENGTH(colors); i++)
		scheme[i] = drw_scm_create(drw, colors[i], alphas[i], 3);

As I never have programmed in C before I don't know well the logic behind it to adapt my patch, someone could help me get through it, please? smile

Last edited by ltsdw (2020-04-20 08:26:44)

Offline

#1556 2020-07-01 00:44:04

johannesthyssen
Member
Registered: 2020-06-30
Posts: 1

Re: DWM Hackers Unite! Share (or request) dwm patches.

How can I hide all clients but the focused one?

Any ideas on how to hide all clients but the focused one on a keypress? I have tried

 xdo hide -dr 

as suggested in their man page, but it doesn't seem to work in dwm, why? I think an alternative would be to write a function that loops over all clients of the selected tag with

 for (c = nexttiled(selmon->clients); c; c = nexttiled(c->next)); 

an hide them all except from the focused one, but I can't figure out how. I want this so that I can use transparency in monocle layout without being able to see what's behind the selected client. Any ideas?

Offline

#1557 2020-07-01 00:47:31

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 29,049
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

Send them to another tag...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#1558 2020-07-20 10:06:24

kanseidorifto
Member
Registered: 2020-07-20
Posts: 1

Re: DWM Hackers Unite! Share (or request) dwm patches.

Hi! I've been using dwm for a few months but switched to xmonad when I got a triple monitor setup at work due to xmonad's way of handling multi-monitors. There's a patch for dwm the single tagset which is quite outdated and I haven't managed to rewrite it. Are there any alternatives? Do you have anything? I miss dwm. I feel I can't be the only one who misses an updated version of that patch. It is also possible that this functionality goes against the mentality behind dwm workflow, if that is the case, please enlighten me how to correctly use dwm on a multihead setup as having separate tags for each monitor feels a bit akward... TY!

tl;dr need single tagset patch, miss dwm

Last edited by kanseidorifto (2020-07-20 10:07:52)

Offline

#1559 2020-07-29 11:50:07

qurn
Member
Registered: 2017-10-13
Posts: 15

Re: DWM Hackers Unite! Share (or request) dwm patches.

I try to write a function for dwm to change the normal mouse cursor from left to right (discussed here I'll close it when I'm done).

These are the functions i wrote:

void
point_left(const Arg *arg) {
	Client *c;
	Monitor *m;
	c = m->clients;
	cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
	if (XGrabPointer(dpy, root, True, MOUSEMASK, GrabModeAsync, GrabModeAsync,
		c->win, cursor[CurNormal]->cursor, CurrentTime) != GrabSuccess)
		return;

}

void
point_right(const Arg *arg) {
	Client *c;
	Monitor *m;
	c = m->clients;
	cursor[CurNormal] = drw_cur_create(drw, XC_right_ptr);
	if (XGrabPointer(dpy, root, True, MOUSEMASK, GrabModeAsync, GrabModeAsync,
		c->win, cursor[CurNormal]->cursor, CurrentTime) != GrabSuccess)
		return;
}

The pointer works to switch layers, but not in windows.
Note that i barely understand what I hacked together there -.-

Last edited by qurn (2020-07-29 11:50:44)

Offline

#1560 2020-10-04 02:30:21

void03
Member
Registered: 2019-06-09
Posts: 3

Re: DWM Hackers Unite! Share (or request) dwm patches.

I have been using someone else's dwm config that was patched so that when you opened a new app or terminal from either dmenu or from keybinds, you would then switch to that new tag.  Now I am building my dwm I can't for the life of me work out what patch it is that does this, does anyone know what the name for this patch is?

Offline

#1561 2020-10-04 06:29:41

Henkm
Member
From: Dutch living in Malaysia
Registered: 2015-11-11
Posts: 18

Re: DWM Hackers Unite! Share (or request) dwm patches.

void03 wrote:

I have been using someone else's dwm config that was patched so that when you opened a new app or terminal from either dmenu or from keybinds, you would then switch to that new tag.  Now I am building my dwm I can't for the life of me work out what patch it is that does this, does anyone know what the name for this patch is?

I think you mean Switchtotag

Offline

#1562 2020-10-04 06:32:56

void03
Member
Registered: 2019-06-09
Posts: 3

Re: DWM Hackers Unite! Share (or request) dwm patches.

Henkm wrote:
void03 wrote:

I have been using someone else's dwm config that was patched so that when you opened a new app or terminal from either dmenu or from keybinds, you would then switch to that new tag.  Now I am building my dwm I can't for the life of me work out what patch it is that does this, does anyone know what the name for this patch is?

I think you mean Switchtotag

Yep, looks like it.  Thanks for that.

Offline

#1563 2020-10-11 17:42:23

imajiner
Member
Registered: 2020-10-11
Posts: 4

Re: DWM Hackers Unite! Share (or request) dwm patches.

hello,
I'd like a bit customize my dmenu through dwm config.
Im expecting similar like I already tried on bash command like:

 dmenu_run -p "$(date)"

but  when I tried customize the config.h and config.def.h with reference above it failed:

 static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_gray2, "-sf", col_gray4, "-p", "$(date)", NULL }; 

how I accomplish this?
pardon my english grammar and thank you.

Offline

#1564 2020-10-11 18:53:37

GaKu999
Member
From: US/Eastern
Registered: 2020-06-21
Posts: 382

Re: DWM Hackers Unite! Share (or request) dwm patches.

It might be better just to tweak dwm title with xsetroot -name "$(something)"...

Tiny proof of concept:

cpu() {
	local a b c cpu previdle prevtotal idle total rest

	read -r cpu a b c previdle rest </proc/stat
	prevtotal=$((a + b + c + previdle))

	sleep 0.5

	read -r cpu a b c idle rest </proc/stat
	total=$((a + b + c + idle))

	printf '%d\n' $((100 * ((total - prevtotal) - (idle - previdle)) / (total - prevtotal)))
}

status() {
	printf "MPD[%s] • UPKG[%s] • TEMP[%s°F] • CPU[%s%%] • RAM[%sMiB] • DATE[%s]" \
		"$(mpc -f '%artist%:%title%' -q current)" \
		"$(wc -l <"/tmp/checkup-db-${UID:-$(id -u)}/updates")" \
		"$(sensors -f | awk '/^Package/ {print +$4.}')" \
		"$(cpu)" \
		"$(free -m | awk '/^Mem/ {print $7}')" \
		"$(date '+%A %d %R')"
}

while xsetroot -name "$(status)"
do sleep 2
done &

But that's not the only way, you can do it anyway you wish, and I'm still working on the coloring...


My reposSome snippets

Heisenberg might have been here.

Offline

#1565 2020-10-11 20:07:36

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 24,454
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

imajiner wrote:

dmenucmd[] = { "dmenu_run", ... "$(date)" ...

That will not work because dmenucmd is not parsed by a shell.  So this passes a literal string $(date) as an argument to the -p flag.  This is not the equivalent to `dmenu_run -p "$(date)"` but it is the equivalent to `dmenu_run -p '$(date)'`.

If you want the arguments to be parsed by a shell, you need to invoke a shell but then you'd not be able to use variables for colors, font, and the like.  These aren't actually variables anyways, but are just constants defined elsewhere in config.h, so you could insert each of them:

static const char *dmenucmd[] = { "sh", "-c", "dmenu_run -m 0 -fn monospace:size=10 -nb #222222 ... -p $(date)", NULL }; 

That said, patching dmenu_run would be a much cleaner approach as it is already a shell script.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Online

#1566 2020-10-11 23:52:52

imajiner
Member
Registered: 2020-10-11
Posts: 4

Re: DWM Hackers Unite! Share (or request) dwm patches.

GaKu999 wrote:

It might be better just to tweak dwm title with xsetroot -name "$(something)"...

Tiny proof of concept:

cpu() {
	local a b c cpu previdle prevtotal idle total rest

	read -r cpu a b c previdle rest </proc/stat
	prevtotal=$((a + b + c + previdle))

	sleep 0.5

	read -r cpu a b c idle rest </proc/stat
	total=$((a + b + c + idle))

	printf '%d\n' $((100 * ((total - prevtotal) - (idle - previdle)) / (total - prevtotal)))
}

status() {
	printf "MPD[%s] • UPKG[%s] • TEMP[%s°F] • CPU[%s%%] • RAM[%sMiB] • DATE[%s]" \
		"$(mpc -f '%artist%:%title%' -q current)" \
		"$(wc -l <"/tmp/checkup-db-${UID:-$(id -u)}/updates")" \
		"$(sensors -f | awk '/^Package/ {print +$4.}')" \
		"$(cpu)" \
		"$(free -m | awk '/^Mem/ {print $7}')" \
		"$(date '+%A %d %R')"
}

while xsetroot -name "$(status)"
do sleep 2
done &

But that's not the only way, you can do it anyway you wish, and I'm still working on the coloring...

yes, thank you for the answer.
I'am aware of xsetroot for simple date.
the thing is, I set my dwm bar to hidden by default and prefer it that way, up until now when i check the date always open the terminal and write date and now it became a habit.
so i prefer print the date on dmenu as a prompt instead. thanks

Trilby wrote:
imajiner wrote:

dmenucmd[] = { "dmenu_run", ... "$(date)" ...

That will not work because dmenucmd is not parsed by a shell.  So this passes a literal string $(date) as an argument to the -p flag.  This is not the equivalent to `dmenu_run -p "$(date)"` but it is the equivalent to `dmenu_run -p '$(date)'`.

If you want the arguments to be parsed by a shell, you need to invoke a shell but then you'd not be able to use variables for colors, font, and the like.  These aren't actually variables anyways, but are just constants defined elsewhere in config.h, so you could insert each of them:

static const char *dmenucmd[] = { "sh", "-c", "dmenu_run -m 0 -fn monospace:size=10 -nb #222222 ... -p $(date)", NULL }; 

That said, patching dmenu_run would be a much cleaner approach as it is already a shell script.

I see, thank you for the explanation.
already tried this, but doesn't work.

static const char *dmenucmd[] = { "sh", "-c", "dmenu_run -m 0 -fn monospace:size=10 -nb #222222 ... -p $(date)", NULL }; 

and so I'm thinking of add time/date module at dwm.c something like this one.

#include <stdio.h>
#include <time.h>

int main ( void )
{
        time_t now;
        now = time ( NULL );
        printf ( "%s", ctime ( &now ) );
        return 0;
}

but I'am not understand the C languange yet, and the most turorial i saw always show how to print them and not how to store or pass them as variable.
pardon my grammar and thank you anyway.

Offline

#1567 2020-10-12 00:19:11

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 24,454
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

imajiner wrote:

already tried this, but doesn't work.

What does "doesn't work" mean?  You didn't literally copy and paste that did you?  The elipses were just a place holder, you'd need to fill in all the parameters.

Using C code to generate the date will not work either as - again - the placeholders in dmenucmd are not actually variables, they are constants.  Strictly speaking, you could put an actual variable string in there if needed, but you can't put in executable code.  So unless you had another thread running and updating the time in the variable (which would be quite ugly) that would not work.

Again, the best solution would be to patch /bin/dmenu_run which would be *very* easy to do:

- dmenu_path | dmenu "$@" | ${SHELL:-"/bin/sh"} &
+ dmenu_path | dmenu "$@" -p "$(date)" | ${SHELL:-"/bin/sh"} &

That's it.  Then just use dmenucmd in config.h to set colors and font as usual.

edit: s/\$"/"$/

Last edited by Trilby (2020-10-12 20:46:07)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Online

#1568 2020-10-12 20:42:59

imajiner
Member
Registered: 2020-10-11
Posts: 4

Re: DWM Hackers Unite! Share (or request) dwm patches.

Trilby wrote:
imajiner wrote:

already tried this, but doesn't work.

What does "doesn't work" mean?  You didn't literally copy and paste that did you?  The elipses were just a place holder, you'd need to fill in all the parameters.

Using C code to generate the date will not work either as - again - the placeholders in dmenucmd are not actually variables, they are constants.  Strictly speaking, you could put an actual variable string in there if needed, but you can't put in executable code.  So unless you had another thread running and updating the time in the variable (which would be quite ugly) that would not work.

Again, the best solution would be to patch /bin/dmenu_run which would be *very* easy to do:

- dmenu_path | dmenu "$@" | ${SHELL:-"/bin/sh"} &
+ dmenu_path | dmenu "$@" -p $"(date)" | ${SHELL:-"/bin/sh"} &

That's it.  Then just use dmenucmd in config.h to set colors and font as usual.

ah pardon me, here's the code,

static const char *dmenucmd[] = { "sh", "-c", "dmenu_run -m 0 -fn xos4 Terminus:size=10 -nb #222222 -nf #bbbbbb -sb #444444 -sf #eeeeee -p $(date)", NULL };

I'm assuming it may fail becuse the date parameter need quote, so I tried to add a single quotes or double quotes for $(date) but still doesn't work as well. maybe I was wrong.

but your second solution work very well, and a bit typo correct for the dollar sign outside the quotes.

dmenu_path | dmenu "$@" -p "$(date)" | ${SHELL:-"/bin/sh"} &

anyway thank you so much.

Offline

#1569 2020-10-12 20:48:01

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 24,454
Website

Re: DWM Hackers Unite! Share (or request) dwm patches.

Sorry about the typo.  In hindsight a slightly different version would be better:

dmenu_path | dmenu -p "$(date)" "@" | ${SHELL:-"/bin/sh"} &

This was the date becomes a default prompt if no other is provided, but if another prompt is provided on the command line to dmenu_run it will be used (the last -p flag on the command line takes precedence).


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Online

#1570 2020-10-12 22:13:49

imajiner
Member
Registered: 2020-10-11
Posts: 4

Re: DWM Hackers Unite! Share (or request) dwm patches.

Yes agreed, it more be convenience since dmenu can be hack onto something else.
it was better than the original I want to.

Last edited by imajiner (2020-10-12 22:16:23)

Offline

Board footer

Powered by FluxBB