Graham's TWM page 2
It's been a while. That last config and screenshot was posted in March 2009. Here I am, back in the future during
the last gasps of 2021, surviving a global pandemic thinking... will I be back 11 years from now, writing about a
Window Manager?
I'm listening to SomaFM on Deadbeef and tweaking another TWM theme, this time under Arch Linux. There's something about the simplistic nature of TWM that keeps pulling me back. Perhaps it's my strong leaning towards minimalism?
Nostalgia - not what it used to be
Maybe it's the fact that TWM was the first "GUI" that I had seen on a non
M$ operating system, the first time I loaded GNU/Linux on
an IBM PC. This was back in the mid nineties when I bought an official
Walnut Creek disc set of Slackware 3.0 along with the Sams book
'Linux Unleashed' 2nd Edition. Little did I know back then, loading a distro
that included a picture of a duck-billed platypus on the jewel case cover and an installer that offered a font "for the Klingon
Language", it would result in years worth of sporadic 'Unix like' tinkering!
A computer person from the 1990's - plus some Linux CD-DROM's from the same era.
Perhaps it's the fact that GNU/Linux and FreeBSD et al are pretty much infinitely configurable. And for an old time tech with an unhealthy interest in computer operating systems that can end up being a very addictive pastime indeed.
I have often thought that I could possibly live at the terminal with Tmux but just occasionally there are tasks to be done demanding higher resolutions and better graphics. Which is where Xorg and TWM come to the rescue.
TWM Rice You may be wondering why I am talking about take away food in the same breath as operating systems? If you where down with the kids and the l33t uber geeks you'd know already know that a 'rice' or 'ricing' was geek speak for 'customising ones desktop' - here's is little explanation should you need it.
Where was I...
Oh, yeah, perusing Openbox themes for inspiration on www.pling.com when I serendipitously came across this TWM tribute theme by Crimeboy. Nice Rice - I thought! I knew instantly that he had been inluenced by TWM design and the color schemes shown on the TWM Wikipedia page.
Crimeboy's OB theme and
seamless background tile. More tiles are in my repo here.
So here's my 'rice' based on Crimeboys theme, itself based on TWM's original colours. The .twmrc color section for this below;
BorderColor "#0D8778" DefaultBackground "#0D8778" DefaultForeground "#FFFFFF" TitleBackground "#0D8778" TitleForeground "#FFFFFF" MenuTitleBackground "#B52F62" MenuTitleForeground "#FFFFFF" MenuBackground "#B52F62" MenuForeground "#FFFFFF" MenuBorderColor "#B52F62"
Screenshot showing the TWM Wikipedia page and TWM in it's original colours - click for larger version!
TWM mimicking the Windows 3.1 colour theme 'Black Leather Jacket' - the 'Bricks' xbm tile is in my repo, link below.
Add-Ons & Tweaks
Apart from changing colours and applying backgrounds and tiles there are a few things I was compelled to change from the
stock config to help make my time with TWM more enjoyable. And before you start thinking why not just change to a window
manager that has the functions you want? - well... where would the fun in that be?
Menus
First up is the menu behaviour. My second most used Window Manager over the years is
Fluxbox and I kinda like the right click menu that Fluxbox uses. So I have my TWM menu on the right mouse button. On
the left I have 'TWM Windows' which is a list of the current active windows. This means that if I end up with a mess of
windows on the desktop I just need to find a clear space, pop up the list and bring the task I want to the top. The middle
mouse button has a fairly sparse 'system menu' for config edits and reloads as well as xkill in case of any badly behaved
process needs closing out.
I'll post my full .twmrc later on but here are the settings that affect mouse menu behaviour;
# Right click menu ala Fluxbox Button3 = : root : f.menu "RootMenu" # Wheel button system menu Button2 = : root : f.menu "System" # Left click on desktop to bring up window list Button1 = : root : f.menu "TwmWindows"
Run Box
Another feature of Fluxbox (and many other Window Managers and Desktop Environments) that I have found useful is the
'Run' box! A small program launcher for any task not hardwired into the menu. It can be seen on at the bottom of the
two screenshots above. TWM doesn't have this feature but it can easily be added with the help of a short script and
menu item.
Here's the menu item to launch the run box;
"Command" f.exec "xterm -geometry 25x1+840+1150 -title Run -e ~/.twm/scripts/getrun &"
I'm certainly no shell scripting expert but I managed to assemble this from various code snippets found around the web. Xterm is called to create a mini window and passed the -e switch with the script location. My 'getrun' script contents below;
read -p "# " userinput nohup $userinput >/dev/null 2>&1 & PPPID=$(awk '{print $4}' "/proc/$PPID/stat") kill $PPPID
The user is presented with the miniwindow and a #prompt. The name of the task is typed in and enter pressed. Whatever the user has inputted is read into the $userinput variable. This task is launched but the parent Xterm is asked not to quit [nohup] otherwise the child process would also quit. This is backgrounded. The 3rd line figures out the PID of the original Xterm call, the 4th kills that removing the 'Run' box from the desktop whilst leaving the task that was launched still running.
Virtual Desktops
TWM doesn't incorporate any 'Virtual Desktop' code and as per my
previous page, I have used Vdesk to good effect here. This time though, instead of adding the Vdesk commands
to the menu I have bound them to key combinations.
function "desktop-1" { f.exec "xmessage -center -timeout 1 -buttons OK DESKTOP NO: 1 &" f.exec "vdesk 1" } function "desktop-2" { f.exec "xmessage -center -timeout 1 -buttons OK DESKTOP NO: 2 &" f.exec "vdesk 2" } function "desktop-3" { f.exec "xmessage -center -timeout 1 -buttons OK DESKTOP NO: 3 &" f.exec "vdesk 3" } function "desktop-4" { f.exec "xmessage -center -timeout 1 -buttons OK DESKTOP NO: 4 &" f.exec "vdesk 4" } "1" = c : all : f.function "desktop-1" "2" = c : all : f.function "desktop-2" "3" = c : all : f.function "desktop-3" "4" = c : all : f.function "desktop-4"
The above functions bind the Control key plus 1,2,3,4 number keys to the Vdesk commands. In addition I use a small centered xmessage window shown left to 'popup' briefly to remind you which Virtual Desktop you have warped to.
I extended this idea by binding the Control + left / right cursor keys to warp forward or back through the Virtual Desktops as shown below;
function "next" { f.exec "A=$((`vdesk`+1)); if [ $A = 5 ] ; then A=1 ; fi ; vdesk $A" f.exec "B=$((`vdesk`)); xmessage -center -timeout 1 -buttons OK DESKTOP NO: $B &" } function "prev" { f.exec "A=$((`vdesk`-1)); if [ $A = 0 ] ; then A=4 ; fi ; vdesk $A" f.exec "B=$((`vdesk`)); xmessage -center -timeout 1 -buttons OK DESKTOP NO: $B &" } "Right" = c : all : f.function "next" "Left" = c : all : f.function "prev"
Again xmessage will use the returned screen number from Vdesk to popup a reminder of the desktop you are on. I have to credit Lontronics.nl for the logic on the first line of the above functions (wherever he may be!)
Another feature missing in TWM but present in Fluxbox and other WM's is the ability to send an individual window to a specific desktop. This took me some time to figure out but I got there in the end. It requires the modification of TWM's 'Window Title' menu and some additional tools namely xdotool, xwininfo and grep.
menu "WindowMenu" { "Sendto 1" f.exec "/home/orby/.twm/scripts/sendto-1 &" "Sendto 2" f.exec "/home/orby/.twm/scripts/sendto-2 &" "Sendto 3" f.exec "/home/orby/.twm/scripts/sendto-3 &" "Sendto 4" f.exec "/home/orby/.twm/scripts/sendto-4 &" }
The above adds the required Window Title menu items so the window can be sent to the desired desktop. And the below shows the contents of the scripts referenced above, one for each destination.
winid=$(xdotool click 1 & xwininfo | awk '/id: / {print $4}'); vdesk 1 $winid
The above is all about extracting the active window ID ($winid) and passing it on to Vdesk. 'xdotool click 1' simulates a window click required by xwininfo that returns a lot of information about the click target window. Then awk parses that info and returns just the window ID number. This is then passed to Vdesk so it knows which window to send to which desktop! Neat huh? I then created three more 'Sendto' scripts, one for each desktop.
Whilst putting this together I came up with one last task for Vdesk which again came from using other window managers. And that is; the ability to 'Stick' or 'Nail' a selected individual window to all the Virtual Desktops!
As I already knew how to get the window ID the last bit was easy - I had finally noticed the Vdesk option 'sticky' i.e. send to window 0
I may add a window title icon or 'sticky button' at some point to complement this. Just for completeness the below shows the contents of the 'Sticky' script.
winid=$(xdotool click 1 & xwininfo | awk '/id: / {print $4}'); vdesk 0 $winid
Backgrounds
There are numerous ways to set background wallpapers, images and repeating tiles. Here are a few I have used recently...
fbseroot is a nice background setting utility that is part of the Fluxbox distribution. The one thing that it does that others cannot, that I really like, is set elliptical gradients. I think this sets it apart because it gives your desktop a kind of depth. Here's what I have in my .xinitrc for my current config;
fbsetroot -gradient Elliptic -from '#2d527f' -to '#859ac0' &
hsetroot - another background setter that can manipulate images and
set gradients. The gradient options aren't quite as extensive as fbsetroot but you might like what it can do with large
wallpapers (tinting and blurring) By way of an example I used this setting for a while;
xsetroot - the background setter that
is part of the Xorg distribution. Even less features than the previous two utilities but it does include one feature which
is quite interesting - the ability to specify a btmap file as a tiled background and being able to change the foreground
and background colours for said bitmap file. This one probably goes way back. There are a couple of image formats, namely
xpm and xbm which can be used by Xorg.
By way of an example this is the contents of a small (8x8 pixel) .xbm file which defines the pixel data. If you copy the above and paste into a plain text editor then save as bricks.xbm you will be able to set this as
a repeating background pattern with colours of your choice as show in the below example; You can use some graphics editors to create / edit .xbm files and create your own patterns. Both Gimp and mtPaint
can provide that function, there may be others? More tiling .xbm files can be found in my tiles
repository. If you came from early windows desktops you may remember
some of them. On Unix like installations a quick check in /usr/include/X11/bitmaps (or equivalent) will reveal bitmap
files included with your Xorg install. I'll admit I've found it quite entertaining, trying to create the most impactful
background from the smallest possible tile file. Whilst on the subject of backgrounds and themes the following links may be of interest to you; Classic patterned bitmap tiled wallpapers -
https://github.com/dkeg/bitmap-walls Huge collection of wallpapers and tiles -
http://cs.gettysburg.edu/~duncjo01/archive/patterns/ X11 color names -
https://en.wikipedia.org/wiki/X11_color_names HTML Color Shades -
https://www.w3schools.com/colors/colors_shades.asp Fuut1 on Deviant Art -
https://www.deviantart.com/fuut1/gallery/all Subtle Patterns -
https://www.toptal.com/designers/subtlepatterns/ Background Tiles -
https://background-tiles.com/ Other TWM related TWM on Github -
https://github.com/freedesktop/twm TWM repo at Freedesktop -
https://gitlab.freedesktop.org/xorg/app/twm TWM entry on the Arch Linux wiki -
https://wiki.archlinux.org/title/twm TWM Wikipedia entry -
https://en.wikipedia.org/wiki/Twm TWM & VTWM entry on XWinman -
http://www.xwinman.org/vtwm.php Tom LaStrange webpage -
http://www.lastrange.com/work/ Last published interview with Tom LaStrange from 2001 Tom LaStrange on Twitter -
https://twitter.com/TomLaStrange Tom LaStrange on Reddit -
https://www.reddit.com/r/unixporn/comments Last mention of TWM on xorg announce -
https://lists.x.org/archives/xorg-announce/2020-June/003047.html Eeri Kask's announcement back in 2010 -
https://lists.x.org/archives/xorg/2010-January/048401.html Current
hsetroot -add "#859ac0" -add "#1f4471" -gradient 180
#define bricks_width 8
#define bricks_height 8
static unsigned char bricks_bits[] = {
0xdd, 0xfa, 0x75, 0xba, 0x5d, 0xae, 0x57, 0xaf, };
xsetroot -bitmap bricks.xbm -fg "#808080" -bg "#101010"
Whilst I suspect the above may have a very small audience I know there are those out there who are still using
TWM on a daily basis. So for you guys, or anyone else who is interested, here is a screenshot of my current setup.
I'll follow it with links to all the config files, tiles and scripts. I'd welcome any feedback or comments
- don't be shy drop me a line.
ku.oc.wncpc@nimda
ku.oc.wncpc@nimda
ku.oc.wncpc@nimda
ku.oc.wncpc@nimda
ku.oc.wncpc@nimda
Window title bar icons in .xbm format -> icons
TWM man page and docs in .pdf format -> docs
Background tiles in .png and .xbm format -> tiles
Various configuration files including .twmrc -> config
Various scripts shown in the examples above -> scripts
Various recent themes including wallpaper jpgs -> themes
Last Modified: 07/03/2024 15:03:49