Sceenshot from all desktops - script

Hi,
I like to share a small script to make one screenshot from all desktops.
It make screenshot then move to next desktop, wait 2 sec (change SLEEP if you need), and so on.
After last desktop it montage all images into one and show it to you with viewnior.

#!/bin/bash
# Inspired by: https://askubuntu.com/questions/211750/taking-screenshots-of-all-or-specific-virtual-desktops-workspaces-or-windows

SLEEP="2"
DESTDIR=$(xdg-user-dir PICTURES)

DATE=$(date +"%Y%m%d-%H%M%S")
eval $(xdotool getdisplaygeometry --shell)

numdesk=$(xdotool get_num_desktops)
desk=0
while [[ "$desk" -lt "$numdesk" ]];
     do
          xdotool set_desktop $desk;
          sleep ${SLEEP};
          scrot -o "/tmp/desktop$desk.png";
          desk=$((desk+1));
     done

cd ${DESTDIR}
montage  /tmp/desktop*.png  -tile 1x${dnum} -geometry ${WIDTH}x${HEIGHT}+0+0 workspaces${DATE}.png
rm /tmp/desktop*.png
viewnior workspaces${DATE}.png


and screenshot as an example :slight_smile:

https://imgur.com/a/Qppyvoa

5 Likes