Skip to content

feat: allow configuring archive app#1555

Open
thegabriele97 wants to merge 6 commits into
pop-os:masterfrom
thegabriele97:fix/open_archive
Open

feat: allow configuring archive app#1555
thegabriele97 wants to merge 6 commits into
pop-os:masterfrom
thegabriele97:fix/open_archive

Conversation

@thegabriele97

@thegabriele97 thegabriele97 commented Jan 22, 2026

Copy link
Copy Markdown

Change default behavior when opening archive files

fixes: #1268

Opening an archive should mean looking inside it first — extracting should be an explicit action.

Summary

This PR changes how COSMIC Files opens archive files.

Current behavior:

  • Only archives selected → extraction dialog opens automatically
  • Mixed selection (archive + other files) → archive opens in archive manager

Problem:

  • Users often want to inspect contents before extracting, grab a single file, or check structure/safety
  • Inconsistent UX between single-archive and mixed selections

Proposed behavior:

  • Double-click/open → archives always open in archive manager
  • “Extract To…” remains available via right-click
  • Default action becomes safe, predictable, and consistent
  • If there are no suitable apps, it falls back to the extract_to dialog

Benefits:

  • Non-destructive first action
  • Extraction is explicit
  • Same behavior regardless of selection type
  • Aligns with user expectations and other file managers
  • No functionality removed; extraction still one click away

Conclusion:
Opening an archive now means browsing its contents first; extraction is an explicit, deliberate action.

edit: summarized

@thegabriele97 thegabriele97 force-pushed the fix/open_archive branch 3 times, most recently from 93c1740 to 480374f Compare February 4, 2026 08:28
@jacobgkau jacobgkau requested a review from a team February 4, 2026 22:43

@jacobgkau jacobgkau left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This did get archives to open in File Roller instead of prompting for extraction in COSMIC Files when File Roller was installed (which it is by default in Pop!_OS), but there are a couple of side effects that aren't desirable.

  • When I uninstalled file-roller but happened to have Nautilus installed on the machine, COSMIC Files launched Nautilus when I tried to open the archive file. Nautilus just automatically extracted the file without even prompting-- this is more destructive than COSMIC Files's current behavior, since COSMIC Files prompts to select the extraction destination first.

  • After removing Nautilus, the archive file opened up in Firefox, which just offered to re-save the file (and is not actually able to extract it).

If we want to make this change, we'd probably want to detect if any suitable apps are available to handle the archive, but fall back to our extractor if there aren't any suitable apps, rather than falling back to less suitable apps.

@thegabriele97

thegabriele97 commented Feb 5, 2026

Copy link
Copy Markdown
Author

This did get archives to open in File Roller instead of prompting for extraction in COSMIC Files when File Roller was installed (which it is by default in Pop!_OS), but there are a couple of side effects that aren't desirable.

* When I uninstalled `file-roller` but happened to have Nautilus installed on the machine, COSMIC Files launched Nautilus when I tried to open the archive file. Nautilus just automatically extracted the file without even prompting-- this is more destructive than COSMIC Files's current behavior, since COSMIC Files prompts to select the extraction destination first.

* After removing Nautilus, the archive file opened up in Firefox, which just offered to re-save the file (and is not actually able to extract it).

If we want to make this change, we'd probably want to detect if any suitable apps are available to handle the archive, but fall back to our extractor if there aren't any suitable apps, rather than falling back to less suitable apps.

Hello, thanks for your analysis.

I tried to address your points by adding a new function, is_suitable_archive_app, which checks whether an app is suitable for opening archives by looking at its exposed categories.

On my test system, I had XArchiver, KDE's Ark, GNOME's File Roller, and Nautilus installed. I tested uninstalling them one by one, and in each case the system used the available archiver app. Once no suitable archiver was left, instead of defaulting to Nautilus or Firefox, it correctly fell back to showing the extract_to dialog.

edit: I forgot to mention that If I try to open a txt and a zip without any installed archiver apps, it opens the txt and the extract_to dialog.

edit: I see that if I try to open multiple archive files with the extract_to dialog (no archiver apps installed), cosmic-files crashes. With the "standard" cosmic-files, it extracts only the first one. Is it correct or Am I testing it wrongly? How do we want to handle this here?

@thegabriele97

thegabriele97 commented Feb 5, 2026

Copy link
Copy Markdown
Author

ok I pushed a fix, now ti doesn't crash anymore but it seems like it extracts only the first archive when multiple archive files are opened and there are no suitable apps. It seems like it is a problem with the standard cosmic-files so it should be addressed in a separate PR maybe?

[2026-02-05T11:29:58Z DEBUG cosmic_files::app] Attempting to launch app
        for: application/zip
        with: ["/home/user/flameshot-13.3.0-1.ubuntu-24.04.amd64.zip"]
[2026-02-05T11:29:58Z DEBUG cosmic_files::app] Checking app org.gnome.Nautilus for archive support
[2026-02-05T11:29:58Z INFO  cosmic_files::app] No suitable archive app found for MIME application/zip. Falling back to extract_to.
[2026-02-05T11:29:58Z DEBUG cosmic_files::app] Attempting to launch app
        for: application/x-compressed-tar
        with: ["/home/user/io.github.cosmic_utils.cosmic-ext-applet-clipboard-manager-db.tgz"]
[2026-02-05T11:29:58Z DEBUG cosmic_files::app] Checking app org.gnome.Nautilus for archive support
[2026-02-05T11:29:58Z INFO  cosmic_files::app] No suitable archive app found for MIME application/x-compressed-tar. Falling back to extract_to.
[2026-02-05T11:29:58Z DEBUG cosmic_files::app] Paths to extract with dialog: ["/home/user/flameshot-13.3.0-1.ubuntu-24.04.amd64.zip", "/home/user/io.github.cosmic_utils.cosmic-ext-applet-clipboard-manager-db.tgz"]

edit: tests performed until now (checked means ok)

  • Open a single archive when an external archive app is installed → opens with the app.
  • Open a single archive when no external archive app is installed → shows “Extract To…” dialog.
  • Select a mix of files with external archive app (single archive + non-archive) → archive open with external app if available, other files open normally.
  • Select multiple archives with external archive app installed → all archives open in the app (verify all are handled).
  • Select multiple archives without any external archive app → “Extract To…” dialog appears
  • Select a mix of files with no external app (multiple archive + non-archive) → extract_to dialog + other files open normally.
  • Test partial installations of archive apps → correct app is chosen according to MIME type priorities.
  • Confirm that normal file behavior (rename, move, open with other apps) is unaffected by the PR changes.

@jacobgkau jacobgkau left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for shaping that up a little bit!

Our UX team noticed this PR (I would've needed to request review from them anyway once this was working) and let me know that they aren't favorable towards this solution-- they don't think users generally want to see what's in archives before extracting them. However, they do think there should be a way to configure archives to open in another app if you'd prefer.

What they're asking for is a solution where a default application for archives is listed in Settings -> Default Applications. The default (at least in Pop!_OS) should be COSMIC Files Extract to..., as it currently is; COSMIC Files Extract (for Nautilus's behavior of extracting to the current directory without prompting), along with any other archive apps, should also be listed. This would keep the default behavior as it currently is, but allow you to set e.g. File Roller as the default if you'd prefer to always browse archives first.

In order to do this, I think we'd need to add action stanzas within the COSMIC Files .desktop file (if not other .desktop files for these other actions), so the Extract and Extract to... options in the right-click menu can be exposed as apps in the Default Applications Settings page.

I understand this is slightly beyond the scope of what you were trying to do. Let me know if you'd still like to attempt it.

@thegabriele97

thegabriele97 commented Feb 6, 2026

Copy link
Copy Markdown
Author

Thanks for shaping that up a little bit!

Our UX team noticed this PR (I would've needed to request review from them anyway once this was working) and let me know that they aren't favorable towards this solution-- they don't think users generally want to see what's in archives before extracting them. However, they do think there should be a way to configure archives to open in another app if you'd prefer.

What they're asking for is a solution where a default application for archives is listed in Settings -> Default Applications. The default (at least in Pop!_OS) should be COSMIC Files Extract to..., as it currently is; COSMIC Files Extract (for Nautilus's behavior of extracting to the current directory without prompting), along with any other archive apps, should also be listed. This would keep the default behavior as it currently is, but allow you to set e.g. File Roller as the default if you'd prefer to always browse archives first.

In order to do this, I think we'd need to add action stanzas within the COSMIC Files .desktop file (if not other .desktop files for these other actions), so the Extract and Extract to... options in the right-click menu can be exposed as apps in the Default Applications Settings page.

I understand this is slightly beyond the scope of what you were trying to do. Let me know if you'd still like to attempt it.

Yes, what you’re proposing makes perfect sense.

Adding Desktop Actions (Extract, Extract To…) to expose them as separate apps in Settings can technically work, but it has some UX issues:

  1. The actions end up appearing in the app launcher, which can confuse users.
  2. Creating a separate .desktop file for each action would make the app list in Settings long and unclear.

For these reasons, it’s probably not the ideal solution.

The approach I suggest is:

  • setting Cosmic Files as the default application for all archive types,
  • showing the “Extract To…” dialog only when the user opens the archive from within the app,
  • automatically extracting the archive if it’s opened externally (e.g., from Firefox or via xdg-open) like nautilus does

It is much simpler and more user-friendly i believe.

Main advantages

  • Users don’t have to distinguish between different actions in Settings.
  • All archive formats can be handled with a single .desktop file.
  • The experience remains consistent whether opening files inside or outside the app.
  • It avoids unnecessarily complicating the Default Applications page.

good:
image

bad:
image

@thegabriele97

thegabriele97 commented Feb 6, 2026

Copy link
Copy Markdown
Author

This is a preview of how it could be.

2026-02-06.11-57-43.mp4

Still didn't push the last modifications I made in cosmic-files to record the video.

This is independent from cosmic-settings and fully testable using xdg-mime query and xdg-mime default.

@jacobgkau

jacobgkau commented Feb 12, 2026

Copy link
Copy Markdown
Member

The UX team still wants it the way they've described. Some of our engineers say adding NoDisplay=true to the new actions in the .desktop file will allow the new actions to still show up in COSMIC Settings while avoiding showing up in the app launcher. Can you please try doing that, and push the commit so we can check it out?

@thegabriele97

thegabriele97 commented Feb 13, 2026

Copy link
Copy Markdown
Author

Sure, pushed.
The commit you see supports setting Cosmic Files as the default app, as shown in the video, and the .desktop file includes the new actions you asked for.

I’m not sure if I did something wrong, but the actions still appear in the launcher even with NoDisplay=true.

Moreover, with the current cosmic-settings implementation, I only see "cosmic-files" in general and not its actions. It probably needs a better implementation — I just duplicated the ones used for other file types, which work with the app_id and don’t search for sub desktop actions.

edit: I’ve pushed the changes to my branch in cosmic-settings: https://github.com/thegabriele97/cosmic-settings/tree/feat_default_archive_app. I’m not sure if you’d like a PR for this — I can open a draft if that helps.

Comment thread src/mime_app.rs Outdated
@thegabriele97 thegabriele97 force-pushed the fix/open_archive branch 4 times, most recently from 27b8ebc to 9932d35 Compare February 18, 2026 09:25
@jackpot51 jackpot51 requested a review from jacobgkau February 18, 2026 16:32
@thegabriele97

Copy link
Copy Markdown
Author

The fact that it only extracts one file seems to be an issue not caused by me (I initially thought it was my fault). #1600

@jacobgkau

Copy link
Copy Markdown
Member

@thegabriele97 Please do open a pull request with your cosmic-settings branch as well. It will help us keep the required work organized.

For now, I'm pushing your branch to the same internal testing-cosmic-files-pr1555 branch this PR's on for testing.

@thegabriele97

Copy link
Copy Markdown
Author

@thegabriele97 Please do open a pull request with your cosmic-settings branch as well. It will help us keep the required work organized.

For now, I'm pushing your branch to the same internal testing-cosmic-files-pr1555 branch this PR's on for testing.

sure, done. pop-os/cosmic-settings#1860

Do I need to fix the CI? I actually forgot to run desktop-file-validate

@jacobgkau

Copy link
Copy Markdown
Member

Do I need to fix the CI? I actually forgot to run desktop-file-validate

It would be good if any CI checks that are passing on master also pass in the branch. It looks like Validate .desktop files is working on that branch now.

@jacobgkau jacobgkau left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With 9f62db1 here and 5892e6b in pop-os/cosmic-settings#1860, I'm seeing archives open in File Roller even with COSMIC Files selected in Default Applications (I tried changing the setting to File Roller and then back to COSMIC Files, with no effect):

2026-02-19.16-57-09.mp4

@thegabriele97

Copy link
Copy Markdown
Author

With 9f62db1 here and 5892e6b in pop-os/cosmic-settings#1860, I'm seeing archives open in File Roller even with COSMIC Files selected in Default Applications (I tried changing the setting to File Roller and then back to COSMIC Files, with no effect):
2026-02-19.16-57-09.mp4

Mmmh can you try with a different file? Like a zip file. I think it's due to a missing mime type

@jacobgkau

Copy link
Copy Markdown
Member

I just tried downloading a ZIP file, and am seeing the same behavior with that (File Roller opening even though the default application is set to COSMIC Files in COSMIC Settings).

@thegabriele97

Copy link
Copy Markdown
Author

I just tried downloading a ZIP file, and am seeing the same behavior with that (File Roller opening even though the default application is set to COSMIC Files in COSMIC Settings).

Hi, sorry for the delay.

I just checked — you need to close and reopen Cosmic Files every time you make a change. It works like other categories, such as Photos.

@jacobgkau jacobgkau left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had some time to look at this again. Here's where we stand with this PR:

  • The .desktop file lint is failing because the spec doesn't allow NoDisplay under individual actions. We can't simply ignore the lint because other distros have their own lints in packaging that would break if we did that. Moreover, the spec states "applications must only include actions that make sense as general launchers," so adding actions that would need to be hidden from the Applications menu wouldn't be the right approach, anyway.
    • Possible solutions I can think of would be using actions but implementing some kind of file-open GUI for them when launching without a filename (so they'd function if invoked from the Applications menu), or ditching the actions and instead special-casing the COSMIC Files options into COSMIC Settings.
  • I'm still only getting a single COSMIC Files entry as a default application in Settings. So if we do stick with actions, Settings will need changing to support actions. (This could get messy with third-party apps' actions, so maybe it's not the best approach.)

All of that said, switching between COSMIC Files and other apps as the default does work as long as I restart COSMIC Files after changing the setting, as you pointed out.

Seeing as the current default behavior when double-clicking archives in COSMIC Files is the Extract to... dialog, and there's already no way to configure that, I think we could decouple the addition of allowing the direct Extract option as a default, and focus only on making the app itself configurable for now. So get rid of the actions from the .desktop file, and just make sure COSMIC Files is the default app by default, and that we show the Extract to... dialog when double-clicking archives (as we already do now) when that's the case.

@thegabriele97

Copy link
Copy Markdown
Author

Had some time to look at this again. Here's where we stand with this PR:
...........

Hello, thanks for the review, seems fine for me.

I can do the work in about 10 days as I am not at home right now.

@jacobgkau

Copy link
Copy Markdown
Member

I'm confirming with our UX team whether this solution will be acceptable for the time being, so I'll let you know before you get started on it. It looks like it might be simple enough to pare back what you've already done, so I might take a crack at it myself in the meantime as well.

@thegabriele97

Copy link
Copy Markdown
Author

I'm confirming with our UX team whether this solution will be acceptable for the time being, so I'll let you know before you get started on it. It looks like it might be simple enough to pare back what you've already done, so I might take a crack at it myself in the meantime as well.

Fine, thanks. Yes it should be simple enough to adapt the PR as you described as far I remember

@jacobgkau jacobgkau changed the title feat: open archives with external app by default feat: allow configuring archive app Apr 7, 2026
@jacobgkau

jacobgkau commented Apr 7, 2026

Copy link
Copy Markdown
Member

Reviewed the corresponding COSMIC Settings PR: pop-os/cosmic-settings#1860 (review)

The sole remaining problem with this is that, on upgrade, Settings shows COSMIC Files as the default application, but both Firefox and COSMIC Files actually treat File Roller as the default. If I change the default application to File Roller and then back to COSMIC Files, then they respect COSMIC Files as the default. The desync needs to be fixed and the default needs to actually be COSMIC Files on upgrade.

I'd assume there's some kind of implicit default (or lack thereof) tripping this up.

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.

[Bug] Open with default program seemingly ignored

3 participants