Dwm Cheatsheet

  



-->

Overview of the Desktop Window Manager (DWM) technology.

To develop Desktop Window Manager (DWM), you need these headers:

For programming guidance for this technology, see:

Erlendaakre / Dwm default keys cheatsheet Forked from ErnestasJa/Dwm default keys cheatsheet. Last active Mar 19, 2021. Star 31 Fork 14 Star Code Revisions 4 Stars 31 Forks 14. What would you like to do? Embed Embed this gist in your website.

  1. In the upper right, there will be a small indicator, with dwm and the version, e.g., dwm-5.9-1. The left side will have numbers 1-9, for each tag. A tag is similar to a workspace. Many people have little scripts to give a bit more inforation in the status bar (the right side, that has dwm and version).
  2. DMV Permit Test Cheat Sheet Answers. It is illegal for a person 21 years of age or older to drive with a blood alcohol concentration (BAC) that is or higher. 0.08% – eight hundredths of one percent; You must notify DMV within 5 days if you: sell or transfer your vehicle; You are getting ready to make a right turn.

Enumerations

TitleDescription
DWM_SOURCE_FRAME_SAMPLINGFlags used by the DwmSetPresentParameters function to specify the frame sampling type.
DWM_TAB_WINDOW_REQUIREMENTSReturned by DwmGetUnmetTabRequirements to indicate the requirements needed for a window to put tabs in the application title bar.
DWMFLIP3DWINDOWPOLICYFlags used by the DwmSetWindowAttribute function to specify the Flip3D window policy.
DWMNCRENDERINGPOLICYFlags used by the DwmSetWindowAttribute function to specify the non-client area rendering policy.
DWMTRANSITION_OWNEDWINDOW_TARGETIdentifies the target.
DWMWINDOWATTRIBUTEFlags used by the DwmGetWindowAttribute and DwmSetWindowAttribute functions to specify window attributes for Desktop Window Manager (DWM) non-client rendering.
GESTURE_TYPEIdentifies the gesture type specified in DwmRenderGesture.

After installation, dwm-mitch should show up as an X session type in your login screen. See the CHEATSHEET for default keybindings. A running dwm can be restarted by kill -s USR1 $pidofdwm. Use this if you have changed your configuration and did a make install to activate your changes without losing your current X session. Notifies Desktop Window Manager (DWM) that a touch contact has been recognized as a gesture, and that DWM should draw feedback for that gesture. DwmSetDxFrameDuration: Sets the number of monitor refreshes through which to display the presented frame. DwmSetDxFrameDuration is no longer supported. Starting with Windows 8.1, calls to.

Functions

TitleDescription
DwmAttachMilContentThis function is not implemented.
DwmDefWindowProcDefault window procedure for Desktop Window Manager (DWM) hit testing within the non-client area.
DwmDetachMilContentThis function is not implemented.
DwmEnableBlurBehindWindowEnables the blur effect on a specified window.
DwmEnableCompositionEnables or disables Desktop Window Manager (DWM) composition.
DwmEnableMMCSSNotifies the Desktop Window Manager (DWM) to opt in to or out of Multimedia Class Schedule Service (MMCSS) scheduling while the calling process is alive.
DwmExtendFrameIntoClientAreaExtends the window frame into the client area.
DwmFlushIssues a flush call that blocks the caller until the next present, when all of the Microsoft DirectX surface updates that are currently outstanding have been made. This compensates for very complex scenes or calling processes with very low priority.
DwmGetColorizationColorRetrieves the current color used for Desktop Window Manager (DWM) glass composition.
DwmGetCompositionTimingInfoRetrieves the current composition timing information for a specified window.
DwmGetGraphicsStreamClientThis function is not implemented.
DwmGetGraphicsStreamTransformHintThis function is not implemented.
DwmGetTransportAttributesRetrieves transport attributes.
DwmGetUnmetTabRequirementsNote This function is publically available, but nonfunctional, for Windows 10, version 1803.Checks the requirements needed to get tabs in the application title bar for the specified window.
DwmGetWindowAttributeRetrieves the current value of a specified Desktop Window Manager (DWM) attribute applied to a window.
DwmInvalidateIconicBitmapsCalled by an application to indicate that all previously provided iconic bitmaps from a window, both thumbnails and peek representations, should be refreshed.
DwmIsCompositionEnabledObtains a value that indicates whether Desktop Window Manager (DWM) composition is enabled. Applications on machines running Windows 7 or earlier can listen for composition state changes by handling the WM_DWMCOMPOSITIONCHANGED notification.
DwmModifyPreviousDxFrameDurationChanges the number of monitor refreshes through which the previous frame will be displayed. DwmModifyPreviousDxFrameDuration is no longer supported. Starting with Windows 8.1, calls to DwmModifyPreviousDxFrameDuration always return E_NOTIMPL.
DwmQueryThumbnailSourceSizeRetrieves the source size of the Desktop Window Manager (DWM) thumbnail.
DwmRegisterThumbnailCreates a Desktop Window Manager (DWM) thumbnail relationship between the destination and source windows.
DwmRenderGestureNotifies Desktop Window Manager (DWM) that a touch contact has been recognized as a gesture, and that DWM should draw feedback for that gesture.
DwmSetDxFrameDurationSets the number of monitor refreshes through which to display the presented frame. DwmSetDxFrameDuration is no longer supported. Starting with Windows 8.1, calls to DwmSetDxFrameDuration always return E_NOTIMPL.
DwmSetIconicLivePreviewBitmapSets a static, iconic bitmap to display a live preview (also known as a Peek preview) of a window or tab. The taskbar can use this bitmap to show a full-sized preview of a window or tab.
DwmSetIconicThumbnailSets a static, iconic bitmap on a window or tab to use as a thumbnail representation. The taskbar can use this bitmap as a thumbnail switch target for the window or tab.
DwmSetPresentParametersSets the present parameters for frame composition. DwmSetPresentParameters is no longer supported. Starting with Windows 8.1, calls to DwmSetPresentParameters always return E_NOTIMPL.
DwmSetWindowAttributeSets the value of Desktop Window Manager (DWM) non-client rendering attributes for a window.
DwmShowContactCalled by an app or framework to specify the visual feedback type to draw in response to a particular touch or pen contact.
DwmTetherContactEnables the graphical feedback of touch and drag interactions to the user.
DwmTransitionOwnedWindowCoordinates the animations of tool windows with the Desktop Window Manager (DWM).
DwmUnregisterThumbnailRemoves a Desktop Window Manager (DWM) thumbnail relationship created by the DwmRegisterThumbnail function.
DwmUpdateThumbnailPropertiesUpdates the properties for a Desktop Window Manager (DWM) thumbnail.

Structures

TitleDescription
DWM_BLURBEHINDSpecifies Desktop Window Manager (DWM) blur-behind properties. Used by the DwmEnableBlurBehindWindow function.
DWM_PRESENT_PARAMETERSSpecifies Desktop Window Manager (DWM) video frame parameters for frame composition. Used by the DwmSetPresentParameters function.
DWM_THUMBNAIL_PROPERTIESSpecifies Desktop Window Manager (DWM) thumbnail properties. Used by the DwmUpdateThumbnailProperties function.
DWM_TIMING_INFOSpecifies Desktop Window Manager (DWM) composition timing information. Used by the DwmGetCompositionTimingInfo function.
MilMatrix3x2DSpecifies a 3x2 matrix that describes a transform.
UNSIGNED_RATIODefines a data type used by the Desktop Window Manager (DWM) APIs. It represents a generic ratio and is used for different purposes and units even within a single API.

A Look at the DWM Window Manager

Tiling window managers can be quite handy. Although I generally useeither fluxbox or openbox some of the smalltiling window managers can be useful, especially on netbooks.

For those unfamiliar with them, a tiling window manager takes eachwindow and sorts them into their own space. On some of them, includingdwm, this is done dynamically, that is, as you open a new window, itwill automatically be sized to fit. Looking at some screenshots might help.(The link goes to suckless.org's screenshots--they're the ones whocreated dwm).

As of dwm-6.2 the default config.def.h file has changed enough so that youmay have to re-edit your custom config.h. The changes are minor, butenough to break an existing config. Depending upon what you need from dwm,though, you can probably choose to ignore upgrading it without losing verymuch. Much of this article is written about older versions, but it shouldwork with 6.2 with small changes that should be evident if you look at thedefault config.def.h file

Some folks get put off by the fact that to configure dwm, one has tomanually edit the included config.h file and recompile. This reallyisn't terribly difficult, even if one doesn't know C, and therecompiling only takes a few seconds. Some distributions, for example,Fedora, have a nice wrapper script that will do it for you. If yourdistribution doesn't have such a script, you're probably better offdownloading it and compiling it yourself. It has relatively few dependencies.

One reason to download it rather than install it from yourdistribution's package manager is that, as mentioned, to customize it,you might want to edit config.h. If your distro installs it as abinary, you might not have that config.h file readily available.

However, the default keybindings are fairly reasonable. A good cheatsheet can be found at here,at github.

As stated above, Fedora, at least, is an exception to this rule. Yourdistribution might also have its version of a wrapper script.

This isn't going to be a detailed tutorial, but hopefully, it will makeit a little easier for you to use and customize dwm.

Once installed, add to your $HOME/.xinitrc

Dm Cheat Sheet

and it should start when you run startx.

For those of you who start with graphical login, there should be a wayto add it to your login menu, but, as I don't use a gui login, I don'tknow what it is. I would try googling add dwm to gdm or kdm or whateverlogin gui that you use. An excellent ArchLinux wikiarticle gives some tips.

Regardless, we'll assume that you've managed to log into dwm. You will see nothing but a black screen with a gray bar at the top. In the upper right, there will be a small indicator, with dwm and the version, e.g., dwm-5.9-1. The left side will have numbers 1-9, for each tag. A tag is similarto a workspace.

Many people have little scripts to give a bit more inforation in the status bar (the right side, that has dwm and version).I use

This changes my status bar to something like 2014-04-22 11:01 (if I'm writing it on April 22 at 11:01 AM). You can run the script as a script in itself (putting #!/bin/sh at the top), or put it in your xinitrc before starting dwm--that is, the exec dwm should be the last line in ~/.xinitrc. In FreeBSD, it doesn't seem to recognize the 1m so use 60 (for seconds)instead.

Ifusing default keybindings (we'll cover this in a minute), hitalt+shift+return and you'll get a terminal that takes up the entirescreen. Hit alt+shift+return again, and you'll get a second terminal,with the screen now divided into a left and right half. Do it a thirdtime and the right half of the screen will now have a top and a bottomterminal. Do it a 4th time, and the right half of the screen will nowhave three terminals, stacked top to bottom. This is known, oddlyenough, as stacking. (Note that 'stacking', is also a term for window managers like flxubox and open box, thatstack rather than tile windows)

Note that in Fedora's version, they have changed the mod key from Mod1,alt, to Mod4, the Windows key, between Ctrl and Alt on most USkeyboards. So, if you're on Fedora and installed dwm with yum installdwm, substitute the Windows key for alt in all of these shortcuts. The left hand terminal is the master area, the right side is used forstacking. The man page gives the various default keyboard shortcuts.Alt+h will decrease the size of the master area. Alt+l will enlarge it.The keyboard shortcuts are familiar to vi users, l moving a vi cursor tothe right and h to the left. (That's a lower case L, not the numeralone.) Alt+j and Alt+k move focus to the window below and aboverespectively.

Now hit alt+p and you'll see the handy dmenu on the top. Type in a fewletters of an application, for example, opera, the web browser.

A new application, whether opened by terminal command or using dmenu,should open in the master area. If I want that application to have morescreen, I can use the alt-l shortcut mentioned previously. If I want itto take the full screen, I can hit alt+m, as in monocle layout, meaningthat the one window will take the entire workspace. Another use for monocle view might be if you've opened up a bunch ofwindows. A particular window might be too small to be useful. To fix that, I can hit alt+m and it's maximized to use the whole screen. To return to tile view, I hit alt+t.

There is also alt+f, which will change the focused window to floating. A floating window can be resized with alt+button3 (right mouse button). (I'd always thought button 3 is the middle button, but I'm going by the config.h file--dwm, at least, seems to consider it the right button, rather than the middle one).or moved with alt+button1 (left mouse button). A default config.h file will toggle floating with alt+button2 (middle button).In my experience, if you set an app to always be floating in config.h, then resize it with alt+button3, close dwm and reopen it, the window will stay that size. This can be useful if you use somethingthat you like to keep at a certain size. Forexample, I like to use gbuffy to watch mail. If I open it in dwm, it will open in the master window. If I resize it, then close dwm, then reopen dwm, it remains the size that Iwant. To set an app to always be floating, you have to figure out its class name and thenput it in config.h. If you look at the listing for gimp, which is set to always be floating, you can see the syntax, which isalso listed above the entries--that is the class, instance, title and so on. So, in this case, it would read

You get the class name by using the xprop program. Use the command

It will give back two names, often the same, e.g., with the old mlterm, it would give back mlterm, mlterm. However, for gbuffy, it will give back

The first listing, all lower case, is the name, the second the class. I cover this a bit more in my openbox page.I want gbuffy to always be opened in a floating window, so I add the lines I listed above (the 'Gbuffy', NULL and so on) into config.h. Then, as always when making changes, I rerun make install in my dwm directory. (Unless using the Fedora wrapper script mentioned above.)

If, while in dwm, one chooses floating mode, the next window opened will float rather than be tiled. For example, if I have twoterminals open, then hit alt+f, the next terminal I open will be floating--that is, rather than a second window opening in theright hand stack, it will be a typical 80x24 terminal appearing in the upper left. The status bar will indicate the mode thatyou're in--by default, if in floating mode, after th 1-9 listing tags, you'll see

If in typical tile mode it will show []=. If using monocular mode it will be a bracket with a number, showing how many things are open. For example, if all I have three terminals and nothing else running, it will show [3].If one uses horizontal stacking (the special patch allowing that is covered below) then it will show [TTT]. This can bechanged, if desired, in config.h in the section static const Layouts. The comment indicates that a symbol indicates a function.It then defines [] as tile and so on.

If I want to make a window larger, but don't want to switch to monocular format, hitting alt+return will swapthe window with the master area. So, if I have 6 windows on screen,and then open another, but it's too small to see what I need to, I canuse the alt-return keybinding. Then, if it's still not big enough, Ican enlarge the master area with alt+l.Firefox is a special case. In the config.h file, it is specified thatfirefox will open full screen in its own tag. To oversimplify a bit, atag can be thought of as a virtual desktop, or workspace. If we have our screen with the 6 or so windows that we made above, and want a new fresh desktop, we can hit alt+2 which will take us to tag 2. This will give us the same black screen we saw when wefirst logged in. You can move a window to a new tag by, while focused on it, hitting shift+alt+2, for example, which will move it to tag number 2.

Going back to firefox, the config file has it set to open in tag 9.Sometimes, one will see on a forum that someone is opening firefox indwm and it's not opening. What's actually happening is that they're inworkspace 1, call firefox with dmenu and not realize that it's open ontag 9. When you are in one tag, e.g., 1 and something is open inanother tag, you'll see a little square next to that tag. So, in thiscase, you'd see a little square next to tag 9 in the status bar at thetop. So, if in tag 1, I have a terminal running, then start firefox,either with a terminal command or using dmenu, and then go to tag 2 withalt+2, I'll see a little square next to both the 1 and the 9 on thestatus bar. If, while in tag 9, I have several windows open in thattag, firefox will be tiled, just as opera would be in our earlierexample.

As of December 2012, dwm has changed from mercurial to git. The latestversion can be gotten with

If you get a RPC error, then instead of http use

that should work. It has added a nice feature (that was apparently there long ago, butdropped) to add and decrease clients in the master area. So if, forexample, you have one large terminal in the master area, and 3 smallerones in the stacking area (the right half of the screen), hitting alt+iwill move one of the three on the right to the left, so you would nowhave two on the left and two on the right. With alt+l and alt+h you canaddjust the sizes of the two areas.

For me personally, this is a big plus--it gives me the ability to have 6or 8 equally sized terminals on screen. If I then want to open abrowser, I can go to another workspace, or open the browser and hitalt+m to let it have full focus.

To build dwm you need xlib, libXft, and xinerama header files. In CentOS, thiscan be gotten with

Youwill also, need the basic development tools. At an absoluteminimum, I install gcc, gcc-c++, make, automake and kernel-devel.

Once downloaded, if you got the the tarball, untar with with the usual tar xvf dwm-<version>.tar.gz. Then cd into the newly created directory. Copy config.def.h to config.h, and you can edit it if you wish.

There is a howto on theDebian forums that goes through config.h line by line. It explains howyou can edit the keybindings, for example, changing the Mod1 to Mod4 tomake the Windows key, rather than Alt, your mod key. It also explainshow to open a program on a particular tag (workspace). Rather thanduplicate that, I'll just point out a few that I find handy.

For example, I like to start chromium browser with Mod+g. So, underneaththe line where it defines the terminal command, I put

You will see the pattern in config.h. Their default is uxterm, so theline they use to define the command for it is

(If you prefer another terminal, such as urxvt, you can change uxterm tourxvt)

If you want specific options, then each option is added inside doublequotes with a comma. For example, I want to open mutt, the mail client,with a keyboard shortcut. So, I'll define it in here.

I could add other options if I wish, with each option and itsdescription enclosed separately in double quotes and comma. In theexample below, I change the terminal that I'll use for mutt to have abackground of burlywood.

Next in the file are the key commands. For example, one of their defaultsis

Dm cheat sheet 5e

This means the mod key, alt by default, that can be changed asmentioned and shift. Then, the XK_Return is the key combo to open aterminal. The termcmd was defined above as a static constant. Youdon't have to know C to figure it out once you get the pattern.

If you don't want to use alt+shift, you could edit that line to read

For my key binding for chromium, I use

In the same way, I'll make the modkey and m my shortcut for the muttcmdthat I defined earlier.

(Note that if running a command, you would use spawn. If you look atthe default config.h, you will see that spawn is only used when runningan actual program, such as terminal or dmenu.)

Many dwm users contribute patches. I find the moveresize patchpretty handy. It allows you to move and resize windows with keystrokes.The patch's author has some reasonable defaults.

According to the page, one just puts the code in dwm.c below the linereading

Dwm Cheatsheet

Then add the keybindings to config.h. However, on ArchLinux and FreeBSD, at least, Ifound that it was also necessary to add

in an earlier part of the file, where there is a long list of functiondeclarations. (You can tell the part because it begins with a commentreading function declarations. If you're not familiar with C, a commentdoesn't begin with a #. It begins with /* and ends with */. In thecase of dwm.c, it starts around line 157 at time of writing.

At any rate you'll see a long list of things like static void, staticMonitor, etc., one per line. Add that static void movereisze linethere, as well as the lines you are instructed to add on the patch'spage.

To do this in FreeBSD, first edit your config.h file. If you don't haveone, first run in /usr/ports/x11-wm/dwm,

You will then see a work directory which contains, among other things, adwm-<version> directory. You will have a config.def.h in there. Copyit somewhere,and edit it.

To apply the patch in FreeBSD, put it in /usr/ports/x11-wm/dwm/files andcall it patch-dwm.c

Although I use packages for most things, for dwm, I use the port. To usemy custom config.h file, I can cd into /usr/ports/x11-wm/dwm and run

While on the BSDs, on OpenBSD, the way to use a custom config.h and/or a patch is to use the ports tree. The OpenBSD faq has a section on usingports. In a nutshell, you fetch a ports tarball for your version, thenextract it to /usr. Once you've done that, as described in this daemonforumspost

In case it's not clear, those are backticks (above a tilde on most USkeyboards), not single quotes for the make show=WRKDIST.

I emailed the patch's author about needing to declare the function, but, although I've seen atleast one other mention of it on the Arch forums, the author wasn't ableto duplicate the problem. They also were kind enough to tell me thatthe reason they did it as they do, rather than an actual patch file, isto allow people to customize it. For example, you will see that theauthor puts a note that if you want to automatically make a clientfloating, rather than tiled, when resizing, replace the if statement thatends with return with togglefloating(NULL).

Judging from screenshots, another popular patch is the bottom stack patch.It changes the layout from a master window on the left and stacked windows in the right half of the screen to the master on top, and then stacking on the bottom, left to right. (If you look at thelink, it's illustrated.) It also includes what its author calls bstackhoriz which just has rowsof windows from top to bottom--again, illustrated on the page. For those who prefer, here's a screenshot of a#!Crunchbang user with a typical bstack layout.

Dwm Cheatsheet

The main patches page has instructions for patching. One can use the standard patch command

One thing about the patch that its page doesn't mention is that it alters config.def.h, not config.h. So, if youhave a config.h file, apply the patch, then run the usual sudo make install, it won't have any effect. The easiestway is to probably copy your config.def.h file to a backup, then copy your config.h file to config.def.h, then copyit back. It sounds more confusing than it actually is.

I've left out one part. To get it to work, you have to add a keyboard entry or two in your config.h, soactually, after patching, but before running make install, one would do some additional editing. If you look at your config.h file, you'll see the entries where one changes between monocle and floating mode.

You'll note that hitting the mod key and space will toggle the layouts. That's what the {0} is. I don't know enough about C tohave it completely figured out, but the toggling seems to only work between some layouts--that is, it won't cycle completelythrough tile, float, and backstack. The user can investigate.

Dwm Cheat Sheets

Dwm Cheatsheet

Once the patch is applied,add one or two more keyboard bindings for layout 3 and 4. Pick ones, obviously, that aren't already assigned. For example, Iuse modkey plus n for bottom stacking, because the more obvious modkey b is already used by default, toggling the bar at top onand off. I don't bother adding a key for bottom horizontal stacking,because, in later versions one gets the same effect with effect with modkey i, adding master windows. So, under the XK_m entry, I add

to my config.h before running make install. Now, I can change between standard tiled layout (using modkey and t), with onelarge window on the left and a few smaller ones on the right, or bottom stacking, with one large window on top and a few smallerones beneath it, left to right. When using this method, using modkey l and modkey k increase and decrease the height, ratherthan width, of the master window.

Dwm Cheat Sheet

In FreeBSD, you would generate and modify your config.h, place the patch file in /usr/ports/x11-wm/dwm/files then, assuming youruser name was john and your custom config.h is in your home directory,cd into /usr/ports/x11-wm/dwm and run

One can define a floating window's position in config.h, I think, but asthe only things that I need in a particular position are variousterminals, I'll do that in ~/.Xdefaults. For example, I've mentioned mymuttcmd that I bind to Modkey_m. Suppose I want mutt to open, as afloating window in the middle of my screen. First, I'll use a different terminal for mutt so that the terminal I use in termcmd continues to openin tiled mode. If I use urxvt as my usual terminal, perhaps I'lluse uxterm for mutt. Then, I can define uxterm to always float by addingit to the tagging section of config.h, in the same way I've describedwith gbuffy.

Cheatsheet

Now, in ~/.Xdefaults, I can define its geometry, including where I wantit to open.

Dwm Cheat Sheet Pdf

The above example puts it approximately in the middle of a screen using1920x1080 resolution on a 24 inch monitor. I explain that a bit in mymutt article. If you're interested, just searchfor geometry in the article. It's in the section on configuringgetmail.

Dwm Cheat Sheet Printable

I'm sure there's a way to define geometry, including position, inconfig.h as well, but I'm familar with doing it in .Xdefaults--and thisway, it can stay consistent with different window managers.

Dm Cheat Sheet 5e

Speaking, sort of, of geometry, I've found that dwm works more or less outof the box with multiple monitors using xinerama. On FreeBSD, where I havea workstation with 4 monitors, dwm opens 4 separate backgrounds. I canmove windows between monitors, but if, while focused in a particularmonitor, I begin to use mod+j to move amongst windows, it will only movearound the windows in that monitor. As the man page states (it uses theterm 'screen' to refer to a monitor), mod+. or mod+, (a period and comma,respectively) will move focus to the next monitor. If I run dmenu, itappears in the first (upper left in my case) monitor, but the invokedprogram will open in whichever monitor has focus at that time.

Dm Cheat Sheet Dnd

The dwm manager is popular amongst Arch and #!Crunchbang users. The#!Crunchbang forums are pretty friendly to new users.

The Arch forums have a long and often useful, thread on dwm. Those familiar with Arch are probably familiar withthe excellence of its wiki, which as mentioned above, also has apage about dwm.