Created
September 28, 2013 01:56
-
-
Save gdhaworth/6737571 to your computer and use it in GitHub Desktop.
Automatically open a screenshot for viewing after it is taken and delete after it is closed. Requires inotify-tools. This is written and tested on Gnome with Shotwell, probably can be adapted to other systems by changing the screenshot filename pattern (line 16) and the photo viewing application (line 18).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ -z "$1" ]]; then | |
_monitor_dir="$HOME/Pictures" | |
else | |
_monitor_dir="$1" | |
fi | |
if [[ ! -d "${_monitor_dir}" ]]; then | |
echo "Can't find directory '${_monitor_dir}', does it exist?" | |
exit 1 | |
fi | |
inotifywait -m -e create --format '%f' "${_monitor_dir}" \ | |
| while read file; do | |
if [[ "$file" = Screenshot\ from\ * ]]; then | |
echo "File created: '$file'" | |
shotwell "${_monitor_dir}/$file" | |
rm -f "${_monitor_dir}/$file" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment