dotfiles/.bin/sshot
2023-08-03 08:23:24 +02:00

52 lines
880 B
Bash
Executable File

#!/bin/sh -e
. ${HOME}/.bin/_config
#
# SIGNAL HANDLER
#
trap cleanup 1 2 3 6
cleanup() {
rm -f "${_file_tmp}";
notify-send "sshot: Aborted..."
}
#
# CONFIGURATION
#
_filename="$(date "+%Y-%m-%d_%H-%M-%S")-sshot.png"
_file_dir="${HOME}/Downloads/Screenshots"
mkdir -p "$_file_dir"
#
# TAKE SCREENSHOT
#
flameshot gui -p "${_file_dir}/${_filename}"
test -f "${_file_dir}/${_filename}" || exit 1
pngcrush -reduce "${_file_dir}/${_filename}"
#
# UPLOAD
#
scp "${_file_dir}/${_filename}" sdk@home.codevoid.de:web/static/paste/
#
# BUILD WEBSITE
#
ssh home.codevoid.de "cd web && make update && make"
#
# COPY TO CLIPBOARD
#
printf '%s' "https://home.codevoid.de/paste/${_filename}" | xclip
#
# PRINT TO STDOUT
#
echo "https://home.codevoid.de/paste/${_filename}"
echo "${_file_dir}/${_filename}"
#
# NOTIFY
#
notify-send "https://home.codevoid.de/paste/${_filename}"