Ubuntu 20.04: Screenshot to a Custom Save Location (Dropbox)

Isshiki🐈
2 min readOct 15, 2020

--

There are many other ways to do this but I want a more portable solution, so I wrote myself this shell script.

#!/bin/bash# filename format, man date for more information
NAME="$(date -Iseconds)"
# save location
touch ~/Dropbox/ScreenShots/$NAME;
if [[ $# -eq 0 ]]
then
# man gnome-screenshot for more detail
gnome-screenshot -f ~/Dropbox/ScreenShots/$NAME
elif [[ $1 == window ]]
then
gnome-screenshot -w -f ~/Dropbox/ScreenShots/$NAME
elif [[ $1 == select ]]
then
gnome-screenshot -a -f ~/Dropbox/ScreenShots/$NAME
fi

Just like the system itself behind the scene, this script uses gnome-screen to capture screenshots. You can take screenshots already by running this script and perhaps passing the argument you like (either select or window).

To make things cleaner, we can make this script executable and make a symbolic link under /usr/bin

chmod +x screenshot.sh# give it a less common name to avoid conflict
# change the path to your own
sudo ln -s /home/your_name/screenshot.sh /usr/bin/a_new_name

[Optional] Disable existing keyboard shortcuts in Settings

And add new keyboard shortcuts from the bottom of the page

Setup three shortcuts to run the script.

// first shortcut: fullscreen screenshot
[name] ...
[command] name_of_the_script
[shortcut] ...
// second shortcut: for a selected area
[name] ...
[command] name_of_the_script select
[shortcut] ...
// third shortcut: for the current active/focused window
[name] ...
[command] name_of_the_script window
[shortcut] ...

That’s it. Now whenever you use these shortcuts, screenshots will go to the directory you just specify. If you use a symbolic link, whenever you edit your source file, the executable file under /usr/bin will also be modified.

--

--

Isshiki🐈
Isshiki🐈

No responses yet