Difference between revisions of "Dwm"

From ArchWiki
Jump to: navigation, search
m (A happy medium)
m
Line 2: Line 2:
 
[[Category:Desktop environments (English)]]
 
[[Category:Desktop environments (English)]]
 
[[Category:HOWTOs (English)]]
 
[[Category:HOWTOs (English)]]
==Introduction==
+
[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 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]]
[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 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.
+
  
 
==Installation==
 
==Installation==
=== Method 1: Repositories ===
+
 
 +
===Method 1: Repositories===
 +
 
 
dwm is available from the standard repositories.  If you're just taking dwm for a test spin, this is the easiest way to do so:
 
dwm is available from the standard repositories.  If you're just taking dwm for a test spin, this is the easiest way to do so:
 
  # pacman -S dwm
 
  # pacman -S dwm
  
=== Method 2: ABS Installation (recommended) ===
+
===Method 2: ABS Installation (recommended)===
 +
 
 
This method will install dwm using the Arch Build System ([[ABS]]). This will allow you to reconfigure it at a later time with minimal fuss.
 
This method will install dwm using the Arch Build System ([[ABS]]). This will allow you to reconfigure it at a later time with minimal fuss.
  
==== Requirements ====
+
====Requirements====
 +
 
 
You'll need some basic programming tools in order to compile dwm and build a package for it. You'll also need the ABS package to fetch the necessary build scripts:
 
You'll need some basic programming tools in order to compile dwm and build a package for it. You'll also need the ABS package to fetch the necessary build scripts:
 
  # pacman -S base-devel abs
 
  # pacman -S base-devel abs
  
==== Download build scripts with ABS ====
+
====Download build scripts with ABS====
 
Once the required packages are installed, use ABS to fetch the latest build scripts from the repositories:
 
Once the required packages are installed, use ABS to fetch the latest build scripts from the repositories:
 
  # abs
 
  # abs
Line 24: Line 27:
 
  $ cp -r /var/abs/community/dwm ~/dwm
 
  $ cp -r /var/abs/community/dwm ~/dwm
  
==== Build and install package ====
+
====Build and install package====
To compile and install dwm:
+
 
# Open a terminal and <tt>cd</tt> to the directory containing the build scripts (the example above used <tt>~/dwm</tt>). Then run:
+
Open a terminal and {{Codeline|cd}} to the directory containing the build scripts (the example above used {{Filename|~/dwm}}). Then run:
 
  $ makepkg -i
 
  $ 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.  
 
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.  
  
'''Note:''' If you save this directory (~/dwm) you can use it again to make changes to the default configuration as described below.
+
{{Note|If you save this directory (~/dwm) you can use it again to make changes to the default configuration as described below.}}
  
 
==Configuration==
 
==Configuration==
dwm is configured at compile-time via its source (config.h and config.mk) and must be recompiled whenever making changes. The initial configuration provides a good set of defaults, but at some point you'll probably want to make changes. For patches, customisations, etc., please visit the [http://www.suckless.org/wiki/dwm dwm] website.
+
dwm is configured at compile-time via its source ({{Filename|config.h}} and {{Filename|config.mk}}) and must be recompiled whenever making changes. The initial configuration provides a good set of defaults, but at some point you'll probably want to make changes. For patches, customisations, etc., please visit the [http://www.suckless.org/wiki/dwm dwm] website.
  
 
=== Method: ABS Rebuild (recommended) ===
 
=== Method: ABS Rebuild (recommended) ===
Line 40: Line 43:
  
 
==== Customizing config.h ====
 
==== Customizing config.h ====
Browse to the dwm source code directory you saved during the installation process (<tt>~/dwm</tt> in the example). The <tt>config.h</tt> found within this directory is where the general dwm preferences are stored.  Some settings within the file should be self-explanatory, while others may not be. For detailed information on these settings, see the [http://www.suckless.org/dwm/ dwm website].
+
Browse to the dwm source code directory you saved during the installation process (~/dwm in the example). The config.h found within this directory is where the general dwm preferences are stored.  Some settings within the file should be self-explanatory, while others may not be. For detailed information on these settings, see the [http://www.suckless.org/dwm/ dwm website].
  
 
''Be sure to make a backup copy of config.h before modifying it, just in case something goes wrong.''
 
''Be sure to make a backup copy of config.h before modifying it, just in case something goes wrong.''
  
Once your changes have been made, edit the PKGBUILD file in the same directory and delete the contents of the '''md5sums''' array so that it looks like this:
+
Once your changes have been made, pipe the new md5sums into the PKGBUILD:
  md5sums=()
+
  $ makepkg -g >> PKGBUILD
 
This will eliminate a checksum mismatch between the official config.h and your revised copy.
 
This will eliminate a checksum mismatch between the official config.h and your revised copy.
 +
{{Tip:You can also erase the md5sum array and build dwm with the --skipinteg option (eg. makepkg -efi --skipinteg).}}
  
 
Now to compile and reinstall:
 
Now to compile and reinstall:
Line 53: Line 57:
 
Assuming your changes were valid, this command will compile dwm, build and reinstall the resulting package (see '''makepkg -h''' for details).  As before, if problems ''were'' encountered, review the output for specific information.  
 
Assuming your changes were valid, this command will compile dwm, build and reinstall the resulting package (see '''makepkg -h''' for details).  As before, if problems ''were'' encountered, review the output for specific information.  
  
'''Note:''' You must restart dwm in order to see any changes.
+
Restart dwm in order to apply the changes.
  
''Tip: To restart dwm without logging out or closing applications, see the section: [[#Starting dwm | Starting dwm]].''
+
{{Tip|To restart dwm without logging out or closing applications, see the section: [[#Starting dwm | Starting dwm]]}}
  
 
=== Method: Mercurial (advanced) ===
 
=== Method: Mercurial (advanced) ===
 +
 
dwm is maintained upstream within a [http://www.selenic.com/mercurial/wiki/ Mercurial] version control system.  If you are already familiar with mercurial, then maintaining your configurations and patches within this system may be more convenient.  A [http://www.suckless.org/dwm/customisation/patch_queue.html detailed tutorial] on this method is available at the dwm website.
 
dwm is maintained upstream within a [http://www.selenic.com/mercurial/wiki/ Mercurial] version control system.  If you are already familiar with mercurial, then maintaining your configurations and patches within this system may be more convenient.  A [http://www.suckless.org/dwm/customisation/patch_queue.html detailed tutorial] on this method is available at the dwm website.
  
Line 70: Line 75:
  
 
==  Patches & Additional tiling modes ==
 
==  Patches & Additional tiling modes ==
 +
 
The [http://www.suckless.org/dwm/patches patches] page in the official website is full of patches that can add extra functionality to dwm. Users can easily customize dwm applying the patches they like. The [http://www.suckless.org/dwm/patches/bottom_stack.html Bottom Stack] patch provides an additional  tiling mode that splits the screen horizontally (opposed to the default tiling mode).
 
The [http://www.suckless.org/dwm/patches patches] page in the official website is full of patches that can add extra functionality to dwm. Users can easily customize dwm applying the patches they like. The [http://www.suckless.org/dwm/patches/bottom_stack.html Bottom Stack] patch provides an additional  tiling mode that splits the screen horizontally (opposed to the default tiling mode).
  
 
==Starting dwm==
 
==Starting dwm==
To start dwm via <tt>startx</tt> or the [[SLIM]] login manager, simply append the following to ~/.xinitrc:  
+
 
 +
To start dwm via {{Codeline|startx}} or the [[SLIM]] login manager, simply append the following to {{Filename|~/.xinitrc}}:  
 
  exec dwm
 
  exec dwm
  
 
===Starting dwm with GDM===
 
===Starting dwm with GDM===
For [[GDM]], append the following to ~/.Xclients and select "Run XClient Script" from the Sessions menu:
+
 
 +
For [[GDM]], append the following to {{Filename|~/.Xclients}} and select "Run XClient Script" from the Sessions menu:
 
  exec dwm
 
  exec dwm
  
 
==Statusbar configuration==
 
==Statusbar configuration==
Piping stdin from another command into dwm will output the results of that command in the status bar.
+
 
 +
Piping <tt>stdin</tt> from another command into dwm will output the results of that command in the status bar.
  
 
=== Basic statusbar ===
 
=== Basic statusbar ===
dwm uses <tt>xsetroot -name</tt> to display information in its statusbar.
 
  
This example prints the date in [http://en.wikipedia.org/wiki/ISO_8601 ISO 8601] format. Add this to your <tt>~/.xinitrc</tt> or <tt>~/.Xclients</tt> file.
+
dwm uses {{Codeline|xsetroot -name}} to display information in its statusbar.
 +
 
 +
This example prints the date in [http://en.wikipedia.org/wiki/ISO_8601 ISO 8601] format. Add this to your ~/.xinitrc or ~/.Xclients file:
  
 
  while true
 
  while true
Line 95: Line 105:
 
  exec dwm
 
  exec dwm
  
Here is another example for a laptop (make sure you have the <tt>acpi</tt> package installed):
+
Here is another example for a laptop (make sure you have the {{Package Official|acpi}} package installed):
 
  while true  
 
  while true  
 
  do
 
  do
Line 117: Line 127:
  
 
=== Conky statusbar ===
 
=== Conky statusbar ===
[http://aur.archlinux.org/packages.php?ID=11884 conky-cli], available from the [[AUR]] is a special build of conky which prints to stdout.  If you're already familiar with conky, a statusbar rich with information can be ready within minutes. Once you have configured conky to your liking, simply print it to the statusbar via the <tt>xsetroot -name</tt> argument:
+
 
 +
[http://aur.archlinux.org/packages.php?ID=11884 conky-cli], available from the [[AUR]] is a special build of conky which prints to <tt>stdout</tt>.  If you're already familiar with conky, a statusbar rich with information can be ready within minutes. Once you have configured conky to your liking, simply print it to the statusbar via the {{Codeline|xsetroot -name}} argument:
  
 
  conky | while true; read line; do xsetroot -name "$line"; done &
 
  conky | while true; read line; do xsetroot -name "$line"; done &
Line 135: Line 146:
  
 
== Tips & Tricks ==
 
== Tips & Tricks ==
 +
 
=== Fixing gaps around terminal windows ===
 
=== Fixing gaps around terminal windows ===
If you find that there are empty gaps of desktop space outside your terminal windows, it is likely due to your terminal font size. You can either tweak the size until you find a sweet spot that closes the gap, or you can toggle <tt>resizehints</tt> to ''False'' in your config.h file:
+
 
 +
If you find that there are empty gaps of desktop space outside your terminal windows, it is likely due to your terminal font size. You can either tweak the size until you find a sweet spot that closes the gap, or you can toggle {{Codeline|resizehints}} to ''False'' in your config.h file:
 
  static Bool resizehints = False; /* False means respect size hints in tiled resizals */
 
  static Bool resizehints = False; /* False means respect size hints in tiled resizals */
 
This will cause dwm to ignore resize requests from client windows--this will affect all windows, not just terminals.  The downside to this workaround is that some terminals may suffer redraw anomalies (ghost lines, premature line wraps, etc.).
 
This will cause dwm to ignore resize requests from client windows--this will affect all windows, not just terminals.  The downside to this workaround is that some terminals may suffer redraw anomalies (ghost lines, premature line wraps, etc.).
  
 
=== Restart dwm without logging out or closing programs ===
 
=== Restart dwm without logging out or closing programs ===
 +
 
If you would like to restart dwm without logging out or closing applications, change your startup script to load dwm in a '''while''' loop, like this:
 
If you would like to restart dwm without logging out or closing applications, change your startup script to load dwm in a '''while''' loop, like this:
  
Line 152: Line 166:
 
Now, you can restart dwm without destroying other X windows by pressing the usual '''Mod-Shift-Q'''.
 
Now, you can restart dwm without destroying other X windows by pressing the usual '''Mod-Shift-Q'''.
  
It's a good idea to place the above startup script into a separate file, such as <tt>~/bin/startdwm</tt> and execute it via <tt>xinitrc</tt>.  Then when you want to actually end your session you can simply execute '''<tt>killall startdwm</tt>''' (better yet, bind it to a key).
+
It's a good idea to place the above startup script into a separate file, such as {{Filename|~/bin/startdwm}} and execute it via ~/.xinitrc.  Then when you want to actually end your session you can simply execute {{Codeline|killall startdwm}} (better yet, bind it to a key).
  
 
=== Make Alt_R key work as if it were Mod4 (Windows Key) ===
 
=== Make Alt_R key work as if it were Mod4 (Windows Key) ===
If you use Mod4 (aka Super aka Windows Key) as your MODKEY, you might find it equally convenient to have your Right Alt key act as Mod4. This will allow you to perform otherwise awkward keystrokes one-handed, such as zooming with Alt_R+Enter.  
+
If you use Mod4 (aka Super/Windows Key) as your MODKEY, you might find it equally convenient to have your Right Alt key 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:
 
First, find out which keycode is assigned to Alt_R:
Line 166: Line 180:
  
 
==More Resources==
 
==More Resources==
* [http://www.suckless.org/dwm dwm] -- the official website of dwm
+
* [http://www.suckless.org/dwm dwm]
* [[dmenu]] -- a simple application launcher from the developers of dwm
+
:dwm's official website
* [http://www.flickr.com/photos/cinderwick/sets/72157604733895131/ dwm wallpapers] -- some simple dwm wallpapers
+
* [[dmenu]]
 +
:simple application launcher from the developers of dwm
 +
* [http://www.flickr.com/photos/cinderwick/sets/72157604733895131/ dwm wallpapers]
 +
:simple dwm wallpapers
  
'''Tutorials and other articles'''
+
===Tutorials and other articles===
 
* [http://www.xsnake.net/howto/dwm/dwm-eng.php HowTo by Snake]
 
* [http://www.xsnake.net/howto/dwm/dwm-eng.php HowTo by Snake]
 
* [http://0x80.org/blog/?p=72 Moved to dwm]
 
* [http://0x80.org/blog/?p=72 Moved to dwm]
 
* [http://milesgroman.com/articles/configuring-dwm configuring dwm]
 
* [http://milesgroman.com/articles/configuring-dwm configuring dwm]

Revision as of 01:25, 28 October 2009

dwm is a dynamic window manager for X. It manages windows in tiled, stacked, and full-screen layouts (as well as many others with 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

Installation

Method 1: Repositories

dwm is available from the standard repositories. If you're just taking dwm for a test spin, this is the easiest way to do so:

# pacman -S dwm

Method 2: ABS Installation (recommended)

This method will install dwm using the Arch Build System (ABS). This will allow you to reconfigure it at a later time with minimal fuss.

Requirements

You'll need some basic programming tools in order to compile dwm and build a package for it. You'll also need the ABS package to fetch the necessary build scripts:

# pacman -S base-devel abs

Download build scripts with ABS

Once the required packages are installed, use ABS to fetch the latest build scripts from the repositories:

# abs

Lastly, copy the dwm build scripts from the ABS tree to a temporary directory. For example:

$ mkdir ~/dwm
$ cp -r /var/abs/community/dwm ~/dwm

Build and install package

Open a terminal and Template:Codeline to the directory containing the build scripts (the example above used Template:Filename). Then run:

$ 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.

Note: If you save this directory (~/dwm) you can use it again to make changes to the default configuration as described below.

Configuration

dwm is configured at compile-time via its source (Template:Filename and Template:Filename) and must be recompiled whenever making changes. The initial configuration provides a good set of defaults, but at some point you'll probably want to make changes. For patches, customisations, etc., please visit the dwm website.

Method: ABS Rebuild (recommended)

If you followed method 2 of the installation phase, then modifying dwm is quite simple.

Customizing config.h

Browse to the dwm source code directory you saved during the installation process (~/dwm in the example). The config.h found within this directory is where the general dwm preferences are stored. Some settings within the file should be self-explanatory, while others may not be. For detailed information on these settings, see the dwm website.

Be sure to make a backup copy of config.h before modifying it, just in case something goes wrong.

Once your changes have been made, pipe the new md5sums into the PKGBUILD:

$ makepkg -g >> PKGBUILD

This will eliminate a checksum mismatch between the official config.h and your revised copy. Template:Tip:You can also erase the md5sum array and build dwm with the --skipinteg option (eg. makepkg -efi --skipinteg).

Now to compile and reinstall:

$ makepkg -efi

Assuming your changes were valid, this command will compile dwm, build and reinstall the resulting package (see makepkg -h for details). As before, if problems were encountered, review the output for specific information.

Restart dwm in order to apply the changes.

Tip: To restart dwm without logging out or closing applications, see the section: Starting dwm

Method: Mercurial (advanced)

dwm is maintained upstream within a Mercurial version control system. If you are already familiar with mercurial, then maintaining your configurations and patches within this system may be more convenient. A detailed tutorial on this method is available at the dwm website.

If you would like to build dwm from the Mercurial sources, be sure to change config.mk accordingly. Failure to do so may result in X crashes. Change the following values:

Change PREFIX to:

PREFIX = /usr

Change the X11 include folder to:

X11INC = /usr/include/X11

Change the X11 lib to:

X11LIB = /usr/lib/X11

Patches & Additional tiling modes

The patches page in the official website is full of patches that can add extra functionality to dwm. Users can easily customize dwm applying the patches they like. The Bottom Stack patch provides an additional tiling mode that splits the screen horizontally (opposed to the default tiling mode).

Starting dwm

To start dwm via Template:Codeline or the SLIM login manager, simply append the following to Template:Filename:

exec dwm

Starting dwm with GDM

For GDM, append the following to Template:Filename and select "Run XClient Script" from the Sessions menu:

exec dwm

Statusbar configuration

Piping stdin from another command into dwm will output the results of that command in the status bar.

Basic statusbar

dwm uses Template:Codeline to display information in its statusbar.

This example prints the date in ISO 8601 format. Add this to your ~/.xinitrc or ~/.Xclients file:

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

Here is another example for a laptop (make sure you have the Template:Package Official package installed):

while true 
do
    xsetroot -name "$(acpi | awk '{ print $3, $4 }' | sed s/","//g)"
done &
exec dwm

This displays the amount of battery remaining and its status (charging/discharging). The awk command trims away the unneeded text from acpi, and sed removes the commas.

Make sure there is only one instance of dwm in ~/.xinitrc or ~/.Xclients. Combining everything together, it should look something like:

~/.setbg
autocutsel&
termirssi&
urxvt&
while true
do
   xsetroot -name "$(date +"%F %R")"
   sleep 1m    # Update time every minute
done &
exec dwm

Conky statusbar

conky-cli, available from the AUR is a special build of conky which prints to stdout. If you're already familiar with conky, a statusbar rich with information can be ready within minutes. Once you have configured conky to your liking, simply print it to the statusbar via the Template:Codeline argument:

conky | while true; read line; do xsetroot -name "$line"; done &
exec dwm

The following is a sample conkyrc for a dual core CPU, displaying several stats:

background no
out_to_console yes
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}

Tips & Tricks

Fixing gaps around terminal windows

If you find that there are empty gaps of desktop space outside your terminal windows, it is likely due to your terminal font size. You can either tweak the size until you find a sweet spot that closes the gap, or you can toggle Template:Codeline to False in your config.h file:

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

This will cause dwm to ignore resize requests from client windows--this will affect all windows, not just terminals. The downside to this workaround is that some terminals may suffer redraw anomalies (ghost lines, premature line wraps, etc.).

Restart dwm without logging out or closing programs

If you would like to restart dwm without logging out or closing applications, change your startup script to load dwm in a while loop, like this:

conky | while read line; do
    xsetroot -name "$line"; 
# log stderror to a file 
done | while true; do dwm 2> ~/.dwm.log; done;
# no error logging
#done | while true; do dwm > /dev/null; done;

Now, you can restart dwm without destroying other X windows by pressing the usual Mod-Shift-Q.

It's a good idea to place the above startup script into a separate file, such as Template:Filename and execute it via ~/.xinitrc. Then when you want to actually end your session you can simply execute Template:Codeline (better yet, bind it to a key).

Make Alt_R key work as if it were Mod4 (Windows Key)

If you use Mod4 (aka Super/Windows Key) as your MODKEY, you might find it equally convenient to have your Right Alt key 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 your startup script (e.g. ~/.xinitrc), changing the keycode 113 if necessary to the above result:

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

Now any functions that are triggered by a Super_L (Windows) key press will also be triggered by an Alt_R key press.

More Resources

dwm's official website
simple application launcher from the developers of dwm
simple dwm wallpapers

Tutorials and other articles