Skip to content

Conversation

@nununoisy
Copy link

A quick addition that enables Resources to pick up the correct data for AppImages managed by appimaged.

appimaged is the official AppImage management daemon, and it has some neat functionality like automatically registering installed AppImages, automatically updating supported AppImages, and integrations with Firejail. To do so, it needs to know when AppImages are launched, so it injects itself into the Exec field in the generated desktop files which causes Resources to mistakenly associate every AppImage process with whichever generated desktop file it finds first.

The PR does the following:

  • Adds process_data::Containerization::AppImage.
  • Automatically detects AppImage processes by checking for the APPIMAGE environment variable.
  • Automatically detects AppImage desktop files by checking for the X-AppImage-Identifier key (part of appimaged and libappimage).
  • Correctly fetches the executable path from the X-ExecLocation key created by appimaged when present.

I realize that parsing the entire environment to determine if a process is an AppImage is somewhat expensive but it seems to be the only 100% robust way to verify (since they can be renamed to remove the .AppImage suffix and the cmdline doesn't reference appimaged at all). If you think that there's a better way to do this then I'm open to suggestions, but it doesn't seem to significantly increase the CPU utilization on my system so I think it's fine.

@nununoisy
Copy link
Author

For reference, here's a generated desktop file for Obsidian with my home dir replaced with ~:

[Desktop Entry]
Name=Obsidian
Exec=~/.local/bin/appimaged-907-x86_64.AppImage wrap "~/.local/bin/Obsidian-1.10.3.AppImage" --no-sandbox %U
Terminal=false
Type=Application
Icon=~/.cache/thumbnails/normal/8d0ca0bc33aae207a6f19140a9091abc.png
StartupWMClass=obsidian
X-AppImage-Version=1.10.3
Comment=~/.local/bin/Obsidian-1.10.3.AppImage
MimeType=x-scheme-handler/obsidian;
Categories=Office;
X-ExecLocation=~/.local/bin/Obsidian-1.10.3.AppImage
TryExec=~/.local/bin/appimaged-907-x86_64.AppImage
X-AppImage-Identifier=8d0ca0bc33aae207a6f19140a9091abc
Actions=Trash;OpenPortableHome;CreatePortableHome;Extract;Show

[Desktop Action Trash]
Name=Move to Trash
Exec=gio trash "~/.local/bin/Obsidian-1.10.3.AppImage"

[Desktop Action OpenPortableHome]
Name=Open Portable Home in File Manager
Exec=xdg-open "~/.local/bin/Obsidian-1.10.3.AppImage.home"

[Desktop Action CreatePortableHome]
Name=Create Portable Home
Exec=mkdir -p "~/.local/bin/Obsidian-1.10.3.AppImage.home"

[Desktop Action Extract]
Name=Extract to AppDir
Exec=bash -c "cd '~/.local/bin' && '~/.local/bin/Obsidian-1.10.3.AppImage' --appimage-extract && xdg-open '~/.local/bin/squashfs-root'"

[Desktop Action Show]
Name=Open Containing Folder
Exec=xdg-open "~/.local/bin"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant