Difference between revisions of "Dwm"

From ArchWiki
Jump to: navigation, search
(wikify some external links, use https for archlinux.org)
m (Reverted edits by Bobo38 (talk) to last revision by Kusakata)
 
(162 intermediate revisions by 41 users not shown)
Line 1: Line 1:
 +
{{DISPLAYTITLE:dwm}}
 
[[Category:Dynamic WMs]]
 
[[Category:Dynamic WMs]]
 
[[de:Dwm]]
 
[[de:Dwm]]
 
[[es:Dwm]]
 
[[es:Dwm]]
 
[[fr:DWM]]
 
[[fr:DWM]]
 +
[[ja:Dwm]]
 
[[ru:Dwm]]
 
[[ru:Dwm]]
 
[[zh-CN:Dwm]]
 
[[zh-CN:Dwm]]
{{Article summary start|Summary}}
+
{{Related articles start}}
{{Article summary text|Information on installing and configuring dwm}}
+
{{Related|dmenu}}
{{Article summary heading|Related}}
+
{{Related|wmii}}
{{Article summary wiki|dmenu}}
+
{{Related articles end}}
{{Article summary wiki|wmii}}
+
[http://dwm.suckless.org/ dwm] is a dynamic window manager for [[Xorg]]. It manages windows in tiled, stacked, and full-screen layouts, as well as many others with the help of [[#Patches|optional patches]]. Layouts can be applied dynamically, optimizing the environment for the application in use and the task being performed. dwm is extremely lightweight and fast, written in C and with a stated design goal of remaining under 2000 source lines of code. It provides [[multihead]] support for [[xrandr]] and Xinerama.
{{Article summary end}}
+
{{DISPLAYTITLE:dwm}}
+
[http://dwm.suckless.org/ dwm] is a dynamic window manager for [[X]]. It manages windows in tiled, stacked, and full-screen layouts, as well as many others with the help of optional patches. Layouts can be applied dynamically, optimizing the environment for the application in use and the task performed. dwm is extremely lightweight and fast, written in C and with a stated design goal of remaining under 2000 source lines of code. It provides multi-head support for xrandr and Xinerama.
+
  
==Installing==
+
== Installation ==
These instructions will install dwm using [[makepkg]] along with the Arch Build System, or [[ABS]] for short. This will allow reconfiguring it at a later time without complications. If only interested in installing dwm for a test drive, simply install the binary package from the repositories instead:
+
# pacman -S dwm
+
  
{{note|By omitting compiling dwm from source a great deal of customizability is lost, since dwm's entire configuration is performed by editing its source code. Taking this in mind, the rest of the article assumes that dwm has been compiled from source as explained in the entirety of this section.}}
+
{{note|If dwm is not compiled from source, opportunities for customization are lost since dwm's configuration is performed by editing its source code. See [[#Configuration]] for more information.}}
  
You will probably also want to consider installing [[dmenu]], a fast and lightweight dynamic menu for X:
+
[[Install]] the {{Pkg|dwm}} package. Alternatively, compile dwm from source using [[ABS]] or the {{AUR|dwm-git}} package (for the development version), making changes to the source code as desired. You may also want to install [[dmenu]], a fast and lightweight dynamic menu for [[Xorg]].
# pacman -S dmenu
+
  
===Requirements===
+
== Starting dwm ==
Basic programming tools present in {{Pkg|base-devel}} are needed in order to compile dwm and build a package for it, and the {{Pkg|abs}} package is also a requisite for fetching the necessary build scripts:
+
# pacman -S base-devel abs
+
  
===Download build scripts with ABS===
+
Select ''Dwm'' from the menu in a [[display manager]] of choice.
Once the required packages are installed, use ABS to update and then copy the dwm build scripts from the ABS tree to a temporary directory. For example:
+
# abs community/dwm
+
$ cp -r /var/abs/community/dwm ~/dwm
+
  
===Build and install package===
+
Alternatively, to start dwm with {{Ic|startx}} or the [[SLiM]] login manager, simply append the following to {{ic|~/.xinitrc}}:  
Use {{Ic|cd}} to switch to the directory containing the build scripts (the example above used {{ic|~/dwm}}). Then run:
+
  exec dwm
  $ makepkg -i
+
  
This will compile dwm, build an Arch Linux package containing the resulting files, and install the package file all in one step. If problems are encountered, review the output for specific information.
+
== Configuration ==
  
{{Tip|If this directory ({{ic|~/dwm}}) is saved, it can subsequently be used for making changes to the default configuration.}}
+
As mentioned in [[#Installation]], dwm is configured at compile-time by editing some of its source files, namely {{ic|config.h}} and {{ic|config.mk}} and also {{ic|dwm.c}}.
  
==Configuring==
+
Once changes have been made, update the checksums in the PKGBUILD, see [[PKGBUILD#Integrity]]. Alternatively, you can skip integrity checks by calling ''makepkg'' with the {{ic|--skipinteg}} switch.
dwm, as mentioned before, is exclusively configured at compile-time via some of its source files, namely {{ic|config.h}} and {{ic|config.mk}}. While the initial configuration provides a good set of defaults, it is reasonable to expect eventual customization.
+
  
===Method 1: ABS rebuild (recommended)===
+
Then, compile and reinstall dwm:
Modifying dwm is quite simple using this route.
+
$ makepkg -fi
  
====Customizing config.h====
+
Assuming the configuration changes were valid, the command above will compile dwm, build and reinstall the resulting package. If problems were encountered, review the output for specific information.
Browse to the dwm source code directory saved during the [[#Installing|installation process]]; {{ic|~/dwm}} in the example. The {{ic|config.h}} found within this directory is where the general dwm preferences are stored. Most settings within the file should be self-explanatory. For detailed information on these settings, see the [http://dwm.suckless.org/ dwm website].
+
  
{{note|Be sure to make a backup copy of config.h before modifying it, just in case something goes wrong.}}
+
Finally, restart dwm in order to apply the changes.
  
Once changes have been made, pipe the new md5sums into the [[PKGBUILD]]:
+
{{Tip|To recompile easily, make an alias by putting {{ic|alias redwm<nowiki>=</nowiki>'cd ~/dwm; updpkgsums; makepkg -fi --noconfirm; killall dwm'}} in your {{ic|.bashrc}} file.}}
$ makepkg -g >> PKGBUILD
+
This will eliminate a checksum mismatch between the official config.h and the new revised copy.
+
  
Now, compile and reinstall:
+
=== Patches ===
$ makepkg -efi
+
  
Assuming the configuration changes were valid, this command will compile dwm, build and reinstall the resulting package. If problems were encountered, review the output for specific information.
+
The official website has a number of [http://dwm.suckless.org/patches/ patches] that can add extra functionality to dwm. These patches primarily make changes to the {{ic|dwm.c}} file but also make changes to the {{ic|config.h}} file where appropriate. For information on applying patches, see [[Patching in ABS]].
  
Finally, restart dwm in order to apply the changes.
+
==== Window tiling patches ====
  
====Notes====
+
The [http://dwm.suckless.org/patches/bottom_stack Bottom Stack] patch provides an additional tiling mode that splits the screen horizontally, as opposed to the default vertically oriented tiling mode. Similarly, bstack horizontal splits the tiles horizontally. The [http://dwm.suckless.org/patches/gapless_grid gaplessgrid patch] allows windows to be tiled like a grid.
From now on, instead of updating the md5sums for every {{ic|config.h}} revision, which are known to become frequent, one may erase the md5sums array and build dwm with the {{Ic|--skipinteg}} option:
+
$ makepkg -efi --skipinteg
+
  
And after adding a few lines to dwm's start-up script, it is possible to [[#Restart dwm without logging out or closing programs|restart dwm without logging out or closing programs]].
+
The default behaviour of dwm is to apply the currently selected layout for all tags. To have different layouts for different tags use the [http://dwm.suckless.org/patches/pertag pertag] patch.
  
===Method 2: Mercurial (advanced)===
+
=== Customizing config.h ===
dwm is maintained upstream within a [http://www.selenic.com/mercurial/wiki/ Mercurial] version control system at [http://hg.suckless.org/dwm suckless.org]. Those already familiar with Mercurial may find it more convenient to maintain configurations and patches within this system. A [http://dwm.suckless.org/customisation/patch_queue detailed tutorial] on this method is available at the dwm website.
+
  
Before building dwm from the Mercurial sources, be sure to alter config.mk accordingly, because failure to do so may result in X crashes. Here are the values that need changing:
+
The {{ic|config.h}} file is where the general dwm preferences are stored. Most settings within the file should be self-explanatory. For detailed information on these settings, see the [http://dwm.suckless.org/customisation/ dwm website].
  
Modify {{Ic|PREFIX}}:
+
==== Adding custom keybinds/shortcuts ====
PREFIX = /usr
+
The X11 include folder:
+
X11INC = /usr/include/X11
+
And the the X11 lib directory:
+
X11LIB = /usr/lib/X11
+
  
==Starting dwm==
+
Two entries are needed in {{ic|config.h}} to create custom keybinds.  One under the {{ic|/* commands */}} section, and another under the {{ic|1=static Key keys[] = {}} section.
To start dwm with {{Ic|startx}} or the [[SLIM]] login manager, simply append the following to {{ic|~/.xinitrc}}:
+
exec dwm
+
  
For [[GDM]], add it to {{ic|~/.Xclients}} instead, and select "Run XClient Script" from the Sessions menu.
+
static const char *''keybindname''[]   = { "''command''", "''flags''", "''arguments''", NULL };
  
===Starting a customized dwm from a display manager===
+
{{ic|''keybindname''}} can be anything; {{ic|''command''}}, {{ic|''flags''}} and {{ic|''arguments''}} can be anything but they have to be individually enclosed in {{ic|""}}.
  
The default /usr/share/xsessions/dwm.desktop does not allow for a customized start like can be done in .xinitrc.
+
Some examples:
A solution to this problem is to make a start script, for example /usr/bin/dwm-personalized and make an alternative xsession .desktop file (/usr/share/xsessions/dwm-personalized.desktop).
+
  
Example of /usr/share/xsessions/dwm-personalized
+
{{ic|1={ MODKEY,            XK_''key'',      spawn,          {.v = ''keybindname'' } <nowiki>}</nowiki>}} would bind {{ic|Mod+''key''}} to the command defined previously.
<pre>[Desktop Entry]
+
Encoding=UTF-8
+
Name=Dwm-personalized
+
Comment=Dynamic window manager
+
Exec=dwm-personalized
+
Icon=dwm
+
Type=XSession
+
</pre>
+
  
Example of /usr/bin/dwm-personalized
+
{{ic|1={ MODKEY<nowiki>|</nowiki>ShiftMask,  XK_''key'',      spawn,          {.v = ''keybindname'' } <nowiki>}</nowiki>}} would bind {{ic|Mod+Shift+''key''}}  Use ControlMask for {{ic|Ctrl}} key.
  
<pre>#!/bin/zsh
+
Single keys such as {{ic|Fn}} or multimedia keys have to be bound with the hex codes obtainable from the program ''xev''.
  
#Set swedish keyboard map
+
{{ic|1={ 0,                0xff00,    spawn,      {.v = ''keybindname'' } <nowiki>}</nowiki>}} would bind foo key {{ic|0xff00}} to {{ic|''keybindname''}}.
setxkbmap se
+
  
#Set chrome as default browser
+
See [[Extra keyboard keys#Keycodes]] for information on finding keycodes.
if [ -n "$DISPLAY" ]; then
+
    BROWSER=google-chrome
+
fi
+
  
#Set status bar & start DWM
+
=== Customizing config.mk ===
conky | while read -r; do xsetroot -name "$REPLY"; done &
+
exec dwm
+
</pre>
+
  
==Statusbar configuration==
+
{{Warning|Installing software directly from source without creating a package is '''not recommended''' as [[pacman]] will not be able to track the installed files.}}
dwm uses the root window's name to display information in its statusbar, which can be changed with {{Ic|xsetroot -name}}.
+
  
===Basic statusbar===
+
The {{ic|config.mk}} file is included by Makefile. It allows you to configure how GNU ''make'' is going to compile and install dwm.
This example prints the date in [[wikipedia:ISO_8601|ISO 8601]] format. Add it to files {{ic|~/.xinitrc}} or {{ic|~/.Xclients}} or see this page's discussion for more details about the GDM-3 case :
+
<pre>
+
while true; do
+
  xsetroot -name "$( date +"%F %R" )"
+
  sleep 1m    # Update time every minute
+
done &
+
exec dwm
+
</pre>
+
  
Here is an example intended for laptops that depends on the {{Pkg|acpi}} package for showing battery information:
+
If you are installing dwm directly from source, without creating a package first, then be sure to alter {{ic|config.mk}} to set the correct prefixes:
<pre>
+
while true ; do
+
    xsetroot -name "$(acpi -b | awk 'sub(/,/,"") {print $3, $4}')"
+
    sleep 1m
+
done &
+
exec dwm
+
</pre>
+
  
The script displays the amount of battery remaining besides its charging status by using the awk command to trim away the unneeded text from acpi, and tr to remove the commas.
+
Modify {{Ic|PREFIX}}:
 +
PREFIX = /usr
 +
The X11 include folder:
 +
X11INC = /usr/include/X11
 +
And the the X11 lib directory:
 +
X11LIB = /usr/lib/X11
  
An alternative to the above is to selectively show the battery status depending on the current charging state:
+
{{Tip|If you only wish to test configuration changes without affecting systemwide dwm, change {{ic|PREFIX}} to a local directory such as {{ic|${HOME}/.local}}. Note that if you are compiling using the {{Pkg|dwm}} [[PKGBUILD]], you should change the {{ic|PREFIX}} in the PKGBUILD instead as this will take precedence over {{ic|config.mk}} - see the ''package()'' function - and you should also change the {{ic|pkgname}}.}}
<pre>
+
while true; do
+
batt=$(LC_ALL=C acpi -b)
+
  
case $batt in
+
=== Statusbar configuration ===
*Discharging*)
+
batt="${batt#* * * }"
+
batt="${batt%%, *} "
+
;;
+
*)
+
batt=""
+
;;
+
esac
+
  
xsetroot -name "$batt$(date +%R)"
+
{{Note|The following requires the {{Pkg|xorg-xsetroot}} package to be installed.}}
  
sleep 60
+
Dwm reads the name of the root window and redirects it to the statusbar. The root window is the window within which all other windows are drawn and arranged by the window manager. Like any other window, the root window has a title/name, but it is usually undefined because the root window always runs in the background.
 +
 
 +
The information that you want dwm to show in the statusbar should be defined with {{ic|xsetroot -name ""}} command in {{ic|~/.xinitrc}} or {{ic|~/.xprofile}} (if you are using a [[display manager]]). For example:
 +
{{bc|xsetroot -name "Thanks for all the fish!"}}
 +
 
 +
Dynamically updated information should be put in a loop which is forked to background - see the example below:
 +
{{bc|
 +
# Statusbar loop
 +
while true; do
 +
  xsetroot -name "$( date +"%F %R" )"
 +
  sleep 1m    # Update time every minute
 
done &
 
done &
 +
 +
# Autostart section
 +
pcmanfm &
  
 
exec dwm
 
exec dwm
</pre>
+
}}
 +
In this case the date is shown in [[wikipedia:ISO_8601|ISO 8601]] format and [[PCManFM]] is launched at startup.
  
Finally, make sure there is only one instance of dwm in {{ic|~/.xinitrc}} or {{ic|~/.Xclients}}, so combining everything together should resemble this:
+
{{note|It is not recommended to set the update interval equal to zero or remove the "sleep" line entirely since this will cause CPU usage to rise substantially (you can assess the effect with ''top'' and [[powertop]]).}}
~/.setbg
+
autocutsel &
+
termirssi &
+
urxvt &
+
+
while true; do
+
    xsetroot -name "$(date +"%F %R")"
+
    sleep 1m    # Update time every minute
+
done &
+
'''exec dwm'''
+
  
Here is another example that displays also the alsa volume and the battery state. The latter only when the system is off-line.
+
==== Examples of statusbar configuration ====
 +
 
 +
This example shows battery state (note that it depends on the {{Pkg|acpi}} package):
 +
{{bc|<nowiki>
 +
while true ; do
 +
    xsetroot -name "$(acpi -b | awk 'sub(/,/,"") {print $3, $4}')"
 +
    sleep 1m
 +
done &
 +
exec dwm
 +
</nowiki>}}
  
#set statusbar
+
Below is another example that displays also the [[ALSA]] volume and the battery state. The latter is displayed only when the system is off-line.
 +
{{bc|<nowiki>#set statusbar
 
  while true
 
  while true
 
  do
 
  do
Line 192: Line 143:
 
     sleep 1s   
 
     sleep 1s   
 
  done &
 
  done &
 +
</nowiki>}}
 +
 +
Alternatively, you could create a script with variables for each type of data to be displayed - this should improve readability and maintainability. See the example below:
 +
{{bc|<nowiki>
 +
while true; do
 +
 +
# Power/Battery Status
 +
if [ "$( cat /sys/class/power_supply/AC0/online )" -eq "1" ]; then
 +
        DWM_BATTERY="AC";
 +
        DWM_RENEW_INT=3;
 +
else
 +
        DWM_BATTERY=$(( `cat /sys/class/power_supply/BAT0/energy_now` * 100 / `cat /sys/class/power_supply/BAT0/energy_full` ));
 +
        DWM_RENEW_INT=30;
 +
fi;
 +
 +
# Wi-Fi eSSID
 +
if [ "$( cat /sys/class/net/eth1/rfkill1/state )" -eq "1" ]; then
 +
  DWM_ESSID=$( /sbin/iwgetid -r );
 +
else
 +
  DWM_ESSID="OFF";
 +
fi;
 +
 +
# Keyboard layout
 +
if [ "`xset -q | awk -F \" \" '/Group 2/ {print($4)}'`" = "on" ]; then
 +
  DWM_LAYOUT="ru";
 +
else
 +
  DWM_LAYOUT="en";
 +
fi;
 +
 +
# Volume Level
 +
DWM_VOL=$( amixer -c1 sget Master | awk -vORS=' ' '/Mono:/ {print($6$4)}' );
 +
 +
# Date and Time
 +
DWM_CLOCK=$( date '+%e %b %Y %a | %k:%M' );
 +
 +
# Overall output command
 +
DWM_STATUS="WiFi: [$DWM_ESSID] | Lang: [$DWM_LAYOUT] | Power: [$DWM_BATTERY] | Vol: $DWM_VOL | $DWM_CLOCK";
 +
xsetroot -name "$DWM_STATUS";
 +
sleep $DWM_RENEW_INT;
 +
 +
done &
 +
</nowiki>}}
 +
 +
Example output from the script above:
 +
{{bc|<nowiki>WiFi: [OFF] | Lang: [en] | Power: [96] | Vol: [on][31%]  | 10 Jan 2014 Fri | 23:01
 +
</nowiki>}}
 +
 +
{{note|In the script above the "sleep" interval is adjusted automatically depending on whether your laptop is running on battery or not. For desktop computers without a battery, this section is not necessary.}}
 +
 +
==== Conky statusbar ====
  
===Conky statusbar===
 
 
[[Conky]] can be printed to the statusbar with {{Ic|xsetroot -name}}:
 
[[Conky]] can be printed to the statusbar with {{Ic|xsetroot -name}}:
  conky | while read -r; do xsetroot -name "$REPLY"; done &
+
  (conky | while read LINE; do xsetroot -name "$LINE"; done) &
 
  exec dwm
 
  exec dwm
  
To do this, conky needs to be told to output text to the console only. The following is a sample conkyrc for a dual core CPU, displaying several stats:
+
To do this, conky needs to be told to output text to the console only. The following is a sample conkyrc for a dual core CPU, displaying several usage statistics:
<pre>
+
{{bc|
 
out_to_console yes
 
out_to_console yes
 
out_to_x no
 
out_to_x no
Line 209: Line 209:
 
TEXT
 
TEXT
 
$mpd_smart :: ${cpu cpu1}% / ${cpu cpu2}%  ${loadavg 1} ${loadavg 2 3} :: ${acpitemp}c :: $memperc% ($mem) :: ${downspeed eth0}K/s ${upspeed eth0}K/s :: ${time %a %b %d %I:%M%P}
 
$mpd_smart :: ${cpu cpu1}% / ${cpu cpu2}%  ${loadavg 1} ${loadavg 2 3} :: ${acpitemp}c :: $memperc% ($mem) :: ${downspeed eth0}K/s ${upspeed eth0}K/s :: ${time %a %b %d %I:%M%P}
</pre>
+
}}
  
==Basic usage==
+
For icons and color options, see [[dzen]].
===Using dmenu===
+
Dmenu is a useful addon to dwm. Rather than a standard list-style menu, it acts as a sort of autocomplete to typing in the names of binaries. It is more advanced than many program launchers and integrates well within dwm.
+
  
To start it, press {{Keypress|Mod1}} + {{Keypress|P}} ({{Keypress|Mod1}} should be the {{Keypress|Alt}} key by default). This can, of course, be changed if you so desire. Then, simply type in the first few characters of the binary you wish to run until you see it along the top bar. Then, simply use your left and right arrow keys to navigate to it and press enter.
+
== Basic usage ==
  
For more information, see [[dmenu]].
+
Besides the following sections, also consult the [http://dwm.suckless.org/tutorial dwm tutorial] for information on basic dwm usage.
  
===Controlling windows===
+
=== Using dmenu ===
====Moving a window to another tag====
+
Moving a window from one tag to another is very simple. To do so, simply bring the window into focus by hovering over it with your cursor, then press {{Keypress|Shift}} + {{Keypress|Mod1}} + {{Keypress|x}}, where 'x' is the number of the tag to which you want to move the window. [Mod1] is, by default, the {{Keypress|Alt}} key.
+
====Closing a window====
+
To cleanly close a window using dwm, simply press {{Keypress|Shift}} + {{Keypress|Mod1}} + {{Keypress|C}}.
+
  
====Window layouts====
+
To start [[dmenu]], press {{ic|Mod1}} + {{ic|P}} ({{ic|Mod1}} should be the {{ic|Alt}} key by default). This can be changed if you so desire. Then, simply type in the first few characters of the binary you wish to run until you see it along the top bar. Use your left and right arrow keys to navigate to the binary and press enter.
By default, dwm will operate in tiled mode. This can be observed by new windows on the same tag growing smaller and smaller as new windows are opened. The windows will, together, take up the entire screen (except for the menu bar) at all times. There are, however, two other modes: floating and monocle. Floating mode should be familiar to users of non-tiling window managers; it allows users to rearrange windows as they please. Monocle mode will keep a single window visible at all times.
+
  
To switch to floating mode, simply press {{Keypress|Mod1}} + {{Keypress|F}}. {{Keypress|Mod1}} is, by default, the {{Keypress|Alt}} key. To check if you are in floating mode, you should see something like this next to the numbered tags in the top right corner of the screen: X>.
+
=== Controlling windows ===
  
To switch to monocole mode, press {{Keypress|Mod1}} + {{Keypress|M}}. To check if you are in monocle mode, you can see an M in square brackets (if no windows are open on that tag) or a number in square brackets (which corresponds with the number of windows open on that tag). Thus, a tag with no windows open would display this: [M], and a tag with 'n' windows open would display this: [n].
+
==== Giving another tag to a window ====
  
To return to tiled mode, press {{Keypress|Mod1}} + {{Keypress|T}}. You will see a symbol which looks like this: []= .
+
Changing a window's tag is simple. To do so, simply bring the window into focus by hovering over it with your cursor. Then press {{ic|Shift}} + {{ic|Mod1}} + {{ic|x}}, where {{ic|x}} is the number of the tag to which you want to move the window. {{ic|Mod1}} is, by default, the {{ic|Alt}} key.
  
===Exiting dwm===
+
==== Closing a window ====
To cleanly exit dwm, press {{Keypress|Shift}} + {{Keypress|Mod1}} + {{Keypress|Q}}.
+
  
Source: [http://dwm.suckless.org/tutorial dwm tutorial].
+
To cleanly close a window using dwm, simply press {{ic|Shift}} + {{ic|Mod1}} + {{ic|c}}.
  
==Extended usage==
+
==== Window layouts ====
  
===Patches & additional tiling modes===
+
By default, dwm will operate in tiled mode. This can be observed by new windows on the same tag growing smaller and smaller as new windows are opened. The windows will, together, take up the entire screen (except for the menu bar) at all times. There are, however, two other modes: floating and monocle. Floating mode should be familiar to users of non-tiling window managers; it allows users to rearrange windows as they please. Monocle mode will keep a single window visible at all times.
The official website has a number of [http://dwm.suckless.org/patches/ patches] that can add extra functionality to dwm. Users can easily customize dwm by applying the modifications they like. The [http://dwm.suckless.org/patches/bottom_stack Bottom Stack] patch provides an additional tiling mode that splits the screen horizontally, as opposed to the default vertically oriented tiling mode. Similarly, bstack horizontal splits the tiles horizontally.  
+
  
The [http://dwm.suckless.org/patches/gapless_grid gaplessgrid patch] allows windows to be tiled like a grid.
+
To switch to floating mode, simply press {{ic|Mod1}} + {{ic|F}}. {{ic|Mod1}} is, by default, the {{ic|Alt}} key. To check if you are in floating mode, you should see something like this next to the numbered tags in the top right corner of the screen: ><>.
  
====Enable one layout per tag====
+
To switch to monocole mode, press {{ic|Mod1}} + {{ic|M}}. To check if you are in monocle mode, you can see an M in square brackets (if no windows are open on that tag) or a number in square brackets (which corresponds with the number of windows open on that tag). Thus, a tag with no windows open would display this: [M], and a tag with 'n' windows open would display this: [n].
The default behaviour of dwm is to apply the currently selected layout for all tags.To have different layouts for different tags use the [http://dwm.suckless.org/patches/pertag pertag] patch.
+
  
===Fixing gaps around terminal windows===
+
To return to tiled mode, press {{ic|Mod1}} + {{ic|T}}. You will see a symbol which looks like this: []= .
If there are empty gaps of desktop space outside terminal windows, it is likely due to the terminal's font size. Either adjust the size until finding the ideal scale that closes the gap, or toggle {{Ic|resizehints}} to ''False'' in {{ic|config.h}}:
+
static Bool resizehints = False; /* False means respect size hints in tiled resizals */
+
  
This will cause dwm to ignore resize requests from all client windows, not just terminals. The downside to this workaround is that some terminals may suffer redraw anomalies, such as ghost lines and premature line wraps, among others.
+
For using alternate window layouts, see [[#Window tiling patches]].
  
====Urxvt====
+
=== Exiting dwm ===
{{Out of date|layoutgaps.patch has been applied upstream in December 2011 and is no longer part of {{AUR|rxvt-unicode-patched}}. Solution below does not work for dwm-6.0 and rxvt-unicode-9.15. }}
+
Another choice for [[urxvt]] users is applying the [[urxvt#Fix maximized window gaps|hints patch]] and regressing to dwm's original behaviour:
+
static Bool resizehints = '''True''';
+
  
===Restart dwm without logging out or closing programs===
+
To cleanly exit dwm, press {{ic|Shift}} + {{ic|Mod1}} + {{ic|q}}.
For restarting dwm without logging out or closing applications, change or add a startup script so that it loads dwm in a ''while'' loop, like this:
+
 
<pre>
+
== Tips and tricks ==
 +
 
 +
=== Restart dwm without logging out or closing programs ===
 +
 
 +
For restarting dwm without logging out or closing applications, change or add a startup script so that it loads dwm in a ''while'' loop, see below:
 +
{{bc|
 
while true; do
 
while true; do
 
     # Log stderror to a file  
 
     # Log stderror to a file  
Line 269: Line 259:
 
     #dwm >/dev/null 2>&1
 
     #dwm >/dev/null 2>&1
 
done
 
done
</pre>
+
}}
  
 
dwm can now be restarted without destroying other X windows by pressing the usual Mod-Shift-Q combination.
 
dwm can now be restarted without destroying other X windows by pressing the usual Mod-Shift-Q combination.
  
It is a good idea to place the above startup script into a separate file, {{ic|~/bin/startdwm}} for instance, and execute it through {{ic|~/.xinitrc}}. From this point on, when desiring to actually end the X session simply execute {{Ic|killall startdwm}}, or bind it to a convenient key.
+
It is a good idea to place the above startup script into a separate file, {{ic|~/bin/startdwm}} for instance, and execute it through {{ic|~/.xinitrc}}. From this point on, when you wish to end the X session, simply execute {{Ic|killall xinit}}, or bind it to a convenient key. Alternatively, you could setup your dwm session script so that it relaunches dwm only if the binary changes.  This could be useful in the case where you change a setting or update the dwm code base.
 +
 
 +
{{bc|1=
 +
# relaunch DWM if the binary changes, otherwise bail
 +
csum=$(sha1sum $(which dwm))
 +
new_csum=""
 +
while true
 +
do
 +
    if [ "$csum" != "$new_csum" ]
 +
    then
 +
        csum=$new_csum
 +
        dwm
 +
    else
 +
        exit 0
 +
    fi
 +
    new_csum=$(sha1sum $(which dwm))
 +
    sleep 0.5
 +
done
 +
}}
 +
 
 +
=== Make the right Alt key work as if it were Mod4 (Windows Key) ===
  
===Make the right Alt key work as if it were Mod4 (Windows Key)===
+
When using Mod4 (the Super/Windows Key) as the {{Ic|MODKEY}}, it may be equally convenient to have the right Alt key ({{ic|Alt_R}}) act as {{ic|Mod4}}. This will allow you to perform otherwise awkward keystrokes one-handed, such as zooming with {{ic|Alt_R}}+{{ic|Enter}}.  
When using Mod4 (aka Super/Windows Key) as the {{Ic|MODKEY}}, it may be equally convenient to have the right Alt key (Alt_R) act as Mod4. This will allow performing otherwise awkward keystrokes one-handed, such as zooming with Alt_R+Enter.  
+
  
First, find out which keycode is assigned to Alt_R:
+
First, find out which keycode is assigned to {{ic|Alt_R}}:
 
  xmodmap -pke | grep Alt_R
 
  xmodmap -pke | grep Alt_R
  
Line 285: Line 294:
 
  xmodmap -e "remove mod1 = Super_L"  # make sure X keeps it out of the mod1 group
 
  xmodmap -e "remove mod1 = Super_L"  # make sure X keeps it out of the mod1 group
  
Now, any functions that are triggered by a Super_L (Windows) key press will also be triggered by an Alt_R key press.
+
After doing so, any functions that are triggered by the {{ic|Super_L}} key press will also be triggered by an {{ic|Alt_R}} key press.
===Disable focus follows mouse behaviour===
+
To disable focus follows mouse behaviour  comment out the following line in definiton of struct handler in dwm.c
+
<pre>[EnterNotify] = enternotify, </pre>
+
Note that this change can cause some difficulties. After it the first click on inactive window will only bring the focus on it. To interact with window contents (buttons, fields etc) you need to click again. Also if you have several monitors you can notice that keyboard focus doesn't switch to another monitor activated by clicking.
+
  
===Adding custom keybinds/shortcuts===
+
{{note|There is a #define option in [[#Customizing config.h|config.h]] which also allows you to switch the modkey}}
Two entries are needed in {{ic|config.h}} to create custom keybinds. One under the "/* commands /*" section, and another under the "static Key keys[] = {" section.
+
  
static const char *<keybindname>[]  = { "<command>", "<flags>", "<arguments>", NULL };
+
=== Space around font in dwm's bar ===
  
<keybindname> can be anything... <command> <-flags> and <arguments> can be anything but they have to be individually enclosed in "",
+
By default, dwm's bar adds 2px around the size of the font. To change this, modify the following line in {{ic|dwm.c}}:
 +
{{bc|1=bh = dc.h = dc.font.height + 2;}}
  
{ MODKEY,            XK_<key>,      spawn,          {.v = <keybindname> } },
+
=== Disable focus follows mouse behaviour ===
  
...would bind Mod+<key> to the command defined previously.
+
To disable focus follows mouse behaviour  comment out the following line in definiton of struct handler in {{ic|dwm.c}}
 +
{{bc|1=[EnterNotify] = enternotify, }}
 +
Note that this change can cause some difficulties; the first click on an inactive window will only bring the focus to it. To interact with window contents (buttons, fields etc) you need to click again. Also, if you have several monitors, you may notice that the keyboard focus does not switch to another monitor activated by clicking.
  
{ MODKEY|ShiftMask,  XK_<key>,      spawn,          {.v = <keybindname> } },
+
=== Make some windows start floating ===
  
...would bind Mod+Shift+<key>  Use ControlMask for Ctrl key.
+
For some windows, such as preferences dialogs, it does not make sense for these windows to be tiled - they should be free-floating instead. For example, to make Firefox's preferences dialog float, add the following to your rules array in {{ic|config.h}}:
 +
  { "Firefox",    NULL,      "Firefox Preferences",        1 << 8,        True,    -1 },
  
Single keys such as Fn or multimedia keys have to be bound with the hex codes obtainable from the program "xev"
+
== Troubleshooting ==
  
{ 0,                0xff00,    spawn,      {.v = <keybindname> } },
+
=== Fixing misbehaving Java applications ===
  
...would bind foo key 0xff00 to <keybindname>
+
As of JRE 6u20, Java applications may misbehave in dwm because dwm is not a known window manager for [[Java]]. The misbehavior may include menus closing when the mouse is released and other minor issues. Firstly, install the {{Pkg|wmname}} package.
  
===Fixing misbehaving Java applications===
+
Now use ''wmname'' to set a WM name that Java recognizes:
 +
$ wmname LG3D
  
As of JRE 6u20, Java applications misbehave in dwm because it is not a known window manager to Java. This causes menus to close when the mouse is released, and other little issues. First, install wmname from the [community] repository:
+
{{Note|This may cause some programs to behave oddly when tiled (specifically [[Chromium]]).}}
# pacman -S wmname
+
This setting is not persistent so you may want to add this command to your {{ic|.xinitrc}} or {{ic|.xprofile}}.
  
Now all you have to do is use wmname to set a WM name that Java recognizes:
+
Alternatively, it is also possible to change enable {{ic|1=export _JAVA_AWT_WM_NONREPARENTING=1}} in {{ic|/etc/profile.d/jre.sh}}
$ wmname LG3D
+
  
This is not permanent, so you may want to add this command to your .xinitrc.
+
=== Fixing the extra topbar that does not disappear when changing resolution/monitors ===
 +
 
 +
{{Note|this patch is intended for dwm-6.0 which is currently in the [[official repositories]]. The development version of dwm has already implemented this.}}
 +
 
 +
When resizing or connecting/disconnecting different monitors there may be a remnant of the topbar stuck on the screen which cannot be removed. To fix this bug, rebuild dwm with [http://ix.io/fea this patch].
 +
 
 +
=== Fixing gaps around terminal windows ===
 +
 
 +
If there are empty gaps of desktop space outside terminal windows, it is likely due to the terminal's font size. Either adjust the size until finding the ideal scale that closes the gap, or toggle {{Ic|resizehints}} to ''False'' in {{ic|config.h}}:
 +
static Bool resizehints = False; /* True means respect size hints in tiled resizals */
 +
 
 +
This will cause dwm to ignore resize requests from all client windows, not just terminals. The downside to this workaround is that some terminals may suffer redraw anomalies, such as ghost lines and premature line wraps, among others.
  
It is also possible to change enable {{ic|1=export _JAVA_AWT_WM_NONREPARENTING=1}} in {{ic|/etc/profile.d/jre.sh}}
+
== See also ==
  
==See also==
 
 
* [http://dwm.suckless.org/ dwm's official website]
 
* [http://dwm.suckless.org/ dwm's official website]
 
* [http://www.youtube.com/watch?v=GQ5s6T25jCc Introduction to dwm video]
 
* [http://www.youtube.com/watch?v=GQ5s6T25jCc Introduction to dwm video]
Line 332: Line 350:
 
* Check out the forums' [https://bbs.archlinux.org/viewtopic.php?id=57768/ wallpaper thread] for a selection of dwm wallpapers
 
* Check out the forums' [https://bbs.archlinux.org/viewtopic.php?id=57768/ wallpaper thread] for a selection of dwm wallpapers
 
*[https://bbs.archlinux.org/viewtopic.php?id=74599 Show off your dwm configuration forum thread]
 
*[https://bbs.archlinux.org/viewtopic.php?id=74599 Show off your dwm configuration forum thread]
* [http://0x80.org/blog/?p=72 Moved to dwm]
+
* [http://wongdev.com/blog/dwm-tags-are-not-workspaces/ dwm: Tags are not workspaces]

Latest revision as of 00:40, 19 January 2016

Related articles

dwm is a dynamic window manager for Xorg. It manages windows in tiled, stacked, and full-screen layouts, as well as many others with the help of optional patches. Layouts can be applied dynamically, optimizing the environment for the application in use and the task being performed. dwm is extremely lightweight and fast, written in C and with a stated design goal of remaining under 2000 source lines of code. It provides multihead support for xrandr and Xinerama.

Installation

Note: If dwm is not compiled from source, opportunities for customization are lost since dwm's configuration is performed by editing its source code. See #Configuration for more information.

Install the dwm package. Alternatively, compile dwm from source using ABS or the dwm-gitAUR package (for the development version), making changes to the source code as desired. You may also want to install dmenu, a fast and lightweight dynamic menu for Xorg.

Starting dwm

Select Dwm from the menu in a display manager of choice.

Alternatively, to start dwm with startx or the SLiM login manager, simply append the following to ~/.xinitrc:

exec dwm

Configuration

As mentioned in #Installation, dwm is configured at compile-time by editing some of its source files, namely config.h and config.mk and also dwm.c.

Once changes have been made, update the checksums in the PKGBUILD, see PKGBUILD#Integrity. Alternatively, you can skip integrity checks by calling makepkg with the --skipinteg switch.

Then, compile and reinstall dwm:

$ makepkg -fi

Assuming the configuration changes were valid, the command above will compile dwm, build and reinstall the resulting package. If problems were encountered, review the output for specific information.

Finally, restart dwm in order to apply the changes.

Tip: To recompile easily, make an alias by putting alias redwm='cd ~/dwm; updpkgsums; makepkg -fi --noconfirm; killall dwm' in your .bashrc file.

Patches

The official website has a number of patches that can add extra functionality to dwm. These patches primarily make changes to the dwm.c file but also make changes to the config.h file where appropriate. For information on applying patches, see Patching in ABS.

Window tiling patches

The Bottom Stack patch provides an additional tiling mode that splits the screen horizontally, as opposed to the default vertically oriented tiling mode. Similarly, bstack horizontal splits the tiles horizontally. The gaplessgrid patch allows windows to be tiled like a grid.

The default behaviour of dwm is to apply the currently selected layout for all tags. To have different layouts for different tags use the pertag patch.

Customizing config.h

The config.h file is where the general dwm preferences are stored. Most settings within the file should be self-explanatory. For detailed information on these settings, see the dwm website.

Adding custom keybinds/shortcuts

Two entries are needed in config.h to create custom keybinds. One under the /* commands */ section, and another under the static Key keys[] = { section.

static const char *keybindname[]   = { "command", "flags", "arguments", NULL };

keybindname can be anything; command, flags and arguments can be anything but they have to be individually enclosed in "".

Some examples:

{ MODKEY, XK_key, spawn, {.v = keybindname } } would bind Mod+key to the command defined previously.

{ MODKEY|ShiftMask, XK_key, spawn, {.v = keybindname } } would bind Mod+Shift+key Use ControlMask for Ctrl key.

Single keys such as Fn or multimedia keys have to be bound with the hex codes obtainable from the program xev.

{ 0, 0xff00, spawn, {.v = keybindname } } would bind foo key 0xff00 to keybindname.

See Extra keyboard keys#Keycodes for information on finding keycodes.

Customizing config.mk

Warning: Installing software directly from source without creating a package is not recommended as pacman will not be able to track the installed files.

The config.mk file is included by Makefile. It allows you to configure how GNU make is going to compile and install dwm.

If you are installing dwm directly from source, without creating a package first, then be sure to alter config.mk to set the correct prefixes:

Modify PREFIX:

PREFIX = /usr

The X11 include folder:

X11INC = /usr/include/X11

And the the X11 lib directory:

X11LIB = /usr/lib/X11
Tip: If you only wish to test configuration changes without affecting systemwide dwm, change PREFIX to a local directory such as ${HOME}/.local. Note that if you are compiling using the dwm PKGBUILD, you should change the PREFIX in the PKGBUILD instead as this will take precedence over config.mk - see the package() function - and you should also change the pkgname.

Statusbar configuration

Note: The following requires the xorg-xsetroot package to be installed.

Dwm reads the name of the root window and redirects it to the statusbar. The root window is the window within which all other windows are drawn and arranged by the window manager. Like any other window, the root window has a title/name, but it is usually undefined because the root window always runs in the background.

The information that you want dwm to show in the statusbar should be defined with xsetroot -name "" command in ~/.xinitrc or ~/.xprofile (if you are using a display manager). For example:

xsetroot -name "Thanks for all the fish!"

Dynamically updated information should be put in a loop which is forked to background - see the example below:

# Statusbar loop
while true; do
   xsetroot -name "$( date +"%F %R" )"
   sleep 1m    # Update time every minute
done &

# Autostart section
pcmanfm & 

exec dwm

In this case the date is shown in ISO 8601 format and PCManFM is launched at startup.

Note: It is not recommended to set the update interval equal to zero or remove the "sleep" line entirely since this will cause CPU usage to rise substantially (you can assess the effect with top and powertop).

Examples of statusbar configuration

This example shows battery state (note that it depends on the acpi package):

while true ; do
    xsetroot -name "$(acpi -b | awk 'sub(/,/,"") {print $3, $4}')"
    sleep 1m
done &
exec dwm

Below is another example that displays also the ALSA volume and the battery state. The latter is displayed only when the system is off-line.

#set statusbar
 while true
 do
    if acpi -a | grep off-line > /dev/null; then
        xsetroot -name "Bat. $(awk 'sub(/,/,"") {print $3, $4}' <(acpi -b)) \
        | Vol. $(awk '/dB/ { gsub(/[\[\]]/,""); print $5}' <(amixer get Master)) \
        | $(date +"%a, %b %d %R")"
    else
        xsetroot -name "Vol. $(awk '/dB/ { gsub(/[\[\]]/,""); print $5}' <(amixer get Master)) \
        | $(date +"%a, %b %d %R")"
    fi
    sleep 1s   
 done &

Alternatively, you could create a script with variables for each type of data to be displayed - this should improve readability and maintainability. See the example below:

while true; do

# Power/Battery Status
if [ "$( cat /sys/class/power_supply/AC0/online )" -eq "1" ]; then
        DWM_BATTERY="AC";
        DWM_RENEW_INT=3;
else
        DWM_BATTERY=$(( `cat /sys/class/power_supply/BAT0/energy_now` * 100 / `cat /sys/class/power_supply/BAT0/energy_full` ));
        DWM_RENEW_INT=30;
fi;

# Wi-Fi eSSID
if [ "$( cat /sys/class/net/eth1/rfkill1/state )" -eq "1" ]; then
		  DWM_ESSID=$( /sbin/iwgetid -r ); 
else
		  DWM_ESSID="OFF";
fi;

# Keyboard layout
if [ "`xset -q | awk -F \" \" '/Group 2/ {print($4)}'`" = "on" ]; then 
		  DWM_LAYOUT="ru"; 
else 
		  DWM_LAYOUT="en"; 
fi; 

# Volume Level
DWM_VOL=$( amixer -c1 sget Master | awk -vORS=' ' '/Mono:/ {print($6$4)}' );

# Date and Time
DWM_CLOCK=$( date '+%e %b %Y %a | %k:%M' );

# Overall output command
DWM_STATUS="WiFi: [$DWM_ESSID] | Lang: [$DWM_LAYOUT] | Power: [$DWM_BATTERY] | Vol: $DWM_VOL | $DWM_CLOCK";
xsetroot -name "$DWM_STATUS";
sleep $DWM_RENEW_INT;

done &

Example output from the script above:

WiFi: [OFF] | Lang: [en] | Power: [96] | Vol: [on][31%]  | 10 Jan 2014 Fri | 23:01
Note: In the script above the "sleep" interval is adjusted automatically depending on whether your laptop is running on battery or not. For desktop computers without a battery, this section is not necessary.

Conky statusbar

Conky can be printed to the statusbar with xsetroot -name:

(conky | while read LINE; do xsetroot -name "$LINE"; done) &
exec dwm

To do this, conky needs to be told to output text to the console only. The following is a sample conkyrc for a dual core CPU, displaying several usage statistics:

out_to_console yes
out_to_x no
background no
update_interval 2
total_run_times 0
use_spacer none

TEXT
$mpd_smart :: ${cpu cpu1}% / ${cpu cpu2}%  ${loadavg 1} ${loadavg 2 3} :: ${acpitemp}c :: $memperc% ($mem) :: ${downspeed eth0}K/s ${upspeed eth0}K/s :: ${time %a %b %d %I:%M%P}

For icons and color options, see dzen.

Basic usage

Besides the following sections, also consult the dwm tutorial for information on basic dwm usage.

Using dmenu

To start dmenu, press Mod1 + P (Mod1 should be the Alt key by default). This can be changed if you so desire. Then, simply type in the first few characters of the binary you wish to run until you see it along the top bar. Use your left and right arrow keys to navigate to the binary and press enter.

Controlling windows

Giving another tag to a window

Changing a window's tag is simple. To do so, simply bring the window into focus by hovering over it with your cursor. Then press Shift + Mod1 + x, where x is the number of the tag to which you want to move the window. Mod1 is, by default, the Alt key.

Closing a window

To cleanly close a window using dwm, simply press Shift + Mod1 + c.

Window layouts

By default, dwm will operate in tiled mode. This can be observed by new windows on the same tag growing smaller and smaller as new windows are opened. The windows will, together, take up the entire screen (except for the menu bar) at all times. There are, however, two other modes: floating and monocle. Floating mode should be familiar to users of non-tiling window managers; it allows users to rearrange windows as they please. Monocle mode will keep a single window visible at all times.

To switch to floating mode, simply press Mod1 + F. Mod1 is, by default, the Alt key. To check if you are in floating mode, you should see something like this next to the numbered tags in the top right corner of the screen: ><>.

To switch to monocole mode, press Mod1 + M. To check if you are in monocle mode, you can see an M in square brackets (if no windows are open on that tag) or a number in square brackets (which corresponds with the number of windows open on that tag). Thus, a tag with no windows open would display this: [M], and a tag with 'n' windows open would display this: [n].

To return to tiled mode, press Mod1 + T. You will see a symbol which looks like this: []= .

For using alternate window layouts, see #Window tiling patches.

Exiting dwm

To cleanly exit dwm, press Shift + Mod1 + q.

Tips and tricks

Restart dwm without logging out or closing programs

For restarting dwm without logging out or closing applications, change or add a startup script so that it loads dwm in a while loop, see below:

while true; do
    # Log stderror to a file 
    dwm 2> ~/.dwm.log
    # No error logging
    #dwm >/dev/null 2>&1
done

dwm can now be restarted without destroying other X windows by pressing the usual Mod-Shift-Q combination.

It is a good idea to place the above startup script into a separate file, ~/bin/startdwm for instance, and execute it through ~/.xinitrc. From this point on, when you wish to end the X session, simply execute killall xinit, or bind it to a convenient key. Alternatively, you could setup your dwm session script so that it relaunches dwm only if the binary changes. This could be useful in the case where you change a setting or update the dwm code base.

# relaunch DWM if the binary changes, otherwise bail
csum=$(sha1sum $(which dwm))
new_csum=""
while true
do
    if [ "$csum" != "$new_csum" ]
    then
        csum=$new_csum
        dwm
    else
        exit 0
    fi
    new_csum=$(sha1sum $(which dwm))
    sleep 0.5
done

Make the right Alt key work as if it were Mod4 (Windows Key)

When using Mod4 (the Super/Windows Key) as the MODKEY, it may be equally convenient to have the right Alt key (Alt_R) act as Mod4. This will allow you to perform otherwise awkward keystrokes one-handed, such as zooming with Alt_R+Enter.

First, find out which keycode is assigned to Alt_R:

xmodmap -pke | grep Alt_R

Then simply add the following to the startup script (e.g. ~/.xinitrc), changing the keycode 113 if necessary to the result gathered by the previous xmodmap command:

xmodmap -e "keycode 113 = Super_L"  # reassign Alt_R to Super_L
xmodmap -e "remove mod1 = Super_L"  # make sure X keeps it out of the mod1 group

After doing so, any functions that are triggered by the Super_L key press will also be triggered by an Alt_R key press.

Note: There is a #define option in config.h which also allows you to switch the modkey

Space around font in dwm's bar

By default, dwm's bar adds 2px around the size of the font. To change this, modify the following line in dwm.c:

bh = dc.h = dc.font.height + 2;

Disable focus follows mouse behaviour

To disable focus follows mouse behaviour comment out the following line in definiton of struct handler in dwm.c

[EnterNotify] = enternotify,

Note that this change can cause some difficulties; the first click on an inactive window will only bring the focus to it. To interact with window contents (buttons, fields etc) you need to click again. Also, if you have several monitors, you may notice that the keyboard focus does not switch to another monitor activated by clicking.

Make some windows start floating

For some windows, such as preferences dialogs, it does not make sense for these windows to be tiled - they should be free-floating instead. For example, to make Firefox's preferences dialog float, add the following to your rules array in config.h:

 { "Firefox",     NULL,       "Firefox Preferences",        1 << 8,         True,     -1 },

Troubleshooting

Fixing misbehaving Java applications

As of JRE 6u20, Java applications may misbehave in dwm because dwm is not a known window manager for Java. The misbehavior may include menus closing when the mouse is released and other minor issues. Firstly, install the wmname package.

Now use wmname to set a WM name that Java recognizes:

$ wmname LG3D
Note: This may cause some programs to behave oddly when tiled (specifically Chromium).

This setting is not persistent so you may want to add this command to your .xinitrc or .xprofile.

Alternatively, it is also possible to change enable export _JAVA_AWT_WM_NONREPARENTING=1 in /etc/profile.d/jre.sh

Fixing the extra topbar that does not disappear when changing resolution/monitors

Note: this patch is intended for dwm-6.0 which is currently in the official repositories. The development version of dwm has already implemented this.

When resizing or connecting/disconnecting different monitors there may be a remnant of the topbar stuck on the screen which cannot be removed. To fix this bug, rebuild dwm with this patch.

Fixing gaps around terminal windows

If there are empty gaps of desktop space outside terminal windows, it is likely due to the terminal's font size. Either adjust the size until finding the ideal scale that closes the gap, or toggle resizehints to False in config.h:

static Bool resizehints = False; /* True means respect size hints in tiled resizals */

This will cause dwm to ignore resize requests from all client windows, not just terminals. The downside to this workaround is that some terminals may suffer redraw anomalies, such as ghost lines and premature line wraps, among others.

See also