diff options
| author | Suleyman Farajli <suleyman@farajli.net> | 2025-10-26 22:23:31 +0400 |
|---|---|---|
| committer | Suleyman Farajli <suleyman@farajli.net> | 2025-10-26 22:23:31 +0400 |
| commit | cb78290f31886fb1f9a5e7c2a764dda55a459e50 (patch) | |
| tree | 72a2df0645405658d8590d4b8d7d87f1e099f596 /scripts/gui/shot | |
| parent | f8d1bfbd0f27e0763cf75fcda58d010e346515ab (diff) | |
chore: split script installation into CLI and GUI sections
Diffstat (limited to 'scripts/gui/shot')
| -rwxr-xr-x | scripts/gui/shot | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/scripts/gui/shot b/scripts/gui/shot new file mode 100755 index 0000000..7404943 --- /dev/null +++ b/scripts/gui/shot @@ -0,0 +1,56 @@ +#!/bin/sh + +. slib + +help() { +cat << EOF +${0}: Wrapper script to take screenshots +options: + -d [File] Write to File + -s Select the area with the cursor + -h Print this message and exit + +NOTE: save directory is ~/pics/screenshot +EOF + +exit 0 +} + +check_program "scrot" + +default_dir="${HOME}"/pics/screenshot + +s_flg="" +while getopts "d:sh" option; do + case "${option}" in + d) input="${OPTARG}" ;; + + s) s_flg="1" ;; + + h) help ;; + + *) invalid_use -h ;; + + esac +done + +shift $((OPTIND - 1)) + +[ ${#} != 0 ] && invalid_use + +[ -z "${input}" ] && input="${default_dir}" + +outfile="${input}" + +[ -d "${input}" ] && outfile="${input}/$(date '+%b%d::%H%M%S').png" + +if [ ! -e "$(dirname "${outfile}")" ]; then + mkdir -p "$(dirname "${outfile}")" > /dev/null 2>&1 \ + || err "Failed to create directory" +fi + +if [ "${s_flg}" = "1" ]; then + run "scrot -zs ${outfile}" "${outfile}" +else + run "scrot -z ${outfile}" "${outfile}" +fi |
