Networking, Programming and Graphics - Tutorials
ONLINEHOWTO.net Tutorials Category

Taking screenshots in Gnome with active Menu

Type: Code Networking, Programming and Graphics - Tutorials
Networking, Programming and Graphics - Tutorials
Level: Beginner Networking, Programming and Graphics - Tutorials 
Networking, Programming and Graphics - Tutorials
Date: 2009-May-30
Networking, Programming and Graphics - Tutorials
Visited: 1553 times
Networking, Programming and Graphics - Tutorials
Rating: Networking, Programming and Graphics - Tutorials
Networking, Programming and Graphics - Tutorials
Published: Stephen Think

Greetings to all of you curious people who came on this page. In this tutorial I will demonstrate you a small trick to workaround one of the most annoying bugs in Gnome - the malfunction of printscreen button when a menu is active.

A little background of the case I came across. I was writing another useful tutorial today , you may want to check it here How to disable F10 key shortcut in gnome-terminal and I was trying to prepare the screenshots for it. I hit on a rock making even the first print screen!!! As you can see in the tutorial first step is to open gnome-terminal and then click on Edit menu. Then I wanted to take a screenshot so I'm pressing Alt+PrtSc and guess what ... nothing happens. I release the menu and press again Alt+PrtSc and to my surprise all works as expected. I was lucky to narrow the problem pretty fast so I was thinking ... Alright I guess gnome-screenshot doesn't work fine then lets find another application that will work. I run Archlinux , pretty cool distro by the way, so I run
pacman -Ss screenshot
Nothing really useful showed up. I tried maybe 5-10 other searches but no luck. Even tried to search in yaourt but again hit on a rock. Well then I started googling around for possible fixes. It turned out that other Linux users have experienced the same problem on all distributions you can imagine. Ubuntu, Archlinux, Fedora, Suse , etc. All talking about the same problem and reporting this as a bug. It turned out that it is just a flaw in the design of Gnome itself. Just something they overlooked when they were making the whole concept of the desktop environment. Once a menu is clicked it gets in to some active state and they ask the windowing system to send all keyboard and mouse events to them. Unfortunately not all menus in all different applications have a special keyboard shortcut about the printscreen button so when you press it nothing happens.

I came across about an article that describes a possible workaround for this problem. It was saying about the command line utility gnome-screenshot. Again as alway the good developers have a solution for everything. Here are the options this CLI tool provides.
[onlinehowto@localhost ~]$ gnome-screenshot  --help
Usage:
  gnome-screenshot [OPTION...] Take a picture of the screen

Help Options:
  -?, --help                     Show help options
  --help-all                     Show all help options
  --help-gtk                     Show GTK+ Options

Application Options:
  -w, --window                   Grab a window instead of the entire screen
  -a, --area                     Grab an area of the screen instead of the entire screen
  -b, --include-border           Include the window border with the screenshot
  -B, --remove-border            Remove the window border from the screenshot
  -d, --delay=seconds            Take screenshot after specified delay [in seconds]
  -e, --border-effect=effect     Effect to add to the border (shadow, border or none)
  -i, --interactive              Interactively set options
  --display=DISPLAY              X display to use

It is really great. You can pass all kind of variables you need, even telling on which X session to take the screenshot. How cool is that!!

Ok now the solution for my little problem was the following command.
gnome-screenshot  -w --delay=5
Shot explanation:

I use -w because I want to capture just one window not the whole screen. You may ask yourself then how the utility will know which window to take a screenshot. Well it captures the current on-focus window.

The --delay=5 is just for that ... to give me 5 seconds to make the window, I like to take a screenshot to, active.
Rate this tutorial:                    
Post Comment


    • posted on 2009-Jun-02 | 10:05:50 AM
      Linux RULZZZZZ
Need a specific tutorial? Do not hesitate and submit a request!
Your e-mail: