Add install script with GIMP version detection#190
Conversation
The current installation method requires users to manually extract files into ~/.config/GIMP/3.0/. When GIMP updates to 3.2+, the config directory changes (e.g. ~/.config/GIMP/3.2/) and PhotoGIMP stops working. The .desktop file also has a hardcoded StartupWMClass=gimp-3.0. This install script: - Detects the active GIMP config directory (3.0, 3.2, etc.) - Creates an automatic backup before overwriting - Adjusts StartupWMClass in the .desktop file to match - Works with native packages, Flatpak, and AppImage Fixes Diolinux#166, fixes Diolinux#181
|
Hi. Line 13: It only works when GIMP uses The following script |
|
Thanks for the feedback! Both points are addressed in the latest commit:
|
|
When you let Sure, |
|
Simplified the regex to GIMP always creates its config folder as uppercase Your review made me look at the script more carefully. Found a few more problems:
|
- Simplify regex (GIMP dir already in search base) - Replace GNU-only grep -oP and sort -V with POSIX equivalents - Prevent set -e crash when grep finds no version match - Search Flatpak config path ~/.var/app/org.gimp.GIMP/config/GIMP/
Do you need it? But nevertheless, I think, to be compatible with as many unixy operating systems, the script should be POSIX-compliant anyway. |
No problem. Just prepare the cases where needed. We fill the gaps later. |
|
Thanks for you comment, yes, pipefail is bash-only and not needed here. Dropped it, switched to set -eu. Also replaced &>/dev/null with >/dev/null 2>&1. For BSD: leaving the uname cases in place so the structure is ready. |
|
|
You're right, |
command -v only writes to stdout, so 2>&1 is not needed.
|
just did a quick test of this install script in my old Ubuntu 24.04 with gimp 3.2, after copy didn't work (of course). No errors, looked good. Didn't do much testing though. I think the idea is great. Script looks good. |
|
|
||
| # Fallback: try to get version from gimp binary | ||
| local version | ||
| for cmd in gimp gimp-3.2 gimp-3.0; do |
There was a problem hiding this comment.
Maybe the literal gimp command with the version number (e.g. gimp-3.2) shouldn't be hardcoded.
If the goal's to get it straight from the binaries, then future versions should be acccounted for, otherwise the same issue of updating the script will keep coming up.
Perhaps the hardcoded gimp-3.2 and gimp-3.0 should be removed altogether as I'm not sure anybody's going to have an installation, where gimp-3.2 or gimp-3.0 work but gimp doesn't.
If there's a reason to keep those numbered versions, then I suggest defining a global variable like MAJOR_VERSION=3, and then using a POSIX compliant function to run down the $PATH and find all possible commands for this major version (and also remove all duplicate finds, as I've had those show up on my system):
GIMP_MAJOR_VERSION=3
get_gimp_binaries_from_path() {
OLD_IFS=$IFS
IFS=:
(
for dir in $PATH; do
[ -d "$dir" ] || continue
for f in "$dir"/gimp*; do
[ -f "$f" ] || continue
[ -x "$f" ] || continue
bin=$(basename -- "$f")
case "$bin" in
gimp | gimp-$GIMP_MAJOR_VERSION*)
printf '%s\n' "$bin"
;;
esac
done
done
) | sort -u
IFS=$OLD_IFS
}|
Thanks for the read. You're right that the version list is hardcoded. I left it in as a small safety net for systems where only a versioned binary like gimp-3.0 is on PATH (some older RPM-based distros, custom builds). That fallback path is mostly defensive though: if no GIMP config directory exists yet, the script exits below with a "start GIMP once" message anyway. I'm happy to refactor along your lines if @Diolinux wants to broaden the scope. My intent with this PR was a minimal, low-risk fix for #166 / #181. |
|
this is not needed, the user will know (because gimp will appear entirely fucked up). Simply update the installer to not version the .desktop |
Problem
PhotoGIMP config is hardcoded to
~/.config/GIMP/3.0/. When GIMP updates to 3.2, it looks in~/.config/GIMP/3.2/and the PhotoGIMP layout is gone. The.desktopfile hasStartupWMClass=gimp-3.0which also breaks.This comes up in #166 and #181 - and it will happen again with every GIMP minor version bump.
Solution
A simple
install.shthat:3.xfolder)StartupWMClassin the.desktopfile to match the installed versionUsage:
git clone https://github.com/Diolinux/PhotoGIMP.git cd PhotoGIMP ./install.shFixes #166, fixes #181