Untested changes! Woo!
This commit is contained in:
parent
b27907f12a
commit
80ae0480b3
21
sup
21
sup
|
@ -58,9 +58,7 @@ sup.scrot() {
|
|||
[[ "$flag_scrot_fullscreen" ]] || { scrot_args+=( '-s' ); }
|
||||
[[ "$cfg_scrot_delay" ]] && { scrot_args+=( "-d $cfg_scrot_delay" ); }
|
||||
|
||||
until [[ ! -e "${cfg_tmp_dir}/${tmp_file_name}" ]]; do
|
||||
tmp_file_name="${RANDOM}${RANDOM}.${cfg_screenshot_ext}"
|
||||
done
|
||||
tmp_file_name="$(sup.mktemp "${cfg_tmp_dir}" "${cfg_screenshot_ext}")"
|
||||
|
||||
scrot "${scrot_args[@]}" "${cfg_tmp_dir}/$tmp_file_name" || {
|
||||
sup.err "Failed to take a screenshot."
|
||||
|
@ -77,6 +75,21 @@ sup.exclude() {
|
|||
|
||||
sup.if_url() { echo "$1" | grep -oE "$cfg_url_regex" &>/dev/null; }
|
||||
|
||||
sup.mktemp() {
|
||||
local tmp_file_name tmp_file_name_extra="$2" tmp_dir="$1"
|
||||
|
||||
[[ -d "$tmp_dir" ]] || {
|
||||
sup.err "${tmp_dir} does not exist or is not a directory."
|
||||
return 1
|
||||
}
|
||||
|
||||
until [[ ! -e "${tmp_dir}/${tmp_file_name}" ]]; do
|
||||
tmp_file_name="${RANDOM}${RANDOM}${tmp_file_name_extra}"
|
||||
done
|
||||
|
||||
echo "${tmp_dir}/${tmp_file_name}"
|
||||
}
|
||||
|
||||
main() {
|
||||
while [[ "$1" ]]; do
|
||||
case "$1" in
|
||||
|
@ -104,7 +117,7 @@ main() {
|
|||
target="${args[0]}"; [[ "$target" ]] || { sup.usage; exit 1; }
|
||||
|
||||
sup.if_url "$target" && {
|
||||
file=`mktemp "$cfg_tmp_dir/sup_tmp_XXXXXX"`
|
||||
file=`sup.mktemp "$cfg_tmp_dir"`
|
||||
|
||||
curl -s "$target" > "$file" || {
|
||||
sup.err "Could not download file."
|
||||
|
|
Loading…
Reference in New Issue
Block a user