Skip to content

Commit f98e90c

Browse files
committed
image-app
1 parent db62faf commit f98e90c

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

bin/image-app

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
#
3+
# Switch default image handler between Preview and GIMP
4+
# Usage: image-app [gimp|preview]
5+
# No args or "preview" -> Preview (default)
6+
# "gimp" -> GIMP
7+
8+
set -e
9+
10+
preview="com.apple.Preview"
11+
gimp="org.gimp.gimp-2.10"
12+
13+
# Common image UTIs
14+
image_utis=(
15+
public.png
16+
public.jpeg
17+
public.tiff
18+
public.heic
19+
public.heif
20+
com.compuserve.gif
21+
org.webmproject.webp
22+
com.microsoft.bmp
23+
com.adobe.raw-image
24+
public.camera-raw-image
25+
)
26+
27+
case "${1:-preview}" in
28+
gimp|g)
29+
app=$gimp
30+
app_name="GIMP"
31+
;;
32+
preview|p|"")
33+
app=$preview
34+
app_name="Preview"
35+
;;
36+
*)
37+
echo "Usage: image-app [gimp|preview]"
38+
echo " gimp, g - Set GIMP as default image viewer"
39+
echo " preview, p - Set Preview as default (this is the default)"
40+
exit 1
41+
;;
42+
esac
43+
44+
echo "Setting default image handler to $app_name"
45+
echo "-------------------------------------------"
46+
47+
for uti in "${image_utis[@]}"; do
48+
echo " $uti"
49+
duti -s "$app" "$uti" all 2>/dev/null || true
50+
done
51+
52+
echo ""
53+
echo "Done! $app_name is now the default for images."

0 commit comments

Comments
 (0)