Created
July 18, 2016 06:38
-
-
Save ryot4/b939fe4931caa40a12fda1ca24b6b636 to your computer and use it in GitHub Desktop.
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/sh | |
screenshot_root=~/Pictures/screenshot | |
viewer='xdg-open' | |
while getopts 'd:n:v' opt; do | |
case "$opt" in | |
d) dir="$OPTARG" ;; | |
n) name="$OPTARG" ;; | |
v) scrot_execute="$viewer \$f" | |
esac | |
done | |
shift $((OPTIND - 1)) | |
scrot_options='-z' | |
case "$1" in | |
active) scrot_options="$scrot_options -u" ;; | |
select) scrot_options="$scrot_options -s" ;; | |
root|*) ;; | |
esac | |
if [ -n "$dir" ]; then | |
screenshot_root="$dir" | |
dir='' | |
else | |
dir=$(date +'%Y/%m/%d') | |
fi | |
: ${name:=$(date +'%H%M%S.png')} | |
mkdir -p "$screenshot_root/$dir" | |
scrot $scrot_options "$screenshot_root/$dir/$name" -e "${scrot_execute:-:}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment