dwm Tag and Rules Configuration^
When you start dwm with the default status bar active, the top left of your screen shows a list of numbers from 1 to 9. The keyboard shortcuts M with 1 to 9 jump the highlighted box between these status numbers. As you open windows and start work, a small box appears beside the numbers to indicate that it contains running applications.
In terms of functionality, tags are analogous to work spaces in KDE, GNOME, and nowadays even macOS and Windows. When you open an application it gets assigned to a particular tag where it remains visible until you move or close it.
There are nine tags. The tag activated by M-0 actives all tags.
Tag Names^
The default names of the dwm tags are a sequence of numeric strings from 1 to 9. This is unfortunate in that it encourages you to think of tags as physical work spaces arranged in sequence where you can jump left and right to choose the next.
A better paradigm is to think of a tag as a specific context of work. Such as, you sit down at your machine and want to access a browser. The browser always lives on tag 3 so you can rely on muscle memory to hit M-3 to find it.
To facilitate this understand, use the tags variable to
designate each tag with a string that reflects the kind of work
you intend to do in the tag.
22static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
The simplest example of this would be to type out the name of
the thing you want to do. If you want tag 3 for your browser,
you might replace the "3" in tags with "web". Or,
if it tickles your fancy, you might also consider using one of
the extensive icons available in the UTF-8 character set, such
as "⚓", (id est, an anchor for those who’d like a vintage
callout to the near forgotten Netscape Navigator).
Tag Rules^
Rules provide you with some control over where and how windows open. Windows are identified through X properties to determine the window instance, class, and title. When dwm finds a match on these three values, it specifies how the window should appear when it opens.
By default, dwm provides rules for GIMP and Firefox to show you how to use them.
24static const Rule rules[] = {
25 /* xprop(1):
26 * WM_CLASS(STRING) = instance, class
27 * WM_NAME(STRING) = title
28 */
29 /* class instance title tags isfloating monitor */
30 { "Gimp", NULL, NULL, 0, 1, -1 },
31 { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
32};
The first three values in the rule indicate the class, instance,
and title, which are retrieved using xprop. This is how you
indicate the kind of window to operate on with the rule.
The fourth values in the rule is the tag mask. This is a
bitmask that corresponds to the tag where you want the window to
appear. For example, on line 31, 1 << 8 sets Firefox to
appear on tag 8.
The fifth value is an integer of 0 or 1 that indicates whether the window should open in a floating state. This setting is useful for ad hoc applications that you want to open briefly on the active tag to perform some operation and then close out when they’re no longer needed. In a future article I’ll cover how to open NeoMutt in st to quickly check your email this way.
The sixth and final value indicates which monitor you want to use. Personally, I prefer to work with one monitor only to minimize distractions, so I’m not too clear at this time how to integrate this value into rules.