Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env perl
- use strict;
- use warnings;
- use 5.010;
- use JSON qw( decode_json ); # isn't default module, must be installed via CPAN or your system package manager
- use Time::HiRes qw ( usleep ); # for simple delays
- my $outputfile = shift; # getting output filename from command-line params
- my $command = 'i3-msg -t get_workspaces'; # console command used to get the list of active workspaces
- my $fileprefix = '/tmp/i3shot-'; # prefix for temporary screenshots
- my $json = `$command`;
- my $decoded = decode_json($json);
- foreach my $workspace (@{$decoded}) {
- # get the name of current workspace
- my $current = $workspace->{'name'};
- # move there
- `i3-msg workspace $current`;
- # a short delay — some windows couldn't be drawn in a moment, and we get a rubbish
- usleep(200000);
- # and take screenshot of all the display and save it to temporary file
- `import -window root ${fileprefix}${current}.png`;
- }
- # montage — an utility from ImageMagick to combine multiple images to a single one
- # parameters' values: -geometry — we don't need neither resizes nor shifts; -tile — put all images in a single row
- `montage ${fileprefix}*.png -geometry +0+0 -tile x1 ${outputfile}`;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement