I have a script which takes a screenshot using import from imagemagick. It's able to shot whole root window or currently focused window. That depends on the only one argument
At the top of the script there are to variables which control its behaviour. The SCREEN_DIR is a directory where you want to save your screenshots. And the SCREEN_PROMPT defines whether you want to be prompted for name of screenshot by i3-input. If you don't then this variable must not be set at all.
You can export these variables from your startup scripts to have settings separated from script itself.
The screenshot is saved in SCREEN_DIR under name in format NAME-YEAR-MONTH-DAY_HOUR-MIN-SEC.png where NAME is string typed in to the i3-input. If prompt is disabled or empty string is given then WM_CLASS of window is used or just "window" if WM_CLASS is not set. In case of root window screenshot NAME is "root".
And finally symlink named 'last' pointing to last taken screenshot is created for easier lookup.
case $1 in
window=`xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" | cut -d' ' -f5`;;
[ ! -z "$SCREEN_PROMPT" ] && \
name=`i3-input -P 'screen-name: ' | sed -n '/command = /s/command = //p'`
if [ -z "$name" ];then
if [ $window == "root" ];then
name=`xprop -id $window | sed -n '/WM_CLASS/s/.* = "\([^\"]*\)".*/\1\n/p'`
[ -z "$name" ] && name='window'
import -border -window $window "$SCREEN_DIR/$filename"
ln -sf "$filename" $SCREEN_DIR/last
In i3 config just create simple binding.
bindsym Print exec screen.sh root
bindsym Mod1+Print exec screen.sh active
Note that if you take second screenshot during single second the previous one taken in that same second gets overwritten since there is no check for this case. So if you like to use printscreen to make movies you should check for this.