You are not logged in.

#1 2010-03-10 16:02:09

simongmzlj
Member
From: Canada
Registered: 2008-11-06
Posts: 135

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

I'm not interested in getting yet another conversation about how people configuring their dwm or in having yet another thread full of screenshots. I'm starting this thread so people have a channel to share their dwm patches and hacks. Feel free to make requests or ask for help as well with your own endeavors as well.

Here are mine:
nbalanced
Its a one or two line tweak of nmaster.c. Behaves saner, imho. It no longer rushes to fill the master area, behaving kinda like gaplessgrid until the nmaster "level" is reached. Probably not the best name, but meh. Both tile and bstack version are "corrected".
nbalanced.c = http://github.com/simongmzlj/dwm/blob/m … balanced.c

opacify
A modified transparency patch. Requires xcompmgr to be running. I changed the transparency level to an int and added functions to allow runtime increasing/decreasing of transparency.
opacify.c = http://github.com/simongmzlj/dwm/blob/master/opacity.c
opacify.diff = http://github.com/simongmzlj/dwm/blob/m … acity.diff

cycle
This one is a product of collaboration between me and some other archers. Adds keybinding to add a way to move left and right through tags with the ability to pull the focused window with you. Like ctrl+alt or ctrl+alt+shift left and right in gnome.
cycle.c = http://github.com/simongmzlj/dwm/blob/master/cycle.c

tagmon
The only patch completely of my doing. Changes how dwm manages multiple monitors. Unless explicitly dragged across, this patch causes dwm to reapply the rules set for the window on the new monitor.
tagmon.diff = http://github.com/simongmzlj/dwm/blob/m … agmon.diff

gaps
This version of the patch, while still adding gaps on monocle - thats my preference - adds gaps around windows. Does not add a double width gap between adjacent windows.
gaps.diff = http://github.com/simongmzlj/dwm/blob/master/gaps.diff

Last edited by simongmzlj (2010-03-10 18:29:30)

Offline

#2 2010-03-10 17:32:02

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

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

/me takes his chance for the golden seat;

leantagbar: http://github.com/lolilolicon/dwm/blob/ … agbar.diff

I wrote this for a "leaner" tag bar.

leantagbar.png

In the screenshot above, the "[term]" shows how selected tags are surrounded by [], and the "code" tag shows how urgent tags are shown in urgent color. Note also that I removed the drawsquare(...) line so the little squares are gone.

This is leantagbar patch for dwm 5.7.2.

It tweaks the display of dwm bar -> tags section:
    * display selected tags as [tag] instead of in sel*color;
    * for urgent tags, it uses inverted urgent colors instead of just invert the sel*color; you need to add urg*color defs in config.h ;
    * as a bonus, urgent windows have urgbordercolor borders;
    * no tiny little squares, thanks;

Example color definitions in config.h:

static const char urgbordercolor[] = "#ff0066";
static const char urgbgcolor[] = "#ff0066";
static const char urgfgcolor[] = "#ffffff";

@simongmzlj
Kudos for opening this thread!
btw, you should put those to a more permanent place smile

Last edited by lolilolicon (2010-03-10 18:09:27)


This silver ladybug at line 28...

Offline

#3 2010-03-10 18:30:22

simongmzlj
Member
From: Canada
Registered: 2008-11-06
Posts: 135

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

Good idea. I followed your lead by creating a dwm repo on github. Anyways, thats an interesting patch. I'll play around with that.

Last edited by simongmzlj (2010-03-10 18:30:54)

Offline

#4 2010-03-10 18:45:26

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

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

OK, here's another one for the drawbar() function;

shottitle: Shortens the title display in the dwm bar.
http://github.com/lolilolicon/dwm/blob/ … title.diff

This is shorttitle patch for dwm 5.7.2.

By default dwm will fill the middle lot of the dwm bar with selbgcolor, no matter how short the title of the selected window. This patch makes it a little bit smarter and dynamically adjust this length. The user can also define the maximum value of this length.

This patch lets you limit the title length shown in the dwm bar;
You need to define titlemaxw in config.h, e.g.

static const unsigned int titlemaxw = 230; /* note it's in pixel */

@simon
Glad you like it! And yeah, github ftw smile

Last edited by lolilolicon (2010-03-10 18:48:47)


This silver ladybug at line 28...

Offline

#5 2010-03-10 19:23:08

thayer
Fellow
From: Vancouver, BC
Registered: 2007-05-20
Posts: 1,560
Website

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

This is how awesome started smile

Seriously though, I think it's cool to share this stuff, but why not share it on the official dwm website?  Patches are always welcome.


thayer williams ~ cinderwick.ca

Offline

#6 2010-03-11 20:27:53

Paul-S
Member
From: Wales
Registered: 2008-02-04
Posts: 353

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

Cool patches, lolilolicon how did you make the scratchpad, one of the few things I miss from XMonad.

Cheers
Paul-S

Offline

#7 2010-03-11 20:37:00

simongmzlj
Member
From: Canada
Registered: 2008-11-06
Posts: 135

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

The gap patch above has been heavily modifies. You now can turn gapping on or off per layout and it no longer relies on two different resize functions to work properly.

@thayer, thats the plan.

Offline

#8 2010-03-12 08:48:56

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

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

Paul-S wrote:

Cool patches, lolilolicon how did you make the scratchpad, one of the few things I miss from XMonad.

Cheers
Paul-S

Hey, Paul. It's currently all done in config.h:

/* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6" };
/* rules */
static const Rule rules[] = {
  { "URxvt",           "Scratchpad",   "Scratchpad",   1 << 5,   True,      -1 }, /* scratchpad in its own tag (6th) */
};
/* commands */
static const char *scratchpadcmd[] = { "urxvt", "-name", "Scratchpad", "-geometry", "74x15", NULL };
/* key bindings */
static Key keys[] = {
  { MODKEY|ControlMask,           XK_x,      spawn,          {.v = scratchpadcmd } }, /* Launch scratchpad... */
  { MODKEY,                       XK_x,      toggleview,     {.ui = 1 << 5} }, /* Toggle scratchpad,, but this doesn't auto focus */
};

The idea is simple:
The Scratchpad stays in its own tag (6 here)
I toggle it by toggleview this tag (MODKEY + x)
But due to this simple disign:
You have to press MODKEY + Control + x to launch it first;
It won't auto focus.

Another thing I've done for it is hiding the tag of Scratchpad from the bar by replacing all three "LENGTH(tags)" with "LENGTH(tags) - 1" in dwm.c (it works, since the tag 6 is the last one)

This is a clever hack in nature and I do like the idea, but I also want something better... [1]

Anyway, hope it helps smile

Edit:
[1] Yeah, so here is a request, simon wink

Last edited by lolilolicon (2010-03-12 09:43:14)


This silver ladybug at line 28...

Offline

#9 2010-03-12 09:21:43

Lokaltog
Member
From: Norway
Registered: 2009-12-04
Posts: 53
Website

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

I don't think this qualifies as a patch or a hack, but it's a tip I think some of you may find useful:

I like icons in my statusbar, but I don't want to use a separate app like dzen2 just to show xbm icons when dwm already has a status bar, and I don't know how to patch dwm with xbm support. I've solved this problem by editing my dwm font (I use artwiz cure) and drawing icons in the font itself:

1) If your font is a pcf font, use pcf2bdf (available in AUR) to convert it to a bdf font
2) Install gbdfed (available in AUR) and xorg-font-tools
3) Open your bdf font in gbdfed and replace the glyphs you want with icons. It may be possible to use empty glyphs beyond 0xFF instead, but I haven't tried this.
4) Change the font name if you want (Edit > Font Info > Font Properties), and save the font
5) Use bdftopcf to compile the bdf font to pcf, and gzip it (this step is optional)
6) Copy/move the font to an Xorg font dir, run fc-cache -vf and restart X
7) Insert the symbols in your status bar script or in config.h if you want. I've made some symbols to indicate the layout mode that I use in config.h (see screenshot).

Here's a screenshot of the tip in action (note that I've patched dwm with statuscolors to add some color to the icons):
664213.jpeg

Edit: Check out my GitHub repo for an updated bdf font with various symbols.

Last edited by Lokaltog (2010-06-08 19:43:52)

Offline

#10 2010-03-12 12:37:09

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

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

Lokaltog wrote:

I don't think this qualifies as a patch or a hack, but it's a tip I think some of you may find useful

Ha! I did almost this exact thing when I used dwm+conky strictly for wireless signal.  Glad to see I'm not the only one smile


archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#11 2010-03-12 13:53:35

erno
Member
Registered: 2009-08-24
Posts: 83

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

anyone got nbalanced or nmaster working with pertag?

Offline

#12 2010-03-12 15:37:28

thayer
Fellow
From: Vancouver, BC
Registered: 2007-05-20
Posts: 1,560
Website

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

rson451 wrote:
Lokaltog wrote:

I don't think this qualifies as a patch or a hack, but it's a tip I think some of you may find useful

Ha! I did almost this exact thing when I used dwm+conky strictly for wireless signal.  Glad to see I'm not the only one smile

The question is...why hasn't anyone created a font that consists entirely of status icons?  Sounds like a good project for me once I get some free time.

Last edited by thayer (2010-03-12 15:37:55)


thayer williams ~ cinderwick.ca

Offline

#13 2010-03-12 15:55:07

simongmzlj
Member
From: Canada
Registered: 2008-11-06
Posts: 135

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

erno wrote:

anyone got nbalanced or nmaster working with pertag?

The issue is that the pertag patch moves the Monitor struct to just after the #include "config.h" line:

typedef struct Monitor Monitor;
typedef struct Client Client;
struct Client {

<snip>

/* configuration, allows nested code to access above variables */
#include "config.h"

struct Monitor {
    char ltsymbol[16];
    float mfact;
    int num;
    int by;               /* bar geometry */
    int mx, my, mw, mh;   /* screen size */
    int wx, wy, ww, wh;   /* window area  */
    unsigned int seltags;
    unsigned int sellt;
    unsigned int tagset[2];
    Bool showbar;
    Bool topbar;
    Client *clients;
    Client *sel;
    Client *stack;
    Monitor *next;
    Window barwin;
    const Layout *lt[2];
    int curtag;
    int prevtag;
    const Layout *lts[LENGTH(tags) + 1];
    double mfacts[LENGTH(tags) + 1];
    Bool showbars[LENGTH(tags) + 1];
};

It does this because the monitor structure now requires access the number of tags to function. This now precludes the ability of any code included in the config.h to use the Monitor struct as they see it as declared but undefined. My current solution is to split out a tags.h header with just the tags declared in them. Then this can be done like this

#include "tags.h"

struct Monitor {
    char ltsymbol[16];
    float mfact;
    int num;
    int by;               /* bar geometry */
    int mx, my, mw, mh;   /* screen size */
    int wx, wy, ww, wh;   /* window area  */
    unsigned int seltags;
    unsigned int sellt;
    unsigned int tagset[2];
    Bool showbar;
    Bool topbar;
    Client *clients;
    Client *sel;
    Client *stack;
    Monitor *next;
    Window barwin;
    const Layout *lt[2];
    int curtag;
    int prevtag;
    const Layout *lts[LENGTH(tags) + 1];
    double mfacts[LENGTH(tags) + 1];
    Bool showbars[LENGTH(tags) + 1];
};

/* configuration, allows nested code to access above variables */
#include "config.h"

and it all works. I'll post a version later tonight that allocates the length at runtime to avoid this circular dependency of files.

EDIT: Hows this? http://github.com/simongmzlj/dwm/blob/m … ertag.diff. I'm not sure if I should bother freeing those arrays seeing that they're constantly in use. Please test, if its okay I'll make pushing this one to the dwm website a priority as the on site one is broken.

Last edited by simongmzlj (2010-03-12 18:46:04)

Offline

#14 2010-03-12 16:11:15

Lokaltog
Member
From: Norway
Registered: 2009-12-04
Posts: 53
Website

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

thayer wrote:

The question is...why hasn't anyone created a font that consists entirely of status icons?

It would be awesome to have a font dedicated to status icons, but how would you use a font with only status icons in dwm's status bar? Wouldn't this require the ability to change fonts in the status bar?

Offline

#15 2010-03-12 16:25:57

simongmzlj
Member
From: Canada
Registered: 2008-11-06
Posts: 135

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

Lokaltog wrote:
thayer wrote:

The question is...why hasn't anyone created a font that consists entirely of status icons?

It would be awesome to have a font dedicated to status icons, but how would you use a font with only status icons in dwm's status bar? Wouldn't this require the ability to change fonts in the status bar?

We'd have to write something similar to http://dwm.suckless.org/patches/statuscolors (colours would make it that much nicer anyways)

While I really like the idea of a symbol font, I'm looking for a break from carbon, maybe I'll see if I can get xbm support in dwm. We could add another header file dedicated to storing images

Offline

#16 2010-03-12 18:58:29

simongmzlj
Member
From: Canada
Registered: 2008-11-06
Posts: 135

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

Lokaltog wrote:

I don't think this qualifies as a patch or a hack, but it's a tip I think some of you may find useful:

I like icons in my statusbar, but I don't want to use a separate app like dzen2 just to show xbm icons when dwm already has a status bar, and I don't know how to patch dwm with xbm support. I've solved this problem by editing my dwm font (I use artwiz cure) and drawing icons in the font itself:

1) If your font is a pcf font, use pcf2bdf (available in AUR) to convert it to a bdf font
2) Install gbdfed (available in AUR) and xorg-font-tools
3) Open your bdf font in gbdfed and replace the glyphs you want with icons. It may be possible to use empty glyphs beyond 0xFF instead, but I haven't tried this.
4) Change the font name if you want (Edit > Font Info > Font Properties), and save the font
5) Use bdftopcf to compile the bdf font to pcf, and gzip it (this step is optional)
6) Copy/move the font to an Xorg font dir, run fc-cache -vf and restart X
7) Insert the symbols in your status bar script or in config.h if you want. I've made some symbols to indicate the layout mode that I use in config.h (see screenshot).

Here's a screenshot of the tip in action (note that I've patched dwm with statuscolors to add some color to the icons):
http://bildr.no/thumb/606340.jpeg

Actually, where did you get those glyphs?

Offline

#17 2010-03-12 19:14:34

Lokaltog
Member
From: Norway
Registered: 2009-12-04
Posts: 53
Website

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

simongmzlj wrote:

Actually, where did you get those glyphs?

I drew them myself in gbdfed, inspired by sm4tik's xbm icons. smile

Offline

#18 2010-03-12 19:33:26

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

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

What's the difference between xft and xbm support? There is an xft patch (I be usin' it) already. Or does that incur a lot more overhead than just xbm? I just really like having true type fonts available...just can't get used to any of the non-xft fonts smile

Scott

Offline

#19 2010-03-12 19:40:53

simongmzlj
Member
From: Canada
Registered: 2008-11-06
Posts: 135

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

firecat53 wrote:

What's the difference between xft and xbm support? There is an xft patch (I be usin' it) already. Or does that incur a lot more overhead than just xbm? I just really like having true type fonts available...just can't get used to any of the non-xft fonts smile

Scott

One deals with font rendering, the other deals with images stored in code:
Xft: http://en.wikipedia.org/wiki/Xft
Xbm: http://en.wikipedia.org/wiki/XBM

And for good measure
Xpm: http://en.wikipedia.org/wiki/X_PixMap

Offline

#20 2010-03-12 20:48:16

simongmzlj
Member
From: Canada
Registered: 2008-11-06
Posts: 135

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

Okay, I somewhat got xpm support into dwm. It replaces the drawing layout symbol with a union jack right now, There's 0 configuration or ability to inject it into the status bar. xbm and more support coming. Patches, for now, on my github. http://github.com/simongmzlj/dwm

Offline

#21 2010-03-13 01:17:05

portix
Member
Registered: 2009-01-13
Posts: 757

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

erno wrote:

anyone got nbalanced or nmaster working with pertag?

I have nmaster and pertag patch working, along with some other patches, mostly regarding mulithead.
http://npaste.de/L5/

Offline

#22 2010-03-13 09:12:16

simongmzlj
Member
From: Canada
Registered: 2008-11-06
Posts: 135

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

lolilolicon wrote:
Paul-S wrote:

Cool patches, lolilolicon how did you make the scratchpad, one of the few things I miss from XMonad.

Cheers
Paul-S

Hey, Paul. It's currently all done in config.h:

/* tagging */
static const char *tags[] = { "1", "2", "3", "4", "5", "6" };
/* rules */
static const Rule rules[] = {
  { "URxvt",           "Scratchpad",   "Scratchpad",   1 << 5,   True,      -1 }, /* scratchpad in its own tag (6th) */
};
/* commands */
static const char *scratchpadcmd[] = { "urxvt", "-name", "Scratchpad", "-geometry", "74x15", NULL };
/* key bindings */
static Key keys[] = {
  { MODKEY|ControlMask,           XK_x,      spawn,          {.v = scratchpadcmd } }, /* Launch scratchpad... */
  { MODKEY,                       XK_x,      toggleview,     {.ui = 1 << 5} }, /* Toggle scratchpad,, but this doesn't auto focus */
};

The idea is simple:
The Scratchpad stays in its own tag (6 here)
I toggle it by toggleview this tag (MODKEY + x)
But due to this simple disign:
You have to press MODKEY + Control + x to launch it first;
It won't auto focus.

Another thing I've done for it is hiding the tag of Scratchpad from the bar by replacing all three "LENGTH(tags)" with "LENGTH(tags) - 1" in dwm.c (it works, since the tag 6 is the last one)

This is a clever hack in nature and I do like the idea, but I also want something better... [1]

Anyway, hope it helps smile

Edit:
[1] Yeah, so here is a request, simon wink

Whats a scratchpad?

Offline

#23 2010-03-13 11:33:17

Paul-S
Member
From: Wales
Registered: 2008-02-04
Posts: 353

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

simongmzlj just a terminal window you can call and dismiss with a keybinding.

Cheers
Paul-S

Offline

#24 2010-03-13 17:10:44

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

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

simongmzlj wrote:

Whats a scratchpad?

Think about the Quake-inspired terminals like yakuake, guake, and tilda.


This silver ladybug at line 28...

Offline

#25 2010-03-14 09:37:59

simongmzlj
Member
From: Canada
Registered: 2008-11-06
Posts: 135

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

http://github.com/simongmzlj/dwm/blob/m … ertag.diff
Heres a further modified pertag patch. While this one doesn't store showbar per tag anymore, this one allows per tag default layout and mfact to be set in config.h

/* tagging */
static const Tag tags[] = {
    /* name    layout   mfact */
    { "term",  1,       -1   },
    { "dev",   0,       -1   },
    { "web",   2,       -1   },
    { "chat",  0,       0.70 },
    { "virt",  2,       -1   },
    { "misc",  0,       -1   },
};
Paul-S wrote:

simongmzlj just a terminal window you can call and dismiss with a keybinding.

Cheers
Paul-S

Okay, its on my todo list.

Last edited by simongmzlj (2010-03-14 09:40:18)

Offline

Board footer

Powered by FluxBB