2022-12-07 10:39:14 +01:00
|
|
|
#!/bin/sh
|
|
|
|
# C-x + ?-?
|
|
|
|
|
2022-12-23 09:36:12 +01:00
|
|
|
set -x
|
|
|
|
|
2022-12-07 10:39:14 +01:00
|
|
|
copy_to_clipboard() {
|
|
|
|
printf '%s\n' "Clipping $1"
|
|
|
|
printf '%s' "$(readlink -f "$1")" \
|
|
|
|
| xclip -selection clipboard
|
|
|
|
}
|
|
|
|
|
|
|
|
upload_to_paste() {
|
|
|
|
printf '%s\n' "Pasting $1"
|
|
|
|
scp "$1" sdk@codevoid.de:/home/www/htdocs/gopher/p/
|
|
|
|
printf '%s' "https://codevoid.de/I/p/${1##*/}" \
|
|
|
|
| xclip -selection clipboard
|
|
|
|
}
|
|
|
|
|
|
|
|
save_image() {
|
|
|
|
if [ -z "$SXIVDIR" ]
|
|
|
|
then
|
|
|
|
. $HOME/.bin/_config
|
|
|
|
SXIVDIR="$(find . -type d -maxdepth 1 | dmenu -p "Save" $DMENUOPTS)"
|
|
|
|
export SXIVDIR;
|
|
|
|
fi
|
|
|
|
printf '%s\n' "Saving $1 to $SXIVDIR/"
|
|
|
|
mkdir -p "$SXIVDIR"
|
|
|
|
mv "$1" "$SXIVDIR/"
|
|
|
|
|
|
|
|
base="${1%.*}"
|
|
|
|
for type in cr2 CR2 orf ORF dng DNG tif TIF xmp XMP
|
|
|
|
do
|
|
|
|
test -f "${base}.${type}" && mv "${base}.${type}" "$SXIVDIR/"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
edit_image() {
|
|
|
|
base=${1%.*}
|
|
|
|
for type in cr2 CR2 orf ORF dng DNG
|
|
|
|
do
|
|
|
|
printf "Trying %s.%s\n" "${base}" "${type}"
|
|
|
|
if [ -f "${base}.${type}" ]
|
|
|
|
then
|
|
|
|
rawtherapee "${base}.${type}"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
for type in tif TIF
|
|
|
|
do
|
|
|
|
printf "Trying %s.%s\n" "${base}" "${type}"
|
|
|
|
if [ -f "${base}.${type}" ]
|
|
|
|
then
|
|
|
|
gimp "${base}.${type}"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
rotate_cw() {
|
|
|
|
printf '%s\n' "Rotating CW"
|
|
|
|
convert -rotate 90 "$1" "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
rotate_ccw() {
|
|
|
|
printf '%s\n' "Rotating CCW"
|
|
|
|
convert -rotate 270 "$1" "$1"
|
|
|
|
}
|
|
|
|
|
2022-12-23 19:19:15 +01:00
|
|
|
show_details() {
|
|
|
|
echo "$1"
|
|
|
|
exiftool "$1" | grep Date | tr ':' '-'
|
|
|
|
}
|
|
|
|
|
2022-12-07 10:39:14 +01:00
|
|
|
while read file
|
|
|
|
do
|
|
|
|
case "$1" in
|
2022-12-23 19:19:15 +01:00
|
|
|
"e") edit_image "$file" ;;
|
2022-12-07 10:39:14 +01:00
|
|
|
"c") copy_to_clipboard "$file" ;;
|
2022-12-23 19:19:15 +01:00
|
|
|
"p") echo "$(readlink -f "$file")" ;;
|
2022-12-07 10:39:14 +01:00
|
|
|
"u") upload_to_paste "$file" ;;
|
|
|
|
"x") save_image "$file" ;;
|
2022-12-23 19:19:15 +01:00
|
|
|
"s") show_details "$file" ;;
|
|
|
|
"w") texec "website-add-image-to-gallery $file" ;;
|
2022-12-07 10:39:14 +01:00
|
|
|
"Right") rotate_cw "$file" ;;
|
|
|
|
"Left") rotate_ccw "$file" ;;
|
|
|
|
esac
|
|
|
|
done
|