8

How can I take a screenshot in X.org?

I am unsure if the Print Screen button will "just work" and I don't know how I would go about testing it.

8

The most commonly used Linux application for taking screen-shots is called scrot

You can install it with for Debian:

sudo apt-get install scrot

Or for Arch:

sudo pacman -S scrot

A screenshot is taken by typing:

scrot output-file.png

If you want to bind scrot to the print screen key then that will need to be controlled by your window manager.

| improve this answer | |
  • 1
    Scrot is quicker and smaller than ImageMagick - 1MB compared to 43MB. – Andrew Fogg Jun 16 '12 at 23:26
5

I found a great answer to this question here, it is worth repeating.

This can be achieved with ImageMagick. Install by running the command

sudo apt-get install imagemagick

To grab all desktop just type

import -window root screen.png

Or you can do it with a delay of 5 seconds

sleep 5; import -window root screen.png
| improve this answer | |
  • I wonder whether we could bind this to a key combo; anyone? – Alex Chamberlain Jun 16 '12 at 19:22
  • @AlexChamberlain: This is dependant on the WM that is being used. – Jivings Jun 16 '12 at 21:03
  • @AlexChamberlain there is an answer as to how to do that here – Andrew Fogg Jun 17 '12 at 13:54
  • -1 I despise ImageMagick and all of its derivatives/relatives. It's a kick in the pants to install, and it's even worse to fix if something breaks. – Andrew Larsson Jun 18 '12 at 17:21
  • @Jivings I guess if you're using your window manager's keybindings; I would think most people use xbindkeys though – Michael Mrozek Jul 9 '12 at 18:37
0

I use 'xwd'. For example, one I just did: xwd | xwdtopnm > dw.ppm The only downside I know of with xwd is that you need some other utility to convert its output to something understood by anything other than 'xwud'.

| improve this answer | |
0

This is the perl6 script I use to take root area window or delay ScreenShots using import:

#!/usr/bin/env perl6
use v6;

sub message(Str $file) {
  run <xmessage -nearmouse -timeout 3>, "Screenshot saved in $file";
}

sub print_window(Str $file) {
  qx{xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"} ~~ /(0x\d*).*$/;
  run <import -window>, $0, $file;
  message($file);
}

sub MAIN( Str $option where $option ∈ <root area window delay> ) {
  my $today = DateTime.now( formatter => { 
        sprintf "%04d_%02d_%02d_%02d:%02d:%02d", 
                .year, .month, .day, .hour, .minute, .second 
       } );
  my $file  = "$*HOME/Dades/Imatges/ScreenShots/$today.png";

  given $option {
    when 'root'   { run <import -window root>, $file; message($file) }
    when 'area'   { run "import", $file             ; message($file) }
    when 'window' { print_window($file)                              }
    when 'delay'  { sleep 5; print_window($file)                     }
    default       { say 'Something went wrong'      ; exit           }
  }
}

These are the key bindings in i3 to run the script:

bindsym $mod+Print exec Print_Screen root 
bindsym --release $mod+Shift+Print exec Print_Screen area
bindsym $mod+Mod1+Print exec Print_Screen delay
bindsym $mod+Control+Print exec Print_Screen window
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.