git.slaskete.net
/
einar-bin
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
d84ef06
)
Add support for uploading clipboard image as jpeg
author
Einar Jørgen Haraldseid
<einar@haraldseid.net>
Tue, 16 Mar 2021 11:58:43 +0000
(12:58 +0100)
committer
Einar Jørgen Haraldseid
<einar@haraldseid.net>
Tue, 16 Mar 2021 11:58:43 +0000
(12:58 +0100)
screenshot.sh
patch
|
blob
|
history
diff --git
a/screenshot.sh
b/screenshot.sh
index 842ff348b2a035c9e6305a22e205cc18afee4ac3..d9205477e96a7612ad3b190b0f7443cbe15a26ca 100755
(executable)
--- a/
screenshot.sh
+++ b/
screenshot.sh
@@
-11,7
+11,7
@@
RemoteUser="einar"
RemoteHost="wowbagger.slaskete.net"
RemotePath="/var/www/eina.rjh.im/screenshots/"
RemoteUser="einar"
RemoteHost="wowbagger.slaskete.net"
RemotePath="/var/www/eina.rjh.im/screenshots/"
-LocalPath="${HOME}/
ownCloud
/Screenshots/"
+LocalPath="${HOME}/
Pictures
/Screenshots/"
UrlBase="https://eina.rjh.im/g"
function errcho() {
UrlBase="https://eina.rjh.im/g"
function errcho() {
@@
-19,10
+19,16
@@
function errcho() {
}
function take_screenshot() {
}
function take_screenshot() {
- FileName="$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 6 | head -n 1).png"
- if [ "$*" = "clipboard" ]; then
+ FileID="$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 6 | head -n 1)"
+ FileName="${FileID}.png"
+ if [ "$*" = "clipboard" ] || [ "$*" = "jpg" ]; then
xclip -out -selection clipboard -t image/png > "/tmp/${FileName}" 2>/dev/null
if [ "$(file -b --mime-type "/tmp/${FileName}")" == "image/png" ]; then
xclip -out -selection clipboard -t image/png > "/tmp/${FileName}" 2>/dev/null
if [ "$(file -b --mime-type "/tmp/${FileName}")" == "image/png" ]; then
+ if [ "$*" = "jpg" ]; then
+ convert "/tmp/${FileName}" "/tmp/${FileID}.jpg"
+ rm "/tmp/${FileName}"
+ FileName="${FileID}.jpg"
+ fi
mv "/tmp/${FileName}" "${LocalPath}/"
else
rm "/tmp/${FileName}"
mv "/tmp/${FileName}" "${LocalPath}/"
else
rm "/tmp/${FileName}"
@@
-59,6
+65,9
@@
case ${1} in
-c|--clipboard|-p|--paste)
take_screenshot clipboard
;;
-c|--clipboard|-p|--paste)
take_screenshot clipboard
;;
+ -j|--jpg)
+ take_screenshot jpg
+ ;;
*)
show_error
;;
*)
show_error
;;