#!/bin/bash filename1="$MY_SCREENSHOTS_DIR/$(date +%Y-%m-%d--%H-%M-%S)_" filename2="$(xdotool getactivewindow getwindowname | sed -r 's/[^a-zA-Z0-9\-]+/_/g')" #get the title of the window, and replace non alphanumerics with '_' filename3='.png' scrot "${filename1}${filename2}${filename3}" -u xclip -r -selection clipboard <<<"$HOME${filename1}${filename2}${filename3}"