twm, because what’s old is what’s new

I saw a screenshot for twm last week, and it inspired me enough to swing past it for the a couple days. This was my inspiration:

twm

What I managed to create was:

2014-05-07-6m47421-twm-rhapsody-palemoon-vim

That’s Arch Linux again, and it was not the terribly long and uphill journey you might imagine. If you’ve ever worked with Openbox, you’ll have no problem getting twm to do something similar. And in some ways, twm has an edge.

For one, twm is incredibly fast. Window moving and resizing are exceptionally quick, even on decade-old hardware. htop says it’s taking up less than 0.3 percent of the memory out of 1Gb available, which suggests less than 400Kb, while managing five or six windows. To the side of that machine I have a D830 with 4Gb of memory in it running Musca, and the difference is between the window managers is trivial.

Also on the plus side: Most everything you could want to do with twm — colors, borders, menus and submenus — is done in one configuration file, and in a straightforward arrangement.

You can specify per-application settings, desktop-wide color schemes, and exact per-window cursor behavior. You can even jam theme settings directly into your menu, and twm handles it with grace.

It’s simple, and doesn’t have too many frills to distract you. It keeps things clean and fast, but doesn’t become the tiling window manager du jour.

Of course, there are some things I don’t like about twm, or things that I’m used to that I find it difficult to work without. To wit:

  • First and most obvious, twm’s focus model. I realize this dates back a human generation, but it’s immensely irritating. A window has focus when the mouse moves over it. But that does not raise it, which means grazing the touchpad or bumping the mouse while you type sends commands into the next window … or into the ether.

    Similarly (and this is a little hard to explain), it also means when you spawn windows, they are not necessarily focused. Start an application and you get a ghost frame that you can maneuver into place, then click to drop. It’s a good idea, and makes things very fast for older hardware.

    However, if you click and don’t shift the mouse back over the same window, it doesn’t have focus. Which means you have to learn the habit of spawn-shift-drop-then-mouse-over, to actually use the program.

  • The rules to raise windows are a bit strange too. You can give focus to a window by mousing over it; that we already discussed. You can click on a window, and again, it has focus. But a window doesn’t raise to the top layer until you click specifically on the title bar.

    Unfortunately, that means if you’re like me and you have a tendency to “lose” applications in the stack on your desktop, you might end up shuffling things around to find out what the heck you’ve been typing, and see the whole application. Needless to say, it takes some getting used to.
  • There are no layering options for pinning windows to the top, or trapping them at the bottom. Those are features from IceWM and Openbox that, believe it or not, I need on a daily basis.
  • I’m not a fan of the icon manager. I can’t explain that any more than to say try it, and see if it strikes you as cumbersome too. I’m used to a middle-click in Openbox that shows every window, minimized or not, and you can jump straight to them. Since the iconmanager is not quite a panel, it behaves more like a hidden application that holds all the icons that are running, which has to be unminimized in order to unminimize something else. ๐Ÿ˜•
  • As best I can tell, twm can’t do xft fonts in borders. I might be mistaken and maybe there’s a patch, but I saw/found nothing to suggest otherwise. Of course, that may be part of what makes it fast. And of course, your applications can use xft fonts, so it’s not a hindrance.
  • There are plenty of options for custom mouse clicks, but I had difficulty getting Mod4+Key hotkeys set up. I don’t think twm was ever really meant to spit out a file manager when I press Mod4+2, or trigger gmrun with Alt+F2. I should really try that again, though.

I know some of these things could be corrected, or at least sidestepped, with a little more time and a little more trial-and-error in my .twmrc file. After a while though, I grew disinterested. I am ashamed. ๐Ÿ˜ณ

I have some other minor complaints, but I don’t want you to get the impression that twm was a bad experience. If you run your Openbox sessions close to the bone, or if you can live without all the doodads that come bundled in IceWM, or if you like tiling window managers but you’re homesick for something with a title bar on it, twm is not a bad option. I might use it again, on something with less muscle.

For what it’s worth, and for my own reference later, I’ll drop my .twmrc file here, after the more tag. If you need better ideas or a few other options to spur your interest, try Graham’s TWM page, which helped me build my .twmrc much quicker than picking through the man page. Oh, and of course, xwinman.org has a page on twm and its cousins. Oddly enough, the Arch Wiki page on twm is a bit scant. Perhaps I should do something about that. ๐Ÿ˜

# Settings effecting window borders etc ------------------------------------------

MenuFont 	"-xos4-terminus-medium-r-normal-*-*-120-*-*-c-*-paratype-pt154"
TitleFont 	"-xos4-terminus-medium-r-normal-*-*-120-*-*-c-*-paratype-pt154"
IconManagerFont	"-xos4-terminus-medium-r-normal-*-*-120-*-*-c-*-paratype-pt154"

BorderWidth 1 			# Number of pixels for border around entire window
ButtonIndent 2 			# Larger seems to squash buttons together
FramePadding 1 			# Number of pixels between titlebar buttons & frame
MenuBorderWidth 1 		# Number of pixels for menu border
TitleButtonBorderWidth 0 	# Number of pixels for button border
TitlePadding 2 			# Number of pixels around title buttons

NoAutoRaise			# Don't raise windows just because of cursor hover
NoMenuShadows 			# No shadow behind the menu
AutoRelativeResize		# Normal resize behavior
NoHighlight			# Don't stipple borders
DontMoveOff			# Enforces screen edge borders

# Title bar buttons

IconDirectory 		"/home/kmandla/.config/twm/icons" # Directory for non default icons
LeftTitleButton 	"resize.xbm"=f.resize
RightTitleButton 	"minimize.xbm"=f.iconify
RightTitleButton 	"maximize.xbm"=f.fullzoom
RightTitleButton 	"close.xbm"=f.delete

# # -------------------------------------------------------------------------------

Color
{
	BorderColor		"#303639"
	DefaultBackground	"White"
	DefaultForeground	"Black"
	
	TitleBackground		"Firebrick"
	TitleForeground		"White"
	
	MenuTitleBackground	"Firebrick"
	MenuTitleForeground	"White"
	
	MenuBackground		"#FFFFFF"
	MenuForeground		"#303639"
	
	MenuShadowColor		"#303639"
	MenuBorderColor		"#303639"
	
	PointerForeground 	"black"
	PointerBackground 	"white"
}
# xsetroot -solid "#05806d" looks good with this.

MoveDelta 1
Function "move-or-lower" { f.move f.deltastop f.lower }
Function "move-or-raise" { f.move f.deltastop f.raise }
Function "move-or-iconify" { f.move f.deltastop f.iconify }

Button3 = : root : f.menu "main" # Openbox-style right-click for menu
Button2 = : root : f.delete
Button3 = m4 : root : f.menu "system" # Super_L plus right-click for "system" menu

Button1 = m : window|icon : f.function "move-or-lower"
Button2 = m : window|icon : f.iconify
Button3 = m : window|icon : f.function "move-or-raise"

Button1 = : title : f.function "move-or-raise"
Button2 = : title : f.raiselower
Button3 = : title : f.iconify

Button1 = : icon : f.function "move-or-iconify"
#Button2 = : icon : f.destroy
Button3 = : icon : f.iconify

Button1 = : iconmgr : f.iconify
Button2 = : iconmgr : f.destroy
Button3 = : iconmgr : f.iconify

LeftTitleButton	 "/usr/X11R6/include/X11/bitmaps/xm_noenter16" = f.delete

menu "main"
{
	"TWM" 			f.title
	"Web browser"		f.exec "palemoon &"
	"File manager"		f.exec "urxvtc -e mc"
	"Terminal emulator"	f.exec "urxvtc"
	""              	f.nop
	"Applications"		f.menu "applications"
	"System"		f.menu "system"
}

menu "applications"
{
	"Games"		f.menu "games"
	"Network"	f.menu "network"
	"Tools"		f.menu "tools"
}

menu "games"
{
	"cataclysm-dda"	f.exec "urxvtc -title cataclysm	-e cataclysm"
}

menu "network"
{
	"Pale Moon"	f.exec "palemoon &"
	"Pidgin"	f.exec "pidgin &"
}

menu "tools"
{
	"alpine"	f.exec "urxvtc -title alpine 	-e alpine -d 0"
	"elinks"	f.exec "urxvtc -title elinks	-e /home/kmandla/.scripts/elinks.sh"
	"hnb"		f.exec "urxvtc -title hnb	-e hnb /home/kmandla/hold/notes.hnb"
	"mc"		f.exec "urxvtc 			-e mc"	
	"mocp"		f.exec "urxvtc 			-e mocp"
	"rhapsody"	f.exec "urxvtc -title rhapsody 	-e /home/kmandla/.scripts/chatnews.sh"
	"sc"		f.exec "urxvtc 			-e sc"
	"slrn"		f.exec "urxvtc -title slrn 	-e slrn -h news://news.aioe.org -f /home/kmandla/.config/.jnewsrc"
	"vim"		f.exec "urxvtc 			-e vim"
}

menu "system"
{
	"System monitor"	f.exec "urxvtc -e htop"
	"Network manager"	f.exec "urxvtc -e wicd-curses"
	""		f.nop
	"Graphical"		f.menu "graphical"
	"Audio"			f.menu "audio"
	""		f.nop
	"Icon manager"	f.showiconmgr
	"Redraw"	f.refresh
	"Restart" 	f.restart
	"Quit"		f.quit
}

menu "graphical"
{
	"Set background"	f.exec "feh -d. -B black -g 800x600 wallpaper/ &"
	""			f.nop
	"Screenshot"		f.exec "/home/kmandla/.scripts/screenshot.sh"
	"App shot"		f.exec "/home/kmandla/.scripts/appshot.sh"
}

menu "audio"
{
	"Adjust"	f.exec "urxvtc -title alsamixer	-e alsamixer"
	"Equalizer"	f.exec "urxvtc -title alsaequal	-e alsamixer -D equal"
	""		f.nop
	"Mute"		f.exec "/home/kmandla/.scripts/mute.sh"
	"Reset"		f.exec "/home/kmandla/.scripts/volumes.sh"
}

Cursors
{
	Frame     "left_ptr"
	Title     "left_ptr"
	Icon      "left_ptr"
	IconMgr   "left_ptr"
	Move      "fleur"
	Resize    "fleur"
	Menu      "hand1"
	Button    "hand2"
	Wait      "clock"
	Select    "dot"
	Destroy   "pirate"
}

1 thought on “twm, because what’s old is what’s new

  1. Pingback: blackbox, as seen in the wake of Openbox | Motho ke motho ka botho

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s