Useful Things You Can Do with FVWM
Suppose we want a simple way of saving a screenshot of the current window, so that when we select the correct option from a menu, a screenshot is saved to the file /tmp/screenshot. We can achieve this by adding the following line to the end of the AddToMenu command listed above:
+ "Take screenshot" Exec xwd -id $w -out /tmp/screenshot
Let's examine how this works. As already explained, the first two elements of the line are a plus sign and a label. Then comes the FVWM command, which in this case is:
Exec xwd -id $w -out /tmp/screenshot
The command name is Exec, which allows one to execute an external command. Its arguments are the external command, followed by the external command's arguments. In this case, the external command is xwd, and the arguments passed to it by FVWM are -id $w -out /tmp/screenshot.
The notation $w in these arguments needs some explanation. It's a special FVWM variable that stands for the window ID of the current window. When FVWM runs the above xwd command, it replaces the argument $w with the relevant window ID.
What is a window ID? The X Window System needs a way of identifying and referring to windows. It does so by assigning each window a unique number, known as the window ID.
For our purposes, you don't need to understand xwd's other arguments just yet. For now, all you need to know is that the command given above causes xwd to put a screenshot of the current window in the file /tmp/screenshot.
At this point, you may be asking, FVWM has many menus; how do I identify the one I need to modify? The answer is the correct one probably is the one called Window-Ops2, but it all depends on whoever packaged and configured FVWM for you. The best way to find the correct menu is to search your FVWM config file for a menu that uses all or most of the following functions: Move, Resize, Raise, Lower, Iconify, Close. If you find such a menu, it's almost certainly the right one.
We've completed the preliminaries and now are ready to start looking at the promised solution. It involves a program I call savescreenshot. To have FVWM run it to take a screenshot, we add the following line to the appropriate AddToMenu command:
+ "Take screens&hot" Exec savescreenshot $w + "Take &named screenshot" Exec savescreenshot -n $w
You need to make sure savescreenshot can be found by searching the PATH that was defined when FVWM was invoked. If it can't, you can use an absolute pathname for savescreenshot. Also, notice that the above labels make H and N into hotkeys.
To actually take the screenshot, savescreenshot relies on xwd. Although several screenshot utilities exist, I chose xwd because it comes packaged with X. xwd's basic usage is as follows:
xwd [-id window_ID] [-out output_file]
where window_ID and output_file should be replaced by the actual names of the window ID and output file, respectively.
The -out option, as the summary above suggests, directs xwd's output to the specified output file; if you don't supply it, xwd writes to its standard output. The -id option tells xwd to use the window with the specified window ID. If you don't supply it, xwd changes the mouse pointer's shape to indicate that it wants you to click in a window to select it. When you've done so, it takes a screenshot of that window.
xwd uses its own special image format. This format doesn't use compression, so output files often are quite large. You usually want to convert the output file to a format such as PNG; I'll cover this in a minute.
To view xwd's output files, you can use xwud, which also comes packaged with X. You can specify an input file with the -in option. The command xwud -in browser-window would display the screenshot stored in the file browser-window.
To convert files in xwd format, you can use convert from the ImageMagick suite. The following commands convert an image to various common formats and should be self-explanatory:
convert browser-window browser-window.png convert browser-window browser-window.jpg
If you want to use the netpbm tools, the following two commands correspond to the two commands above:
xwdtopnm < browser-window | pnmtopng > browser-window.png xwdtopnm < browser-window | pnmtojpeg > browser-window.jpg
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
- Google's Abacus Project: It's All about Trust
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- Back to Backups
- Seeing Red and Getting Sleep
- Secure Desktops with Qubes: Introduction
- Fancy Tricks for Changing Numeric Base
- Working with Command Arguments
- Secure Desktops with Qubes: Installation
- Linux Mint 18
- CentOS 6.8 Released
Until recently, IBM’s Power Platform was looked upon as being the system that hosted IBM’s flavor of UNIX and proprietary operating system called IBM i. These servers often are found in medium-size businesses running ERP, CRM and financials for on-premise customers. By enabling the Power platform to run the Linux OS, IBM now has positioned Power to be the platform of choice for those already running Linux that are facing scalability issues, especially customers looking at analytics, big data or cloud computing.
￼Running Linux on IBM’s Power hardware offers some obvious benefits, including improved processing speed and memory bandwidth, inherent security, and simpler deployment and management. But if you look beyond the impressive architecture, you’ll also find an open ecosystem that has given rise to a strong, innovative community, as well as an inventory of system and network management applications that really help leverage the benefits offered by running Linux on Power.Get the Guide