== Understanding FVWM States, with better FVWM code for selecting terminal windows Every so often I make an epic mistake, where I drastically misunderstand something. A discussion with one of the people behind FVWM in response to [[yesterday's entry on selecting terminal windows from the keyboard FvwmKeyboardWindows]] revealed that I had made one of them about an FVWM feature called (window) 'States'; a correct understanding of the feature leads to a better version of the FVWM code from my last entry. What FVWM States are is effectively user-controlled tags for windows, given numbers from 0 through 31 instead of (say) text labels. Crucially, ~~States are completely independent from each other~~; a given window can be in multiple States at once, and individual States are manipulated independently. Windows default to having all States turned off but can have this changed by FVWM Style commands or on the fly. States can be used for at least two separate things. The first is to keep track of actual window states, such as whether or not a window has ever been iconified; the second is to aggregate windows together into some sort of abstract category such as 'all terminal windows'. (My mistake was thinking that a window could only be in one State at a time, which meant that using States to identify terminal windows would preclude using States for anything else involving them, more or less. This is wrong.) The second sort of use of States is the interesting one for what I was doing in yesterday's entry, so here's revised FVWM code with commentary. First, we mark all windows we consider 'terminal windows' with a specific State through a _Style_ command. I've picked State 2 here, but the choice is arbitrary (provided that you aren't already using the state number). Style "XTerm" State 2 Style "9term" State 2 Style "Gnome-terminal" State 2 Any time your FVWM configuration wants to specify 'this applies to terminal windows' it can now simply use '_State 2_' as the matching condition. Specifically we can do this in my ToWindow function: AddToFunc ToWindow + I Current (State 2, "$0") Break + I Next (State 2, "$0") ToWindow2 AddToFunc ToWindow2 + I Iconify False + I Focus + I Raise + I WarpToWindow 80 20 Using a State to identify terminal windows has the great advantage that if you start using another form of terminal window, such as Konsole, you don't have to go through your FVWM configuration to add additional '_|Konsole_' matching conditions to everything; you just add a single Style declaration to identify Konsole as a terminal. Style "Konsole" State 2 (If you actually want all terminal windows to have the same window manager decorations and so on, you can do even better than this. FVWM allows for abstract styles, so you can create a 'terminal' style that decorates the window appropriately and also includes the '_State 2_' setting, then simply say '_Style "Konsole" UseStyle terminal_'.) (I'd like to thank Thomas Adam for taking the time to patiently get enlightenment into my head.)