Useful Things You Can Do with FVWM
FVWM is a window manager used with the X Window System, which is the standard GUI for UNIX. This article explains a few useful things you can do with FVWM, including how to take screenshots conveniently, how to easily change a window's title and how to reconfigure easily a running FVWM instance.
This article is aimed at fairly knowledgeable UNIX users. A little programming experience would be helpful, but you probably can manage without it. No knowledge of X or FVWM is assumed.
The ideas presented in this document were tested with FVWM 2.4.16. They should work with any FVWM 2 version, however. Scripts presented in this document are written in Bash; I used the 2.05a.0(1)-release, but they should work in any version. Finally, I run Debian Linux 3.0. This means the utilities invoked from the shell scripts are assumed to be the standard Linux ones or to behave like them.
The method I present here allows you to save a screenshot of the current window by selecting an option from one of FVWM's window menus. If you use FVWM, it's almost certainly configured to put one or more buttons on the titlebar of each window. When clicked, one of these buttons--probably the one in the top left corner--brings up a menu that lists window operations such as move, resize and so on. We're going to modify this menu to have two new options, Take screenshot and Take named screenshot. Selecting the former will cause a screenshot with a unique name to be put in a standard directory. Selecting the latter will do the same thing, except it will prompt you for a name for the new image.
You may ask, why is this useful? You may go on to ask, can I not simply use a standard window-dumping utility, such as xwd, to take my screenshot? These are good questions, but the method I'm outlining offers several advantages. First, my method is more convenient than switching to another window and giving a command to take a screenshot. Second, my method chooses a filename for you, relieving you of the burden. The filename chosen is unique, ensuring that screenshots can be ordered according to the time at which they were taken.
The savings in time and trouble may seem minor, but when you need to take a series of screenshots from a particular window, they add up. Imagine that you want to explain to a client how to perform a particular operation. A good way of doing so is to send him a series of screenshots showing him every step in the sequence. Saving such a series is much less trouble with the method I'm about to outline.
As mentioned above, we're going to add two new options to an FVWM menu. To begin, let's look at how FVWM menus are defined. The following code, taken from a sample configuration file shipped with FVWM 2.4.16, defines an FVWM menu called Window-Ops2. More precisely, it adds elements to the end of the menu.
AddToMenu Window-Ops2 "&Move" Move + "&Resize" Resize + "&Raise" Raise + "&Lower" Lower + "(De)&Iconify" Iconify + "(Un)&Stick" Stick + "(Un)&Maximize" Maximize + "" Nop + "&Delete" Delete + "&Close" Close + "&Destroy" Destroy + "&ScrollBar" Module FvwmScroll 2 2 + "&Print" PrintFunction + "&Print Reverse" PrintReverseFunction
A full description of how to define menus in FVWM is unnecessary for our purposes, so I'm not going to give one. An outline is necessary, however. I begin by recapitulating the above command in the following table, labeling each component:
| Command for Adding to Menu Definition | Name of Menu | Menu Label | FVWM Code for Menu Action |
|---|---|---|---|
| AddToMenu | Window-Ops2 | &Move | Move |
| Plus Sign | Menu Label | FVWM Code for Menu Action | |
| + | &Resize | Resize | |
| + | &Raise | Raise | |
| + | &Lower | Lower | |
| + | (De)&Iconify | Iconify | |
| + | (Un)&Stick | Stick | |
| + | (Un)&Maximize | Maximize | |
| + | Nop | ||
| + | &Delete | Delete | |
| + | &Close | Close | |
| + | &Destroy | Destroy | |
| + | &ScrollBar | Module | |
| + | Print Function | ||
| + | &PrintReverse | Reverse Print Function |
This table shows the structure of the command. The first element is AddToMenu, an FVWM command. Next comes Window-Ops2, the name of the menu. After that comes &Move, which defines a menu label; I explain the function of the ampersand in a minute. Then comes Move, which is an FVWM command that is executed if the user chooses Move from the menu. Following this are a number of lines. Each line begins with a plus sign, which is followed by a label and then an FVWM command, possibly with arguments. In summary, the essence of the AddToMenu command is to bind menu labels to actions.
Now, about those ampersands: they're used in labels to define hotkeys. FVWM looks at the character after the ampersand to find out what the hotkey is. For example, a label of &Move defines M as a hotkey. If the user presses the M key after bringing up the menu, this is equivalent to clicking on the Move option.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
- seo services in india
12 min 28 sec ago - For KDE install kio-mtp
13 min 10 sec ago - Evernote is much more...
2 hours 13 min ago - Reply to comment | Linux Journal
10 hours 58 min ago - Dynamic DNS
11 hours 32 min ago - Reply to comment | Linux Journal
12 hours 31 min ago - Reply to comment | Linux Journal
13 hours 21 min ago - Not free anymore
17 hours 23 min ago - Great
21 hours 10 min ago - Reply to comment | Linux Journal
21 hours 18 min ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?



Comments
Useful Things You Can Do with FVWM
Not a bad article on the whole. :) My only gripe with it is that you seem to ignore Fvwm's internal functionality in favour of using superfluous external shell-scripts. Why? For instance, you could use Fvwm{Script,Form} to do all of the preconfigurations easily enough. Not to mention this is the whole reason "PipeRead" exists.
Your title change of window is slightly OTT as well. It would be better to outline the power of Fvwm by actually using its features rather than showing us how good it is to call external scripts. One trick that you can do to title windows:
AddToFunc TitleMeDifferently
+ I ThisWindow ($0) PipeRead 'echo exec xprop -id $[w.id] -set WM_NAME \"$1\"'
Then you can use:
TitleMeDifferently xterm somenewtitle
FVWM for Artists
FVWM can be set up with multiple desktops and zero edge resistance so that an aquired graphic can be stretched across as many desktops as required so that one aquired dot or one print out dot equals one screen pixel.
The results of modifying edges and shading can be seen on a real looking picture as it would appear in the output.
Nice, but what's with all the shell scripts?
FVWM has a number of modules, including things like FvwmForm which give you a very simple-to-use graphical form generator, that is much nicer for asking users for input than popping an xterm/rxvt and asking from the shell. Someone else commented on starting a new xterm on a remote system; as an example of using FvwmForm I show one I use to do this:
$ cat ~/.fvwm/XTermForm
# -*-fvwm-*-
#
# This is an FvwmForm definition file for creating specific xterms
DestroyModuleConfig XTermForm*
*XTermForm: WarpPointer
*XTermForm: Line center
*XTermForm: Text "Create New XTerm"
*XTermForm: Line left
*XTermForm: Text "Username:"
*XTermForm: Input UserName 12 "psmith"
*XTermForm: Line left
*XTermForm: Text "Login to host:"
*XTermForm: Input HostName 32 "localhost"
*XTermForm: Line left
*XTermForm: Text "Start on host:"
*XTermForm: Selection LocalSel single
*XTermForm: Choice Local Local on "Local"
*XTermForm: Choice Remote Remote off "Remote"
*XTermForm: Line expand
*XTermForm: Button quit "Create" ^M
*XTermForm: Command Exec rterm -l $(UserName) $(Remote?-r) $(HostName)
*XTermForm: Button restart "Clear"
*XTermForm: Button quit "Cancel" ^[
*XTermForm: Command Nop
Then in one of my menus I have:
+ "%menu/terminal.xpm%XTerm" Module FvwmForm XTermForm
(the stuff between the %...% in the menu title is the name of an icon to put in the menu.)
The rterm mentioned above is a script I wrote that handles creating terminals remotely (with DISPLAY set to my local host) or locally (then logging in within the xterm), with different users, etc. It's sort of customized to my environment so I won't include it but it should be straightforward to write your own, or you can simplify things by leaving out the local/remote option altogether.
I actually have a bunch of these forms for different kinds of things; it really helps create a more integrated desktop.
Or, if you're using Gnome with FVWM you can invoke zenity (see the man page) from your shell script to get a GTK dialog which looks nice. I'm sure KDE has something similar.
And there is another, even more powerful FVWM module for this kind of thing called FvwmScript; I've not used that one though.
rxvt is used so user has favourite editor available
Hi Paul. The reason for popping up a terminal
emulator, rather than using FvwmForm or any other
graphical dialog program, is that I want to give
the user the opportunity to use their favourite
text editor. I know that I'm much faster with
vi than I would be with FvwmForm.
Besides, hardened command-line junkies like me
regard GUIs as a necessary evil, and choose
atavistic command-line solutions whenever
possible.
xwd vs import
I've found that ImageMagick's import utility is in most cases better at capturing screenshots than xwd. xwd often has troubles with windows such as media players, rdesktop, and emulators.
The equivalent of:
xwd -id $w -out /tmp/screenshot && convert /tmp/screenshot /tmp/screenshot.jpg
is:
import -window $w /tmp/screenshot.jpg
Two additional tricks
Two additional tricks I've found useful:
1) create a root window menu item that opens a new xterm connected to a remote host. This requires setting up SSH to support X11 forwarding and using RSA keys so you don't have to use a password.
main-menu-pre.hook:
+ "chaos" Exec /usr/bin/ssh -X -f chaos.example.com "/usr/bin/X11/xterm -T chaos"
You should only use this with trusted systems, but it can be a real timesaver since you can then easily launch any remote X application.
2) set up a dynamic background image that indicates system load. Many people find this annoying, but I've found it useful (in those rare occasions when the desktop isn't wallpapered by windows) since it provides some visual feedback when the system is overloaded.
init.hook:
+ "I" Exec /usr/X11R6/bin/xlock -inroot -mode qix &
If this is too busy you could use xearth, xfishtank, or any other screensaver that can be run on the root window.
This has one other cute "feature" - it tends to blow away Windows users. :-)
xscreensaver hacks
All of the xscreensaver display modes, or "hacks", are separate programs that you can use to animate your desktop background by running with the -root command-line option. Each xscreensaver hack has its own man page, so if you want a slow-motion desktop pattern, check the man page for a speed or "-cycle-delay" option.