Skip to content

Instantly share code, notes, and snippets.

@iakat
Last active March 23, 2024 10:50
Show Gist options
  • Save iakat/e22a63597496c5e0e83d9dc4cb96a7b4 to your computer and use it in GitHub Desktop.
Save iakat/e22a63597496c5e0e83d9dc4cb96a7b4 to your computer and use it in GitHub Desktop.
sshot
#!/usr/bin/env bash
set -ex
# https://creativecommons.org/public-domain/cc0/
# sshot - screenshot and upload to rclone remote
# made by katia
# This script takes 2 arguemnts
# 1. rclone remote
# 2. url prefix
# Requirements
# 1. spectacle - https://github.com/KDE/spectacle
# 2. rclone - https://github.com/rclone/rclone
# 3. pwgen - https://github.com/tytso/pwgen
# 4. wl-clipboard - https://github.com/bugaevc/wl-clipboard
# 5. paplay - https://github.com/pulseaudio/pulseaudio
# 6. pngcrush - https://github.com/Kjuly/pngcrush
# error if n of args is not 2
if [ "$#" -ne 2 ]; then
echo "Illegal number of parameters"
exit 1
fi
RCLONE_REMOTE="$1"
URL_PREFIX="$2"
mkdir -p "$HOME/.cache/screenshot"
FILENAME="$(date +%Y%m%d)_$(pwgen -s 18 1).png"
TMPFILE="$HOME/.cache/screenshot/$FILENAME"
spectacle --nonotify fullscreen --output $TMPFILE
pngcrush -brute -rem alla -rem text -ow "$TMPFILE"
rclone copyto "$TMPFILE" "$RCLONE_REMOTE/$FILENAME"
rm "$TMPFILE"
printf "$URL_PREFIX/$FILENAME" | wl-copy
notify-send "Screenshot uploaded" "Link copied to clipboard" --icon=dialog-information
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment