Created
January 6, 2021 15:35
-
-
Save chindraba-work/1bffea790ce03a2188f6c9bf1635e553 to your computer and use it in GitHub Desktop.
Single command to screenshot all KDE virtual desktops into one large image.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# SPDX-License-Identifier: CC-BY-SA-3.0 | |
# Script to take a screenshot of all the desktops and stitch them together into | |
# single image. | |
# Only slightly modified from an answer on AskUbuntu | |
# https://askubuntu.com/a/951399/1167939 | |
# by user derHugo | |
# https://askubuntu.com/users/423684/derhugo | |
# Licensed under CC BY-SA 3.0 | |
# Slight modifications made by Chindraba | |
# https://askubuntu.com/users/1167939/chindraba | |
# https://github.com/chindraba-work | |
# Added the creation of the directory, with a timestamp in the name | |
# Added the config settings to replace the setting in the montage command | |
# Doubled up on the motage command to create both the final image in both | |
# JPEG and PNG formats | |
# Added an explicit background (transparent in PNG) to accomodate multple | |
# monitor setups where the resolutions don't come out even. As in one | |
# monitor at 1920x1200 and a second at 1920x1080. That will be saved as | |
# an image 3840x1200 even though there is a 1920x120 band missing in the | |
# space of one monitor. White, the default was off-putting in too many cases. | |
desk_size='3840x1200' # the resolution of a single virtual desktop (all monitors as one image) | |
grid_size='3x2' # the arrangement, columns x rows, of the VDs into the final image | |
png_bgcolor='rgba(255,255,255,0)' # background color to use on .png final image, transparancy available | |
jpeg_background='rgb(21,21,21)' # background color to use on .jpg final image, transparancy NOT available | |
save_dir="capture-$(date --utc +%Y.%m.%d-%H.%M.%S)" | |
mkdir ~/$save_dir | |
dnum=$(xdotool get_num_desktops) | |
desk=0 | |
while [[ "$desk" -lt "$dnum" ]]; do | |
xdotool set_desktop $desk; | |
sleep 2; | |
maim --format png /dev/stdout > ~/$save_dir/desktop$desk.png; | |
desk=$((desk+1)); | |
done | |
pushd ~/$save_dir >/dev/null | |
montage desktop*.png -tile "$grid_size" -background $png_bgcolor -geometry "$desk_size"+1+1 workspaces.png | |
montage desktop*.png -tile "$grid_size" -background $jpeg_background -geometry "$desk_size"+1+1 workspaces.jpg | |
popd >/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment