6

I am using a system that runs twm and I am wondering if it is possible to switch between windows using keyboard shortcuts, as I do in gnome with Alt+Tab.

6 Answers 6

3

The f.warpring function is close, but you have to define a list of windows that are part of the ring, and there doesn't seem to be a way to say "all of them". This, for example, sets up Alt+Tab and Shift+Alt+Tab to cycle among xterms:

WindowRing { "XTerm" }
"Tab" = m     : all : f.warpring "next"
"Tab" = m | s : all : f.warpring "prev"

Have you tried the icon manager? It shows a 2-dimensional grid of window names and you can bind keys to up, down, left, and right in the grid. Here's a fragment of my setup:

ShowIconManager
IconManagerGeometry "320x200+0+0" 3
"h" = m | c : all : f.lefticonmgr
"j" = m | c : all : f.downiconmgr
"k" = m | c : all : f.upiconmgr
"l" = m | c : all : f.righticonmgr

Window selection using Ctrl + Alt + the vi cursor keys. Hooray for unix!

Truly the biggest thing that makes twm an improvement over window managers of the gnome generation is that all of the features I just showed you are properly documented ("properly" means "in the man page"). The configuration file is not SGML/XML-ish; it's intended to be understood by humans, and edited with an editor, not a maze of menus on top of 3 layers of configuration-abstraction-libraries.

1

Yes, the "Ring" needs the names of the programs which will be included in it. But, assuming all windows you have also yield an icon, you can navigate over the Icon Manager by programming keys (I use Shift, Alt or Ctrl and F9, F10 and F11 to move left, right or down and F12 to deiconize the Icon Manager if it gets iconized. This will work whether the window is iconized or not.

For stacked windows, I likewise use F5 and F6 to up or down the stack, and this works whether or not the windows are in the "Ring" or not. I have F7 and F8 to go left and right in the "Ring".

You can also hit Shift and Num Lock to turn the numeric pad into mouse movement keys, with Num Lock, / and * then acting as the left, center and right mouse buttons, and 5 to emulate a click. Turn that functionality off by hitting Shift and Num Lock again.

As to the "focus", you can make it operate like on windows (i.e. click to get focus on a window with the f.focus function. See the manpage).

You can do quite clever stuff with .xsession, .Xresources and .twmrc files in combination. On some X11 setups, the first two will be .xinitrc and .XDefaults but fill the same roles.

I've been using twm for 20 years, fast, reliable, no clutter, and supports multiple logins over a client server network (GNOME and KDE tend to dislike multiple sessions).

0

I don't think Twm can provide the Alt+Tab behavior where you cycle between windows by holding Alt down and pressing Tab repeatedly. There are facilities to switch between windows with the keyboard, but they're limited.

Twm applies a focus-follows-mouse policy: the focused window is the one that the mouse pointer is in. The function f.warpring navigates between a fixed set of windows, determined by the variable WindowRing. For example, the following .twmrc snippet lets you cycle among xterm windows with Alt+F2.

WindowRing { "XTerm" }
"F2" = m : all  : f.warpring "next"
"F2" = m|s : all  : f.warpring "prev"

The function f.warpto warps to a window by name.

"E" = m|s : all : f.warpto "Emacs"

There's a patch to allow f.warpring to cycle over all windows, but as far as I can tell, it hasn't been accepted by the maintainers.

You don't have to use Twm if you don't like it. It is assuredly very primitive. You can invoke a different window manager in your ~/.xinitrc or ~/.xsession. Even if there is no other window manager installed on your system, you can compile it and install it under your home directory. If your system is very resource-constrained, try Vtwm or Fvwm or Blackbox or Ratpoison or many other low-footprint window managers.

0

Cycling by holding Alt down and pressing Tab repeatedly may be achieved via 3rd party application: https://github.com/sagb/alttab
It works fine in twm.

0
############################################################################################
######                  Alt-Tab no wildcard add applications as required              ######
############################################################################################

WindowRing 
{

"abiword"
"audacity"
"claws-mail"
"dillo"
"geany"
"geeqie"
"gnumeric"
"gnucash"
"gogglesmm"
"lilyterm"
"leafpad"
"lowriter"
"localc"
"mpv"
"mumble"
"pidgin"
"ROX-Filer"
"runner" 
"Seamonkey"
"spacefm"
"utox"
"xterm"

}

"Tab" =             m     : all         : f.warpring "next"
"Tab" =             m | s : all         : f.warpring "prev"

############################################################################################
######                                   Alt-Tab end                                  ######
############################################################################################
0
# Hold Alt and Tab cycles through windows bringing up focus
Function "winup" { f.circleup }
"Tab" = m : root|window|frame|title : f.function "winup"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .