Dwm: Difference between revisions

From Alpine Linux
mNo edit summary
 
(44 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{TOC right}}
{{DISPLAYTITLE:dwm}}[https://dwm.suckless.org/ dwm] is an extremely fast, small, and dynamic window manager for X. It manages windows in tiled, monocle and floating layouts. This page provides instructions for installing dwm both from binary packages and from source along with dependencies.


[https://dwm.suckless.org/ dwm] is a dynamic window manager for X. It manages windows in tiled, monocle and floating layouts.
== Prerequisites ==


This guide covers:
{{:Include:Desktop prerequisites}}
* [[Alpine_setup_scripts#setup-xorg-base|Install Xorg]]


* Creating  a user account that can run sudo
== Installation ==
* Installing dependencies for the [https://suckless.org suckless] tools and installing firefox
* Installing from source dwm (dynamic window manager), dmenu (dynamic menu), st (simple terminal)
* Configuring the new profile to run dwm at login.


The {{pkg|dbus-x11}} package is needed for the dbus system as it enables Firefox running in dwm to open in a tile.The packages {{pkg|adwaita-icon-theme}} and {{pkg|font-dejavu}} are optional, but recommended for a nicer looking firefox. Install them before proceeding: {{Cmd|# apk add {{pkg|dbus-x11}} {{pkg|adwaita-icon-theme}} {{pkg|font-dejavu}} {{pkg|firefox-esr}}}}


== Creating a new user account ==
=== Installing binary packages  ===
After installing Alpine you get the root account. We want to create an account that is not root, but can run sudo.
{{cmd|# adduser myname}}
Where '''myname''' is the user name you want to use.


Install sudo so we can add '''myname''' to sudoers.
Alpine Linux provides  binary packages for {{Pkg|dwm}} (dynamic window manager), {{Pkg|dmenu}} (dynamic menu) and {{Pkg|st}} (simple terminal). This allows new users to experience dwm quickly without compiling the source code. To install the binary packages, issue the command:{{Cmd|# apk add dwm dmenu st}}
{{cmd|# apk add sudo}}


Edit the sudoers file by running:
Proceed to [[#Starting dwm|Starting dwm]] section to start using dwm with default settings. If you are new to dwm, refer to the [https://dwm.suckless.org/tutorial/ official dwm tutorial].
{{cmd|# visudo}}
{{Note|Edit the sudoers file using only '''visudo'''}}
Add the newly create account to sudoers. Insert the line '''after''' the root definition. The relevant section should look like this:
{{cat|/etc/sudoers.tmp|
<pre>
##
## User privilege specification
##
root ALL=(ALL) ALL
myname ALL=(ALL) ALL</pre>}}


Switch to the new account
To customize dwm, refer [[#Installing from source|Installing from source]].  
{{cmd|# su myname}} Where '''myname''' is your username.


== Installing Xorg ==
=== Installing from source  ===
Run the following command to install X.org:
{{cmd|# doas setup-xorg-base}}


== Configure the community repositories ==
To customize dwm, the source code written in '''c''' language must be edited, compiled and installed everytime for the changes to take effect, which usuaully takes less than a minute.  
This is needed so you can install Firefox. Edit the file with this command:
{{cmd|# sudo vi /etc/apk/repositories}}
Uncomment the community line by removing the '''#''' then save the file and exit.
It should look something like this:
{{cat|/etc/apk/repositories|
#/media/cdrom/apks
http://linorg.usp.br/AlpineLinux/v3.9/main
http://linorg.usp.br/AlpineLinux/v3.9/community
#http://linorg.usp.br/AlpineLinux/edge/main
#http://linorg.usp.br/AlpineLinux/edge/community
#http://linorg.usp.br/AlpineLinux/edge/testing}}
Next, tell the package manager about the change:
{{cmd|# sudo apk update}}


== Installing dependencies ==
If you have installed the [[#Installing binary packages|binary packages]], remove them first before proceeding:{{Codeline| # apk del dwm dmenu st}}
{{Note|
'''git make gcc g++ libx11-dev libxft-dev libxinerama-dev ncurses''' is needed to install suckless tools from source.


'''dbus-x11''' is needed for the dbus system (enables firefox running in dwm to open in a tile)
Install the necessary packages to compile dwm: {{cmd|# apk add {{pkg|git}} {{pkg|make}} {{pkg|gcc}} {{pkg|g++}} {{pkg|libx11-dev}} {{pkg|libxft-dev}} {{pkg|libxinerama-dev}} {{pkg|ncurses}} }}


The last three '''adwaita-gtk2-theme adwaita-icon-theme ttf-dejavu''' are optional, but recommended for a nicer looking firefox.}}
The following instructions downloads the sources for {{ic|dwm}}, {{ic|dmenu}} and {{ic|st}} in {{Path|/usr/src/suckless}}, compiles the source(make) and installs the binaries in {{Path|/usr/local/bin}}. If you do not want to keep the sources, use {{Path|/tmp}} for downloading the sources.


The command to install the dependencies:
# Create a directory {{Path|/usr/src/suckless}} using the command: {{Cmd|# mkdir -p /usr/src/suckless}}
{{cmd|# sudo apk add git make gcc g++ libx11-dev libxft-dev libxinerama-dev ncurses dbus-x11 firefox-esr adwaita-gtk2-theme adwaita-icon-theme ttf-dejavu}}
# Change to the {{Path|/usr/src/suckless directory}}:{{cmd|$ cd /usr/src/suckless}}
# Download the {{ic|dwm}} sources: {{cmd|# git clone https://git.suckless.org/dwm}}
# Once downloaded, go to the dwm directory:{{cmd|# cd dwm }}
# To install dwm, issue the command: {{cmd|# make clean install}}
# Next, go up one directory level {{cmd|# cd ..}}
# Download and install {{ic|dmenu}} launcher: {{cmd|<nowiki># git clone https://git.suckless.org/dmenu
# cd dmenu
# make clean install</nowiki>}}
# Finally, go up one more directory level: {{cmd|# cd ..}}
# Download and install {{ic|st}} terminal: {{cmd|<nowiki># git clone https://git.suckless.org/st
# cd st
# make clean install</nowiki>}}


== Installing suckless tools dwm, dmenu, and st from source ==
== Configuration ==
Change to the /tmp directory. {{cmd| # cd /tmp}} then execute:
 
{{cmd|# git clone https://git.suckless.org/dwm}}
The configuration of dwm and other suckless tools are done by editing the {{Path|config.h}} file. If not already done, complete [[#Installing from source|Installing from source]] before proceeding.
Once downloaded, go to the dwm directory {{cmd|# cd dwm}}
 
To install, run:
The {{ic|make}} command will create {{Path|config.h}} file from {{Path|config.def.h}}. If the file {{Path|config.h}} already exists, {{ic|make}} won't overwrite it and instead use it. Based on above instructions, for customizing dwm, edit the file {{Path|/usr/src/suckless/dwm/config.h}}.
{{cmd|# sudo make clean install}}
 
Next, go up one directory level {{cmd|# cd ..}} to install dmenu:
All changes related to keybindings, colors, fonts, patches, etc. are to be made to the {{Path|config.h}} file and (re)compile the source code by issuing the command {{Codeline|# make clean install}}.
{{cmd|# git clone https://git.suckless.org/dmenu}}
 
{{cmd|# cd dmenu}}
=== Starting dwm ===  
{{cmd|# sudo make clean install}}
 
Finally, go up one more directory level {{cmd|# cd ..}} to install st:
Create or edit {{Path|~/.xinitrc}} with at least the following: {{cat|~/.xinitrc|#!/bin/sh
{{cmd|# git clone https://git.suckless.org/st}}
# Start D-Bus session
{{cmd|# cd st}}
if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
{{cmd|# sudo make clean install}}
    eval $(dbus-launch --sh-syntax --exit-with-session)
== Setting up your profile ==
fi
Change to your home directory:
{{cmd|# cd /home/myname}} Where '''myname''' is your username.
Create .xinitrc:
{{cmd|# vi .xinitrc}}
Add this line:
{{cat|~/.xinitrc|
exec dwm}}
exec dwm}}
Save the file and exit vi.
Next, create .profile.:
{{cmd|# vi .profile}}
Add this line:
{{cat|~/.profile|
startx}}


{{Note|If you install additional programs that call your `$SHELL` with the POSIX `-l` login flag, you'll need to make launching `startx` conditional, otherwise X will attempt to launch every time your shell is called with the login flag.
To prevent X from attempting to launch {{ic|dwm}} every time your shell is called with the login flag, make launching `startx` conditional by creating or editing {{Path|.profile}} as follows:{{cat|~/.profile|if [ -z $DISPLAY ] && [ $(tty) {{=}} /dev/tty1 ]; then
{{cat|~/.profile|
if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then
     startx
     startx
fi
fi
}}
}}
|gotchas}}


Log out or reboot. dwm will run the next time you log in.  
Log out or reboot. dwm will run the next time you log in.  
Press alt+p to launch dmenu. Type firefox then press enter. Firefox will load and run in tile 9.


= =
Press {{Key|Alt}}+{{Key|p}} to launch {{ic|dmenu}}. Type firefox then press {{key|enter}}. Firefox will load and run in tile 9.
* https://pkgs.alpinelinux.org/contents?file=dwm
 
* [https://wiki.gentoo.org/wiki/Dwm "dwm is only a single binary, and its source code is intended to never exceed 2000 SLOC. dwm is customized through editing its source code"]
== Troubleshooting ==
* [[Awesome]]
 
=== unable to connect to X server: Connection refused ===
 
If you receive above error message on hitting "startx" with {{Path|Xorg.0.log}} showing errors like {{Cmd|
Xorg.(EE) Failed to load module "driver_name"
Fatal server error:
no screens found}}
The issue might be due to the user not in the '''video''' group. [[Setting_up_a_new_user#Group_management|Adding '''video''' group]] for the user will solve the issue.
 
== See also ==
 
* [https://dwm.suckless.org/tutorial/ official dwm tutorial]
* [https://git.sr.ht/~bt/alpine-suck-installer Alpine Suck] Desktop installer for Alpine Linux based on the suckless philosophy
* [https://wiki.gentoo.org/wiki/Dwm Gentoo wiki page on dwm]
* [https://wiki.archlinux.org/title/Dwm Archwiki page on dwm]
* [[Raspberry Pi 3 - Browser Client]] - A guide which omits dwm, but uses similar steps to install firefox in a diskless install on ARM. dwm is not used on the RPI3, due to tmpfs limitations.
* [[Raspberry Pi 3 - Browser Client]] - A guide which omits dwm, but uses similar steps to install firefox in a diskless install on ARM. dwm is not used on the RPI3, due to tmpfs limitations.


[[category:Desktop]]
[[Category:Window Managers]]

Latest revision as of 01:57, 23 August 2025

dwm is an extremely fast, small, and dynamic window manager for X. It manages windows in tiled, monocle and floating layouts. This page provides instructions for installing dwm both from binary packages and from source along with dependencies.

Prerequisites

Installation

The dbus-x11 package is needed for the dbus system as it enables Firefox running in dwm to open in a tile.The packages adwaita-icon-theme and font-dejavu are optional, but recommended for a nicer looking firefox. Install them before proceeding:

# apk add dbus-x11 adwaita-icon-theme font-dejavu firefox-esr

Installing binary packages

Alpine Linux provides binary packages for dwm (dynamic window manager), dmenu (dynamic menu) and st (simple terminal). This allows new users to experience dwm quickly without compiling the source code. To install the binary packages, issue the command:

# apk add dwm dmenu st

Proceed to Starting dwm section to start using dwm with default settings. If you are new to dwm, refer to the official dwm tutorial.

To customize dwm, refer Installing from source.

Installing from source

To customize dwm, the source code written in c language must be edited, compiled and installed everytime for the changes to take effect, which usuaully takes less than a minute.

If you have installed the binary packages, remove them first before proceeding: # apk del dwm dmenu st

Install the necessary packages to compile dwm:

# apk add git make gcc g++ libx11-dev libxft-dev libxinerama-dev ncurses

The following instructions downloads the sources for dwm, dmenu and st in /usr/src/suckless, compiles the source(make) and installs the binaries in /usr/local/bin. If you do not want to keep the sources, use /tmp for downloading the sources.

  1. Create a directory /usr/src/suckless using the command:

    # mkdir -p /usr/src/suckless

  2. Change to the /usr/src/suckless directory:

    $ cd /usr/src/suckless

  3. Download the dwm sources:

    # git clone https://git.suckless.org/dwm

  4. Once downloaded, go to the dwm directory:

    # cd dwm

  5. To install dwm, issue the command:

    # make clean install

  6. Next, go up one directory level

    # cd ..

  7. Download and install dmenu launcher:

    # git clone https://git.suckless.org/dmenu # cd dmenu # make clean install

  8. Finally, go up one more directory level:

    # cd ..

  9. Download and install st terminal:

    # git clone https://git.suckless.org/st # cd st # make clean install

Configuration

The configuration of dwm and other suckless tools are done by editing the config.h file. If not already done, complete Installing from source before proceeding.

The make command will create config.h file from config.def.h. If the file config.h already exists, make won't overwrite it and instead use it. Based on above instructions, for customizing dwm, edit the file /usr/src/suckless/dwm/config.h.

All changes related to keybindings, colors, fonts, patches, etc. are to be made to the config.h file and (re)compile the source code by issuing the command # make clean install.

Starting dwm

Create or edit ~/.xinitrc with at least the following:

Contents of ~/.xinitrc

#!/bin/sh # Start D-Bus session if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then eval $(dbus-launch --sh-syntax --exit-with-session) fi exec dwm

To prevent X from attempting to launch dwm every time your shell is called with the login flag, make launching `startx` conditional by creating or editing .profile as follows:

Contents of ~/.profile

if [ -z $DISPLAY ] && [ $(tty) = /dev/tty1 ]; then startx fi

Log out or reboot. dwm will run the next time you log in.

Press Alt+p to launch dmenu. Type firefox then press enter. Firefox will load and run in tile 9.

Troubleshooting

unable to connect to X server: Connection refused

If you receive above error message on hitting "startx" with Xorg.0.log showing errors like

Xorg.(EE) Failed to load module "driver_name" Fatal server error: no screens found

The issue might be due to the user not in the video group. Adding video group for the user will solve the issue.

See also