Found an old script that can make video intro with arbitrary text(?)
[einar-bin] / screenshot.sh
1 #!/bin/bash
2 # A quick and dirty script to take a screenshot, upload it via scp
3 # and put a link to it in the clipboard for easy pasting to i.e. IRC.
4 # It assumes a lot of things, e.g. that ssh to the target host has
5 # been set up with a working private key, and that xclip and
6 # gnome-screenshot is installed.
7 #
8 # If all you have is a hammer, everything looks like a nail.
9
10 # Settings
11 RemoteUser="einar"
12 RemoteHost="wowbagger.slaskete.net"
13 RemotePath="/var/www/eina.rjh.im/screenshots/"
14 LocalPath="${HOME}/Pictures/Screenshots/"
15 UrlBase="https://eina.rjh.im/g"
16
17 function errcho() {
18 >&2 echo -e "$@"
19 }
20
21 function take_screenshot() {
22 FileID="$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 6 | head -n 1)"
23 FileName="${FileID}.png"
24 if [ "$*" = "clipboard" ] || [ "$*" = "jpg" ]; then
25 xclip -out -selection clipboard -t image/png > "/tmp/${FileName}" 2>/dev/null
26 if [ "$(file -b --mime-type "/tmp/${FileName}")" == "image/png" ]; then
27 if [ "$*" = "jpg" ]; then
28 convert "/tmp/${FileName}" "/tmp/${FileID}.jpg"
29 rm "/tmp/${FileName}"
30 FileName="${FileID}.jpg"
31 fi
32 mv "/tmp/${FileName}" "${LocalPath}/"
33 else
34 rm "/tmp/${FileName}"
35 notify-send -i applets-screenshooter "screenshot.sh" "Tried to post image from clipboard, but found no image there."
36 fi
37 else
38 gnome-screenshot -f "${LocalPath}/${FileName}" -p "$@"
39 fi
40 if [ -f "${LocalPath}/${FileName}" ]; then
41 scp -q "${LocalPath}/${FileName}" "${RemoteUser}@${RemoteHost}:${RemotePath}"
42 echo -n "${UrlBase}/${FileName}"|xclip -selection p
43 echo -n "${UrlBase}/${FileName}"|xclip -selection c
44 notify-send -i applets-screenshooter "screenshot.sh" "Screenshot published to ${UrlBase}/${FileName}"
45 fi
46 }
47
48 function show_error() {
49 errcho "Please use one of: -w, --window, -a, --area, -s, --selection,"
50 errcho " -f, --full or no argument at all."
51 exit 1
52 }
53
54 case ${1} in
55 -w|--window)
56 take_screenshot -w -b -e shadow
57 ;;
58 -a|--area|-s|--selection)
59 sleep 0.2
60 take_screenshot -a
61 ;;
62 ""|-f|--full)
63 take_screenshot
64 ;;
65 -c|--clipboard|-p|--paste)
66 take_screenshot clipboard
67 ;;
68 -j|--jpg)
69 take_screenshot jpg
70 ;;
71 *)
72 show_error
73 ;;
74 esac
75