Add install script with GIMP version detection - #232
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
- 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/
command -v only writes to stdout, so 2>&1 is not needed.
Query gimp for config directory. Install PhotoGIMP to gimp's registered config dir.
gabrielalmir
left a comment
There was a problem hiding this comment.
Hi @StarlitLuna, thanks for continuing the work from #190 and for taking the previous feedback into account. Querying GIMP directly for its config directory looks like a good improvement, especially across different packaging methods.
I noticed a few cases that should be fixed before merging:
- The script should confirm that the detected installation is actually GIMP 3.x. Right now,
gimpor the installed Flatpak could still point to GIMP 2.10, and the script would copy GIMP 3 configuration files into that profile. - It should stop if GIMP is already running, since GIMP may overwrite the configuration when it exits or the installer may modify the profile while it is still in use.
- If both Flatpak and native versions are installed, it would be better to ask which installation should be used instead of always preferring Flatpak.
- A short README section explaining how to run the installer and where the backup is created would also help users.
The general direction looks good. Once these cases are addressed, I think the installer will be in good shape for approval. Thanks again for working on this!
Add a gimp is running check.
|
@gabrielalmir Addressed your feedback in the latest commits:
Edit: |
|
Hello. Author of #190 here. For context: the changes for the review were finished. I just wasn't confident enough in them to publish :-) And I think querying gimp-directory directly is a good move. Two things from testing it: Your version of GIMP 2.10 is not supported. Reproduced with stubs on PATH, gimp reporting 2.10.36 and gimp-3.0 reporting 3.0.4. With gimp removed the same script completes normally. Continuing the loop instead of returning when the detected version is below 3.0 would reach the versioned binary as intended. Second: pgrep -x "$GIMP_COMMAND" matches the name from command -v, usually gimp. The distro desktop entry launches the versioned binary (Exec=gimp-2.10 %U here), and a process is named after the name it was invoked with, not the symlink target. So GIMP started from the menu isn't matched and the guard passes. |
I moved
I'm not able to reproduce this. I installed a gimp rpm, ran it from my desktop menu and the pgrep command detected that gimp was running. |
gabrielalmir
left a comment
There was a problem hiding this comment.
Hi @StarlitLuna, thanks for addressing the previous feedback. The version check, the installation selection when both native and Flatpak versions are available, and moving the generic gimp command to the end of the detection order are good improvements.
I tested the native and Flatpak installation paths with stubbed commands. The basic installation works, but I found a few cases that should be fixed before merging:
- The restore command only copies the backup over the current configuration. Files added by PhotoGIMP that were not present in the backup remain in the profile, so it does not fully restore the previous state. It may be safer to move the current configuration aside and then recreate it from the backup.
- For Flatpak installations, the script overwrites
~/.local/share/applications/org.gimp.GIMP.desktop, but this file is not included in the backup. An existing launcher or user customization would be lost. The installer should either back it up or install a separate PhotoGIMP desktop file. - The native process check is still not reliable across packaging methods.
pgrep -x "$GIMP_COMMAND"may look forgimpwhile the actual process is namedgimp-3.0or another versioned name. Also, ifpgrepis unavailable, the installer currently prints an error but continues as if GIMP were not running.
It would also be good to use ${XDG_DATA_HOME:-$HOME/.local/share} for the desktop and icon destinations, but I think that and the README update can be handled as follow-up improvements.
The general direction still looks good. Once the restore behavior, launcher backup, and native process detection are addressed, I think the PR will be ready for another pass. Thanks again for working on this!
Check for any arbitrarily running gimp. Backup icons and launcher files as well.
|
Hi @gabrielalmir in order of appearance:
I also made these changes:
|
|
@gabrielalmir any update on this? I'd like to close this out. |
gabrielalmir
left a comment
There was a problem hiding this comment.
Hi @StarlitLuna, thanks for addressing the previous feedback and for your patience while I reviewed the latest changes.
The updated native detection, running-process checks, and backup handling resolve the main concerns from my previous reviews. The installer is now in good shape, and I’m approving the PR.
There is still a possible edge case when identically named GIMP binaries exist in multiple directories in PATH: the script scans a full path but later invokes the selected binary by name. If this becomes relevant in practice, we can improve it in a follow-up by retaining and invoking the full binary path. I don’t consider this necessary to block the current PR.
Thanks again for continuing the work from #190 and seeing this through!
This PR is a sort of continuation of #190 because it seems that one never got any changes to address PR feedback.
I based this branch off of the one by @oxidworks and iterated on it by:
detecting whether flatpak is installed first (and prefer the flatpak version) then fall back for native detection.
If gimp is installed, then we query gimp itself to ask for the registered config directory. This has the added side effect that the query itself counts as a first run of GIMP if it has never been run, so this technically eliminates the need for the user to run GIMP first before installing PhotoGIMP if installed through the installer.
I tested this on a fresh install of gimp via a devcontainer.
Another improvement this adds is that technically the flatpak and native install can share the same config directory (confirmed on fedora 44 at least) so it didn't seem ideal to me to rely on assumptions about the flatpak config being in
~/.varwhich was not true for me for example.I also modified the installer to only install the flatpak launcher and icons if we are installing to the flatpak version.
@gabrielalmir I think this approach resolves your review feedback items in #190. For the 3rd, I removed the version thing from gimp-3.0 so that it launches without specifying a specific minor version which works for me I think this is what you meant.
closes #166 closes #181