Just use this in a wrapper; this was a bad idea
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
2beb1c0638
commit
c89d90f67c
42
ufw
42
ufw
|
@ -28,10 +28,7 @@ usage() {
|
|||
Usage: ufw [-RsF] [-D num] [file/url]"
|
||||
Flags:
|
||||
-R|--remove-file # Remove the file after uploading.
|
||||
-s|--screenshot # Make a screenshot and upload it instead of a file.
|
||||
-F|--fullscreen # Make a fullscreen shot instead of prompting for a window/area. Implies -s.
|
||||
-d|--description # Supply a description.
|
||||
-D|--screenshot-delay <num> # Delay the shot by <num> seconds.
|
||||
-p|--public # Make the file public.
|
||||
-n|--no-notify # Don't send immediate notifications for this upload.
|
||||
--notify # Force a notification for this upload.
|
||||
|
@ -47,7 +44,6 @@ usage() {
|
|||
|
||||
Config options (~/.config/ufw):
|
||||
secret # Your personal token. Get it at https://zfh.so/settings_form
|
||||
cfg_screenshot_ext # Screenshot file type, used by maim.
|
||||
cfg_max_filesize # Maximum filesize (takes K, M and G suffixes).
|
||||
# Others are self-explanatory:
|
||||
cfg_url_regex
|
||||
|
@ -101,10 +97,6 @@ get_album_id() {
|
|||
upload() {
|
||||
declare api_response api_status api_status_message
|
||||
|
||||
if (( flag_scn )); then
|
||||
flag_rm=1
|
||||
file=$(take_screenshot) || { return 1; }
|
||||
else
|
||||
(( $# )) || {
|
||||
usage
|
||||
return 1
|
||||
|
@ -137,7 +129,6 @@ upload() {
|
|||
return 1
|
||||
}
|
||||
fi
|
||||
fi
|
||||
|
||||
get_file_hash "$file"
|
||||
|
||||
|
@ -206,28 +197,6 @@ get_shortlink() {
|
|||
fi
|
||||
}
|
||||
|
||||
take_screenshot() {
|
||||
declare tmp_file
|
||||
|
||||
[[ "$scn_exec" ]] || { scn_exec=$(type -P maim); }
|
||||
[[ "$scn_exec" ]] || {
|
||||
err "Please install maim to use this function"
|
||||
return 1
|
||||
}
|
||||
|
||||
(( "$flag_scn_fullscreen" )) || { scn_args+=( '-s' ); }
|
||||
[[ "$cfg_scn_delay" ]] && { scn_args+=( "-d" "$cfg_scn_delay" ); }
|
||||
|
||||
tmp_file="$(_mktemp "${cfg_tmp_dir}" ".${cfg_screenshot_ext}")"
|
||||
|
||||
maim "${scn_args[@]}" "$tmp_file" || {
|
||||
err "Failed to take a screenshot."
|
||||
return 1
|
||||
}
|
||||
|
||||
printf '%s\n' "$tmp_file"
|
||||
}
|
||||
|
||||
get_api_status() {
|
||||
read -d '' -r api_status api_status_message < <(
|
||||
jq -r '.status.code, .status.message'
|
||||
|
@ -347,7 +316,7 @@ set_argv() {
|
|||
}
|
||||
|
||||
main() {
|
||||
declare args file target flag_private flag_rm flag_scn flag_scn_fullscreen cfg_scn_delay flag_notify
|
||||
declare args file target flag_private flag_rm flag_notify
|
||||
declare flag_shortlink
|
||||
|
||||
# Defaults for XDG
|
||||
|
@ -379,7 +348,6 @@ main() {
|
|||
: ${cfg_file:="$XDG_CONFIG_DIR/ufw"}
|
||||
: ${cfg_tmp_dir:="$XDG_RUNTIME_DIR/ufw"}
|
||||
: ${cfg_service_url:='https://8fw.me'}
|
||||
: ${cfg_screenshot_ext:='png'}
|
||||
: ${cfg_max_filesize:='200M'}
|
||||
: ${flag_shortlink:=0}
|
||||
: ${flag_directlink:=1}
|
||||
|
@ -387,14 +355,12 @@ main() {
|
|||
while [[ "$1" ]]; do
|
||||
case "$1" in
|
||||
(-h|--help|--usage) usage; return;;
|
||||
(-D|--screenshot-delay) cfg_scn_delay="$2"; shift;;
|
||||
(-m|--max-filesize) cfg_max_filesize=$2; shift;;
|
||||
(-A|--album-name) album_name=$2; shift;;
|
||||
(-t|--tags) tags=$2; shift;;
|
||||
|
||||
(--tmp-dir) cfg_tmp_dir=$2; shift;;
|
||||
(--url) cfg_service_url=$2; shift;;
|
||||
(--screenshot-ext) cfg_screenshot_ext=$2; shift;;
|
||||
(--max-filesize) cfg_max_filesize=$2; shift;;
|
||||
|
||||
(-i|--my-ip) action='getmyip';;
|
||||
|
@ -402,7 +368,6 @@ main() {
|
|||
|
||||
(-p|--public) flag_private='false';;
|
||||
(-R|--remove-file) flag_rm='1';;
|
||||
(-s|--screenshot) flag_scn='1';;
|
||||
(-S|--short-url) flag_shortlink=1;;
|
||||
(-P|--page-url) flag_directlink=0;;
|
||||
(-q|--quiet) flag_quiet=1;;
|
||||
|
@ -411,11 +376,6 @@ main() {
|
|||
(--notify) flag_notify=1;;
|
||||
(--no-notify|-n) flag_notify=0;;
|
||||
|
||||
(-F|--fullscreen)
|
||||
flag_scn='1'
|
||||
flag_scn_fullscreen='1'
|
||||
;;
|
||||
|
||||
(-a|--album-id)
|
||||
misc_curl_args+=( -F "album_id=$2" )
|
||||
shift
|
||||
|
|
Loading…
Reference in New Issue
Block a user