I would like to be able to save state of windows opened in all the tags on system halt/logout. Not necessarily with their whole history, just the fact that there was terminal under third tag and browser under fourth tag (for example).

How do I do that in DWM, is there any patch I could use?

Edit: I am aware of the philosophy behind DWM and that this probably would be possible by default (e.g. without patches). This is just something I would like to add to my configuration of DWM.

  • No. That's not how dwm is designed to work... Just add rules to your config.h. – jasonwryan Dec 28 '14 at 9:36
  • Yes: it is suckless and dynamic... Just use rules if you want the same outcome. – jasonwryan Dec 28 '14 at 9:39

dwm isn't designed to save the state of your session; that is typically something that a more full-bloatedblown desktop environment would do.

Instead, you can write rules in your config.h for applications that you would like to start with consistent tags.

To use the examples you mention, a browser and a terminal:

static const Rule rules[] = {
    /* class      instance    title       tags mask     isfloating   monitor */
   { "Vimprobable", NULL,       NULL,       1 << 1,       False,       -1 },
   { "urxvtc",      NULL,       NULL,       0 << 1,       False,       -1 },

This will start a browser in tag 2, and a terminal in tag 1.

You could also add keybinds to simplify launching these applications:

/* commands */
static const char   *newtermcmd[] = { "urxvtc", "-title", "newterm", NULL };
static const char   *browsercmd[] = { "vimprobable", "%s", NULL };

static Key keys[] = {
    /* modifier                     key        function        argument */
    { 0,                            XK_Menu,   spawn,          {.v = dmenucmd } },
    { MODKEY|ShiftMask,             XK_Return, spawn,          {.v = newtermcmd } },
    { ControlMask|Mod1Mask,         XK_b,      spawn,          {.v = browsercmd } },

When you start dwm, you can then hit your keybinds and have those applications assigned their respective tags. If you wanted to further develop on this concept, you could write a shell script that opened all of the applications that you require and bind that to a key sequence:

#!/usr/bin/env sh
# autostart apps

tabbed -d >/tmp/tabbed.xid; vimprobable2 -e $(</tmp/tabbed.xid) &
urxvtc -title "mutt" -e mutt &
$HOME/bin/shux &

As long as there are rules for each of the individual applications, they will be assigned the correct tags; you just assign a key sequence for the shell script:

 { ControlMask|Mod1Mask,         XK_a,      spawn,          SHCMD("$HOME/bin/autostart") },
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.