Saving your activity for future
About 5 years ago I was thinking about how much time I spend on computers and on what, because of that I've made a cronjob that executed every minute making a screenshot.
It's a protection
After years of using it i can tell you that it's an absolutely invaluable thing. Whenever you forget something, you can go back and see what you've been doing.
It can be a text file you couldn't save before power went down, some random video or site you were watching a couple hours ago and forgot about it's name or list of files that you have accidently deleted. All of that can be restored by you simply taking screenshots.
The best part about it is that you have the whole process recorded so even if you were to delete your whole system, every file on your computer but these screenshots, you can recreate all of that by looking at how you've interacted with it in the past.
For example once I've irrecoverably deleted most of my collection of files and the first thing I did was to look through these screenshots. In 5 minutes i've searched through 3 months of my activity and found the list of files deleted.
There is no better way of storing the history of your actions, you can use browser history but what about you deleting it just to clear up cache? What about using a different browser temporarely or using private mode? Taking screenshots saves everything that you've seen be that videos you've watched, things you've read, all commands you've typed and their output, you can even see what music you've listened too. Above all of that you see the whole interface surrounding the said history, so even if things were to dissappear from the web or you don't have internet you can still see them.
Simply it gives you an additional layer of protection against loosing things.
You can analize your life
Once a week i look through screenshots for my past week and look at what i've achieved, what things i've changed and on what i've wasted time.
With this method you have the ability to look back and literally see what went wrong.
And if you go a couple years back and see some random day you will quickly remember your whole day even without seeing it fully, even what you were working on in that week, those images will make you remember everything about that day even if you spend only an hour on the computer. This is how human brain works, it remembers everything but the only way to access it is to look at something you remember about it.
How much storage does it take?
Depends on how much you use your computer, but even with heavy use not much.
My directory of barely 5 years takes 45GB, which is over 80000 files. Each full year weights around 13GB, but as said before it depends on how much you use your computer - I use it a lot.
Overall the space required is small considering how much drive space costs nowadays and how much benefits you have from it.
Setting it up
Here's my cronjob
* * * * * /bin/sh -c 'XAUTHORITY="$HOME/.Xauthority"; export XAUTHORITY; DISPLAY=:0; export DISPLAY; [ "$(xrandr --listactivemonitors | wc -l)" -lt "2" ] && exit; . ${HOME}/.config/vars; xwd -display :0.0 -root | magick xwd:- tiff:- | cwebp -o "$F/shots/$(date +\%Y/\%m/\%d/\%H-\%M).webp" -quiet -q 62 -- -'
And heres it's main part unpacked
XAUTHORITY="$HOME/.Xauthority"
export XAUTHORITY
DISPLAY=:0
export DISPLAY
[ "$(xrandr --listactivemonitors | wc -l)" -lt "2" ] && exit
. ${HOME}/.config/vars
xwd -display :0.0 -root | magick xwd:- tiff:- | cwebp -o "$F/shots/$(date +\%Y/\%m/\%d/\%H-\%M).webp" -quiet -q 62 -- -
It's executed at maximum speed, which is every minute.
You obviously have to change a couple things for yourself like output path, but before you use it make sure you have installed xwd
, imagemagick
and cwebp
.
You might notice the backslashes before percent signs they are necessary as cron has a special syntax for percent signs so they need to be escaped.
The first part of the command checks for active monitors since I ofter turn off the screen on my laptop instead of going into sleep mode, so there is no point in taking screenshots of unchanging screen. Variables are initialized since every thing relying on X11 needs them to work and so does xrandr
.
In ~/.config/vars
I define my env variables for destination so it loads them.
xwd
takes screenshot of the main display in it's own weird format. If you have more than one screen enabled it will append them one to another so everything will be visible. Then it's converted with imagemagick
to tiff
which is lossless format with fast compression and then it's being converted by cwebp
to webp
format.
webp
is the most efficient image format and it matters in this case. cwebp
is a tool specificly designed for webp
so it gives you a lot more options than imagemagick
and so it's my preference, but replace it if you want.
I use lossy compression with not the best quality value to save space, screenshots don't really have to look beautiful they just have to be readable.
I use date command so that each file is in a directory named by year, then named by month, and then named by the day, files are named by the hour and minute e.g. 2025/02/03/19-25.webp
.
Every december i create directory structure for the following year with
mkdir -p 2025/{01..12}/{01..31}
It does not account for months with less days but it doesn't bother me.
I also have a bash binding that automatically opens my file manager on the directory with current day
bind '"\C-gFS": "csas $F/shots/$(date +%Y/%m/%d)\n"'