Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Desktop Environments
  • Search

DWM Hacking Thread

Problems with GUI applications? Questions about X, KDE, Gnome, Fluxbox, etc.? Come on in. NOTE: For multimedia, go up one forum
Post Reply
Advanced search
14 posts • Page 1 of 1
Author
Message
F_
Tux's lil' helper
Tux's lil' helper
Posts: 142
Joined: Sun Dec 31, 2006 5:52 pm

DWM Hacking Thread

  • Quote

Post by F_ » Fri May 16, 2008 9:16 am

Anyone here use the window manager dwm? Here is a screenshot of my current desktop (boring, I know, forgive me -- its this very fact that is the reason for this thread):
http://img241.imageshack.us/img241/1043/desktopkq3.png

I really love this window manager for several reasons, the major ones being:
1. <2000 SLOC
2. completely hackable
3. very active development
4. very active community


So I want to start a dwm hacking thread so we can have a specific place where we can share ideas, share configs, comment on each other's desktops, recommend scripts, etc. etc...

I'm still using dwm-4.7 (since I don't really have much reason to upgrade to 4.9 yet). Here are some of my (lame) configs/scripts:

Code: Select all

/* See LICENSE file for copyright and license details. */

/* appearance */
#define BARPOS                  BarTop /* BarBot, BarOff */
#define BORDERPX                1
#define FONT                    "-*-terminus-medium-*-*-*-*-*-*-*-*-*-*-*"
#define NORMBORDERCOLOR         "#333"
#define NORMBGCOLOR             "#000"
#define NORMFGCOLOR             "#ccc"
#define SELBORDERCOLOR          "#f00"
#define SELBGCOLOR              "#300"
#define SELFGCOLOR              "#fff"

/* tagging */
const char tags[][MAXTAGLEN] = { "main", "www", "mail", "doc", "img" };
Bool seltags[LENGTH(tags)] = {[0] = True};
Rule rules[] = {
        /* class:instance:title regex   tags regex      isfloating */
        { "Opera",                      "www",          False },
        { "feh",                        "img",          True },
        { "Xpdf",                       NULL,           True },
        { "thunderbird",                "mail",         True },
        { "Gimp",                       NULL,           True },
        { "MPlayer",                    NULL,           True },
        { "Acroread",                   NULL,           True },
};

/* layout(s) */
#define MWFACT                  0.6     /* master width factor [0.1 .. 0.9] */
#define RESIZEHINTS             True    /* False - respect size hints in tiled resizals */
#define SNAP                    32      /* snap pixel */
Layout layouts[] = {
        /* symbol               function */
        { "[]=",                tile }, /* first entry is default */
        { "><>",                floating },
};

/* key definitions */
#define MODKEY                  Mod4Mask
Key keys[] = {
        /* modifier                     key             function        argument */
        { MODKEY,                       XK_p,           spawn,
                "exe=`dmenu_path | dmenu -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"'"
                " -sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"'` && exec $exe" },
        { MODKEY|ShiftMask,             XK_Return,      spawn, "exec urxvt +sb -bg black -fg white -tr -sh 20" },
        { MODKEY,                       XK_o,           spawn,          "opera" },
        { MODKEY,                       XK_w,           spawn,          "exec ~/code/scripts/wpchange.pl" }, 
        { MODKEY,                       XK_t,           spawn,          "thunderbird" },
        { MODKEY,                       XK_space,       setlayout,      NULL },
        { MODKEY,                       XK_b,           togglebar,      NULL },
        { MODKEY,                       XK_j,           focusnext,      NULL },
        { MODKEY,                       XK_k,           focusprev,      NULL },
        { MODKEY,                       XK_h,           setmwfact,      "-0.05" },
        { MODKEY,                       XK_l,           setmwfact,      "+0.05" },
        { MODKEY,                       XK_m,           togglemax,      NULL },
        { MODKEY,                       XK_Return,      zoom,           NULL },
        { MODKEY,                       XK_Tab,         viewprevtag,    NULL },
        { MODKEY|ShiftMask,             XK_space,       togglefloating, NULL },
        { MODKEY|ShiftMask,             XK_c,           killclient,     NULL },
        { MODKEY,                       XK_0,           view,           NULL },
        { MODKEY,                       XK_1,           view,           tags[0] },
        { MODKEY,                       XK_2,           view,           tags[1] },
        { MODKEY,                       XK_3,           view,           tags[2] },
        { MODKEY,                       XK_4,           view,           tags[3] },
        { MODKEY,                       XK_5,           view,           tags[4] },
        { MODKEY,                       XK_6,           view,           tags[5] },
        { MODKEY,                       XK_7,           view,           tags[6] },
        { MODKEY,                       XK_8,           view,           tags[7] },
        { MODKEY,                       XK_9,           view,           tags[8] },
        { MODKEY|ControlMask,           XK_1,           toggleview,     tags[0] },
        { MODKEY|ControlMask,           XK_2,           toggleview,     tags[1] },
        { MODKEY|ControlMask,           XK_3,           toggleview,     tags[2] },
        { MODKEY|ControlMask,           XK_4,           toggleview,     tags[3] },
        { MODKEY|ControlMask,           XK_5,           toggleview,     tags[4] },
        { MODKEY|ControlMask,           XK_6,           toggleview,     tags[5] },
        { MODKEY|ControlMask,           XK_7,           toggleview,     tags[6] },
        { MODKEY|ControlMask,           XK_8,           toggleview,     tags[7] },
        { MODKEY|ControlMask,           XK_9,           toggleview,     tags[8] },
        { MODKEY|ShiftMask,             XK_0,           tag,            NULL },
        { MODKEY|ShiftMask,             XK_1,           tag,            tags[0] },
        { MODKEY|ShiftMask,             XK_2,           tag,            tags[1] },
        { MODKEY|ShiftMask,             XK_3,           tag,            tags[2] },
        { MODKEY|ShiftMask,             XK_4,           tag,            tags[3] },
        { MODKEY|ShiftMask,             XK_5,           tag,            tags[4] },
        { MODKEY|ShiftMask,             XK_6,           tag,            tags[5] },
        { MODKEY|ShiftMask,             XK_7,           tag,            tags[6] },
        { MODKEY|ShiftMask,             XK_8,           tag,            tags[7] },
        { MODKEY|ShiftMask,             XK_9,           tag,            tags[8] },
        { MODKEY|ControlMask|ShiftMask, XK_1,           toggletag,      tags[0] },
        { MODKEY|ControlMask|ShiftMask, XK_2,           toggletag,      tags[1] },
        { MODKEY|ControlMask|ShiftMask, XK_3,           toggletag,      tags[2] },
        { MODKEY|ControlMask|ShiftMask, XK_4,           toggletag,      tags[3] },
        { MODKEY|ControlMask|ShiftMask, XK_5,           toggletag,      tags[4] },
        { MODKEY|ControlMask|ShiftMask, XK_6,           toggletag,      tags[5] },
        { MODKEY|ControlMask|ShiftMask, XK_7,           toggletag,      tags[6] },
        { MODKEY|ControlMask|ShiftMask, XK_8,           toggletag,      tags[7] },
        { MODKEY|ControlMask|ShiftMask, XK_9,           toggletag,      tags[8] },
        { MODKEY|ShiftMask,             XK_q,           quit,           NULL },
};

Here is a small perl script I wrote to change wallpapers (keybound to Modkey + w):

Code: Select all

#!/usr/bin/perl -w
#randomly change my wallpaper.

use warnings;
use strict;

opendir(DIR, "/home/f/misc/wallpaper") || die "can't opendir ~/misc/wallpapers: $!";
my @files = grep { $_ ne '.' and $_ ne '..' } readdir(DIR);
closedir DIR;

# perldoc -q "random element"
my $chosenwp = $files[rand @files];

#print "chosen wallpaper is: $chosenwp\n";
system("feh --bg-scale /home/f/misc/wallpaper/\"$chosenwp\"");
Of course you should edit the path to your wallpaper dir.

Right now I don't have mpd up and running, but when I did I used to stream music from my server to my laptop (which runs dwm) and I would have the artist and track title display on the top bar, along with some boring info like uptime. Here was the script for it:

Code: Select all

#!/usr/bin/sh

while true
do
echo "[`uptime | sed s/up\ \ /\ uptime:\ /` ] | `mpc --format "mpd: %artist% - %title%" | head -1`"
sleep 1 
done | dwm
I have yet to really get into hacking dzen which looks like a very interesting application that would fit well with dwm.

Anyways, thats all I have for now. I'll add more to this thread as I do more cool things with dwm. Hopefully there are some other dwm users out there who can also contribute.
Top
code933k
n00b
n00b
User avatar
Posts: 52
Joined: Thu Aug 30, 2007 10:29 am
Contact:
Contact code933k
Website

  • Quote

Post by code933k » Mon May 19, 2008 7:14 am

Hi there.

I was getting in your path some time ago (though I was trying managers just because had to stop using Ion)
Tried WMII (not too pleasant) and DWM then. When I thought it was OK, Xmonad appeared in my way and
all was pure romance for me. Recently I stopped using it and re-discovered ratpoison.

Why am I talking so much about "minimalistic" WMs?

Check out your video FPS with various WMs and Desktops then tell me if you want
to use DWM. At least my ATI radeon doesn't love it so much. And I like having more power at hand.

For random use of wallpapers you could try feh if you don't know it.
I have discovered it recently and erased my wallpaper script.

Take care. I really enjoy seeing people who doesn't take desktops too seriously ;)
If gods were created by language then praying is an infinite loop.
Top
F_
Tux's lil' helper
Tux's lil' helper
Posts: 142
Joined: Sun Dec 31, 2006 5:52 pm

  • Quote

Post by F_ » Mon May 19, 2008 2:19 pm

Thanks for replying!
code933k wrote: Check out your video FPS with various WMs and Desktops then tell me if you want
to use DWM. At least my ATI radeon doesn't love it so much. And I like having more power at hand.
How can I check my video FPS?
Also, I use an ATI Radeon XPRESS 1100 IGP.
For random use of wallpapers you could try feh if you don't know it.
I have discovered it recently and erased my wallpaper script.
Ah, really now? I'll have to dive through man feh one more time. If that is the case, you are right, i can get rid of my wallpaper script. :)
Top
code933k
n00b
n00b
User avatar
Posts: 52
Joined: Thu Aug 30, 2007 10:29 am
Contact:
Contact code933k
Website

  • Quote

Post by code933k » Mon May 19, 2008 8:30 pm

Good to know there's an open mind :D

Just issue glxgears from any terminal you like.
You know, it is not a real video card benchmark, but the
numbers are useful for comparing environments.

The last time I checked out with gnome-desktop I had an ugly lose of about 30/60fps
and DWM dropped 10fps compared with Xmonad. Being Xmonad more powerful
in a wider sense, but consuming just a little more memory.

BTW, you can do "whatever you want" with Ratpoison. It is a little bigger but faster
than DWM in my own experience. If you run into problems with (say) Gimp you can
call the command tmpwm and exchange temporarily to evilwm as an example.

Cheers!
If gods were created by language then praying is an infinite loop.
Top
F_
Tux's lil' helper
Tux's lil' helper
Posts: 142
Joined: Sun Dec 31, 2006 5:52 pm

  • Quote

Post by F_ » Fri Jun 13, 2008 7:16 am

Just posting an update in my dwm experience.
I'm still using dwm-4.7 but with the bstack patch that can be found at www.suckless.org

New desktop photo here: http://omploader.org/vam9i/desktop.png

Here is the (ugly) bash script I wrote for the top dzen bar:

Code: Select all

#!/bin/bash

# set some constants
FG='gray70'
BG='#000000'
FONT='-*-terminus-*-r-normal-*-*-120-*-*-*-*-iso8859-*'
ICONPATH=/home/f/code/scripts/dzen/dzen_bitmaps
SLEEP=1


# setting some variables
RXB=`cat /sys/class/net/${INTERFACE}/statistics/rx_bytes`
TXB=`cat /sys/class/net/${INTERFACE}/statistics/tx_bytes`
MAX=`amixer -c0 get PCM | awk '/^  Limits/ { print $5 }'`
CV="amixer -c0 get PCM | awk '/^  Front Left/ { print \$4 \" \" $MAX }'"


# functions
fcpu() {
	   gcpubar -c 2 -i 0.1 -fg '#aecf96' -bg gray40 -w 50 -h 7 | tail -1 | awk '{print $3,$4,$5}' 
}

volume() {
	eval "$CV" | gdbar -h 7 -w 50 -fg '#a8a3f5' -bg '#333'
}


# we set this so cpu and vol have something to compare against the first time around
cpu=$(fcpu)
vol=$(volume)


while :; do

	#CPU info
	cpu=$(fcpu)
		
	#network
	RXBN=`cat /sys/class/net/${INTERFACE}/statistics/rx_bytes`
	TXBN=`cat /sys/class/net/${INTERFACE}/statistics/tx_bytes`

	#calculate the rates
	#format the values to 4 digit fields
	RXR=$(printf "%4d\n" $(echo "($RXBN - $RXB) / 1024/${SLEEP}" | bc))
	TXR=$(printf "%4d\n" $(echo "($TXBN - $TXB) / 1024/${SLEEP}" | bc))

	#volume
	vol=$(volume)	


	#date
	dt=`date +"%a %b %e %l:%M %p "`



	#print out with some nice formatting
	echo "^i(${ICONPATH}/net-wired.xbm)^fg(white)${RXR}kB/s^fg(#80AA83)^p(3)^i(${ICONPATH}/arr_down.xbm)^fg(white)${TXR}kB/s^fg(orange3)^i(${ICONPATH}/arr_up.xbm)^fg() | ^i(${ICONPATH}/cpu.xbm) ${cpu} | ^i(${ICONPATH}/volume.xbm)${vol} | ${dt}"

	#reset old rates
	RXB=$RXBN; TXB=$TXBN

	sleep $SLEEP

# pipe out to dzen
done | dzen2 -e '' -x '750' -w '530' -fg $FG -bg $BG -fn $FONT
Last edited by F_ on Sat Jun 14, 2008 9:08 am, edited 1 time in total.
Top
Codeblues
n00b
n00b
Posts: 26
Joined: Wed May 28, 2008 8:34 pm
Location: Chicago, Illinois

  • Quote

Post by Codeblues » Sat Jun 14, 2008 4:07 am

New linux and gentoo user here. Can someone provide a step to step guide on patching dwm? I have no idea where to start...I installed dwm through portage. Should I have installed it manually in the beginning?
Top
code933k
n00b
n00b
User avatar
Posts: 52
Joined: Thu Aug 30, 2007 10:29 am
Contact:
Contact code933k
Website

  • Quote

Post by code933k » Sat Jun 14, 2008 4:45 am

Why should you patch DWM? Just look into the /etc/portage/savedconfig/x11-wm/dwm-X.X-VERSION file.
There are all the answers you want -I think. You can change colors, define your own "virtual space" names and so forth.
Then you should recompile with the savedconfig use flag for the install to use your changes.

Read the Gentoo docs if you don't know yet how to handle use flags.

What is shown up here is not really "DWM hacking" but scripting for dzen2. When you know a programming language you can
customize your own status bars through it. For plain DWM you don't have to do so. But if you like the bars you see there you can
copy and paste the code.

You can read some BASH (scripting) tutorial searching in www.google.com/linux

Welcome to GNU/Linux ! And overall welcome to Gentoo.
If gods were created by language then praying is an infinite loop.
Top
Codeblues
n00b
n00b
Posts: 26
Joined: Wed May 28, 2008 8:34 pm
Location: Chicago, Illinois

  • Quote

Post by Codeblues » Sat Jun 14, 2008 5:05 am

Thanks! I'll look into that sometime soon. Meanwhile I have a quick question. The top right status bar where it should show date and time shows EOF. The dwm man page describes a bug that's kind of reverse of mine. I started my dwm and X by logging in then startx.
Top
F_
Tux's lil' helper
Tux's lil' helper
Posts: 142
Joined: Sun Dec 31, 2006 5:52 pm

  • Quote

Post by F_ » Sat Jun 14, 2008 9:15 am

Codeblues wrote:New linux and gentoo user here. Can someone provide a step to step guide on patching dwm? I have no idea where to start...I installed dwm through portage. Should I have installed it manually in the beginning?
dwm patches and instructions can be found at the suckless website.
Also: $ man patch

And yes I didn't use portage to install dwm, I find it much simpler to just use portage for everything else except dwm. But thats just me. If you're curious, i just have a /home/f/code/dwm/ directory where I unpack dwm to and make it. The command given in the README (make clean install) installs dwm to /usr/local/bin/dwm (or /usr/bin/dwm depending on what version of dwm you're installing, but regardless you can change this).

Codeblues wrote: Thanks! I'll look into that sometime soon. Meanwhile I have a quick question. The top right status bar where it should show date and time shows EOF. The dwm man page describes a bug that's kind of reverse of mine. I started my dwm and X by logging in then startx.
Yes, the default behavior is to show an EOF. It is up to you to decide if you want anything else there. I am using a seperate tool, dzen2 and writing bash scripts that pipe out to dzen, which in turn pipe out to dwm.

This might sound a bit complicated but its not. Take a look at the last few lines of the bash script I posted earlier and the following .xinitrc file to see what is happening.

Code: Select all

[f|~]$ cat .xinitrc 
while true
do
	sh /home/f/code/scripts/dzen_script.sh
done | dwm
Top
Codeblues
n00b
n00b
Posts: 26
Joined: Wed May 28, 2008 8:34 pm
Location: Chicago, Illinois

  • Quote

Post by Codeblues » Sat Jun 14, 2008 9:29 am

Hm...I tried

Code: Select all

rc-update add xdm default
then configured everything and that had dwm showing the date and time where EOF is. It seems like you're piping your dzen_script.sh out to dwm? Can I do the same with this in my /.xinitrc?

Code: Select all

date | dwm
exec dwm
Top
F_
Tux's lil' helper
Tux's lil' helper
Posts: 142
Joined: Sun Dec 31, 2006 5:52 pm

  • Quote

Post by F_ » Sat Jun 14, 2008 11:07 am

Codeblues wrote:then configured everything and that had dwm showing the date and time where EOF is. It seems like you're piping your dzen_script.sh out to dwm? Can I do the same with this in my /.xinitrc?

Code: Select all

date | dwm
exec dwm
You're executing dwm twice in that. Get rid of the "exec dwm".
Top
Codeblues
n00b
n00b
Posts: 26
Joined: Wed May 28, 2008 8:34 pm
Location: Chicago, Illinois

  • Quote

Post by Codeblues » Sun Jun 15, 2008 10:53 am

Doesn't seem to work.
Top
F_
Tux's lil' helper
Tux's lil' helper
Posts: 142
Joined: Sun Dec 31, 2006 5:52 pm

  • Quote

Post by F_ » Sun Jun 15, 2008 4:28 pm

Codeblues wrote:Doesn't seem to work.
try:

Code: Select all

while true
do
echo `date` `uptime | sed 's/.*,//'`
sleep 1
done | /path/to/dwm
Top
Codeblues
n00b
n00b
Posts: 26
Joined: Wed May 28, 2008 8:34 pm
Location: Chicago, Illinois

  • Quote

Post by Codeblues » Sun Jun 15, 2008 10:58 pm

Oooh that works. But there's also a display of "0.0x" there where x changes. Is that how long it took for the date command to execute? Can I get rid of it?
Top
Post Reply

14 posts • Page 1 of 1

Return to “Desktop Environments”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic