2 #**********************************************************************
3 # Copyright (C) 2023 - The Geeqie Team
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #**********************************************************************
23 ## @brief Download full and minimal AppImages from the Continuous build release on GitHub.
24 ## Optionally extract the full size AppImage.
26 ## Downloads are made to $HOME/bin.
27 ## It is expected that $HOME/bin exists and that it is in $PATH.
29 ## Downloads will not be made unless the server version is newer than the local file.
37 printf "Download the latest Geeqie AppImages from the
38 Continuous Build release on GitHub.
40 -b --backups <n> Set number of backups (default is 3)
41 -d --desktop Install desktop icon and menu item
42 -e --extract Extract AppImage
43 -h --help Display this message
44 -m --minimal Download minimal version of AppImage
45 -r --revert <n> Revert to downloaded AppImage backup. For the latest version set <n> to 0
46 -v --version Display version of this file
48 The Continuous Build release is updated each
49 time the source code is updated.
51 The default action is to download an AppImage to
52 \$HOME/bin. A symbolic link will be set so that
53 \"geeqie\" points to the executable
55 No downloads will be made unless the file on the
56 server at GitHub is newer than the local file.
58 The full size AppImage is about 120MB and the
59 minimal AppImage is about 10MB. Therefore the full
60 size version will load much slower and will have
61 a slightly slower run speed.
63 However the minimal version has limited capabilities
64 compared to the full size version.
66 The minimal option (-m or --minimal) will download
69 The extract option (-e or --extract) will extract
70 The contents of the AppImage into a sub-directory
71 of \$HOME/bin, and then set the symbolic link to the
74 This will take up some disk space, but the
75 extracted executable will run as fast as a
82 printf "Version: %s\n" "$version"
88 character_count=$((${#message} + 4))
93 while kill -0 "$pid" 2> /dev/null
96 printf "$message [%c]" "$spinstr"
97 spinstr=$temp${spinstr%"$temp"}
99 printf "%$character_count""s" | tr " " "\b"
135 printf '"--backups" requires a non-empty option argument.\n' >&2
147 printf '"--revert" requires a non-empty option argument.\n' >&2
158 --) # End of all options.
163 printf 'Unknown option %s\n' "$1" >&2
175 if [ ! -d "$HOME/bin" ]
177 printf "\$HOME/bin does not exist.
178 It is required for this script to run.
179 Also, \$HOME/bin should be in \$PATH.\n"
184 if [ "$backups_option" -eq 1 ] && {
185 [ "$minimal" = "-minimal" ] || [ "$extract" -eq 1 ] || [ "$revert_option" -eq 1 ]
188 printf "backups must be the only option\n"
193 if [ "$desktop" -eq 1 ] && {
194 [ "$minimal" = "-minimal" ] || [ "$extract" -eq 1 ]
197 printf "desktop must be the only option\n"
202 if [ "$backups_option" -eq 1 ]
204 if ! [ "$backups" -gt 0 ] 2> /dev/null
206 printf "%s is not an integer\n" "$backups"
210 tmp_file=$(mktemp "${TMPDIR:-/tmp}/geeqie.XXXXXXXXXX")
212 sed --in-place "s/^backups=.*/backups=$backups/" "$tmp_file"
220 if [ "$desktop" -eq 1 ]
222 if [ -f "$HOME/Desktop/org.geeqie.Geeqie.desktop" ]
224 printf "Desktop file already exists\n"
229 file_count=$(find "$HOME/bin/" -name "Geeqie*latest*\.AppImage" -print | wc -l)
230 if [ "$file_count" -eq 0 ]
232 printf "No AppImages have been downloaded\n"
237 tmp_dir=$(mktemp --directory "${TMPDIR:-/tmp}/geeqie.XXXXXXXXXX")
238 cd "$tmp_dir" || exit 1
240 app=$(find "$HOME/bin/" -name "Geeqie*latest*\.AppImage" -print | sort --reverse | head -1)
241 $app --appimage-extract "usr/local/share/applications/org.geeqie.Geeqie.desktop" > /dev/null
242 $app --appimage-extract "usr/local/share/pixmaps/geeqie.png" > /dev/null
243 xdg-desktop-icon install --novendor "squashfs-root/usr/local/share/applications/org.geeqie.Geeqie.desktop"
244 xdg-icon-resource install --novendor --size 48 "squashfs-root/usr/local/share/pixmaps/geeqie.png"
245 xdg-desktop-menu install --novendor "squashfs-root/usr/local/share/applications/org.geeqie.Geeqie.desktop"
246 rm --recursive --force "$tmp_dir"
251 # The cd needs to be here because the --backups option needs PWD
252 cd "$HOME/bin/" || exit 1
254 if [ "$revert_option" -eq 1 ]
256 if ! [ "$revert" -ge 0 ] 2> /dev/null
258 printf "%s is not an integer\n" "$revert"
262 if [ "$revert" -eq 0 ]
270 if ! [ -f "$HOME/bin/Geeqie$minimal-latest-$architecture.AppImage$revert" ]
272 printf "Backup $HOME/bin/Geeqie%s-latest-$architecture.AppImage%s does not exist\n" "$minimal" "$revert"
277 if [ "$extract" -eq 1 ]
279 rm --recursive --force "Geeqie$minimal-latest-$architecture-AppImage"
280 mkdir "Geeqie$minimal-latest-$architecture-AppImage"
281 cd "Geeqie$minimal-latest-$architecture-AppImage" || exit 1
283 (../Geeqie-latest-x86_64.AppImage --appimage-extract > /dev/null) & spinner "Extracting Geeqie AppImage..."
285 printf "\nExtraction complete\n"
288 ln --symbolic --force "./Geeqie$minimal-latest-$architecture-AppImage/squashfs-root/AppRun" geeqie
290 ln --symbolic --force "$HOME/bin/Geeqie$minimal-latest-$architecture.AppImage$revert" geeqie
296 log_file=$(mktemp "${TMPDIR:-/tmp}/geeqie.XXXXXXXXXX")
298 wget --no-verbose --show-progress --backups="$backups" --output-file="$log_file" --timestamping "https://github.com/BestImageViewer/geeqie/releases/download/continuous/Geeqie$minimal-latest-$architecture.AppImage"
300 download_size=$(stat --printf "%s" "$log_file")
303 # If a new file was downloaded, check if extraction is required
304 if [ "$download_size" -gt 0 ]
306 chmod +x "Geeqie$minimal-latest-$architecture.AppImage"
308 if [ "$extract" -eq 1 ]
310 rm --recursive --force "Geeqie$minimal-latest-$architecture-AppImage"
311 mkdir "Geeqie$minimal-latest-$architecture-AppImage"
312 cd "Geeqie$minimal-latest-$architecture-AppImage" || exit 1
314 (../Geeqie-latest-x86_64.AppImage --appimage-extract > /dev/null) & spinner "Extracting Geeqie AppImage..."
316 printf "\nExtraction complete\n"
319 ln --symbolic --force "./Geeqie$minimal-latest-$architecture-AppImage/squashfs-root/AppRun" geeqie
321 ln --symbolic --force "Geeqie$minimal-latest-$architecture.AppImage" geeqie