-
Notifications
You must be signed in to change notification settings - Fork 21
/
thunar-convert-to-jpg.sh
executable file
·74 lines (66 loc) · 1.16 KB
/
thunar-convert-to-jpg.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/sh
#
# Convert an image file to a jpg file.
#
# * Put this file into your home binary dir: ~/bin/
# * Make it executable: chmod +x
#
#
# Required Software:
# -------------------------
# * convert
#
#
# Thunar Integration
# ------------------------
#
# Command: ~/bin/thunar-convert-to-jpg.sh -f %f
# File Pattern: *
# Appear On: Image Files
#
#
# Usage:
# -------------------------
# thunar-convert-to-jpg.sh -f <filename>
#
# required:
# -f input filename
#
# Note:
# -------------------------
#
# Feel free to adjust/improve and commit back to:
# https://github.com/cytopia/thunar-custom-actions
#
usage() {
echo "$0 -f <filename>"
echo
echo " required:"
echo " -f input filename"
echo
}
while getopts ":f:" i; do
case "${i}" in
f)
f=${OPTARG}
;;
*)
echo "Error - unrecognized option $1" 1>&2
usage
;;
esac
done
shift $((OPTIND-1))
# Check if file is specified
if [ -z "${f}" ]; then
echo "Error - no file specified" 1>&2
usage
exit 1
fi
# Check if convert exists
if ! command -v convert >/dev/null 2>&1 ; then
echo "Error - 'convert' not found." 1>&2
exit 1
fi
$(which convert) "${f}" "${f}.jpg"
exit $?