Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #!/usr/bin/env perl
  2.  
  3. use strict;
  4. use warnings;
  5. use 5.010;
  6.  
  7. use JSON qw( decode_json ); # isn't default module, must be installed via CPAN or your system package manager
  8. use Time::HiRes qw ( usleep ); # for simple delays
  9.  
  10. my $outputfile = shift; # getting output filename from command-line params
  11. my $command = 'i3-msg -t get_workspaces'; # console command used to get the list of active workspaces
  12. my $fileprefix = '/tmp/i3shot-'; # prefix for temporary screenshots
  13.  
  14. my $json = `$command`;
  15. my $decoded = decode_json($json);
  16.  
  17. foreach my $workspace (@{$decoded}) {
  18. # get the name of current workspace
  19. my $current = $workspace->{'name'};
  20. # move there
  21. `i3-msg workspace $current`;
  22. # a short delay — some windows couldn't be drawn in a moment, and we get a rubbish
  23. usleep(200000);
  24. # and take screenshot of all the display and save it to temporary file
  25. `import -window root ${fileprefix}${current}.png`;
  26. }
  27.  
  28. # montage — an utility from ImageMagick to combine multiple images to a single one
  29. # parameters' values: -geometry — we don't need neither resizes nor shifts; -tile — put all images in a single row
  30. `montage ${fileprefix}*.png -geometry +0+0 -tile x1 ${outputfile}`;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement