status monitor

The status bar text of dwm is stored in the WM_NAME X11 property of the root window, which is managed by dwm.

It can be easily set and retrieved using standard Unix tools.

xsetroot -name $status

xprop -root -notype -f WM_NAME "8u" \
    | sed -n -r 's/WM_NAME = \"(.*)\"/\1/p'

Set The Status Using A Shell Script

while true;
do
    xsetroot -name "$(date)"
    sleep 2
done

Set The Status Using Other Methods

There are two status monitors maintained at suckless:

slstatus - suckless status

A somewhat complex status monitor which includes all batteries.

You can read more on the project page.

dwmstatus

Barebone status monitor with basic functions written in C. This follows the suckless philosophy, to give you an easy way to extend the source code to your needs. See the helper functions for C below, to extend it to your needs. Just check it out and keep on hacking.

git clone git://git.suckless.org/dwmstatus
cd dwmstatus
make
make PREFIX=/usr install
# add »dwmstatus 2>&1 >/dev/null &« to your .xinitrc

Status Monitors Submitted By Others

Feel free to add your own status monitors here (keeping the list sorted).

Helper Functions In The Shell

Return battery capacity percentage:

$(echo $(awk '/rem/ { print $3/89000 }' /proc/acpi/battery/BAT0/state| hoc| cut -c3,4)%

Your battery may be called something different, so check /proc/acpi for its name. Also, change 89000 to whatever the capacity is for your battery. This returns the remaining battery power as a percentage. hoc comes from plan9port or 9base.

Depending on your system, you can also use

cat /sys/class/power_supply/BAT0/capacity

to get your battery status in percentage.

Return the amount of ram used, in megabytes:

$(free -m |awk '/cache:/ { print $3"M" }')

Return the temperature of the cpu, in degree celcius:

$(awk '{ print $2 }' /proc/acpi/thermal_zone/THM0/temperature)C

Return volume:

amixer get Front | tail -n1 | awk '{ print $5 }' | tr -d []

Change “Front” to your audio device

Using shell scripts very well leads to big scripts, which pull in unneeded dependencies. One solution for this is to write everything in C, which is much more efficient.

Helper Functions In C (for dwmstatus or slstatus etc.)

If you have simple C functions for gathering system information, feel free to add them here (keeping the list sorted).