Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve %filemanager macro, to allow focusing the file-in-question #220

Closed
stdedos opened this issue Aug 12, 2023 · 2 comments
Closed

Improve %filemanager macro, to allow focusing the file-in-question #220

stdedos opened this issue Aug 12, 2023 · 2 comments

Comments

@stdedos
Copy link

stdedos commented Aug 12, 2023

In Ubuntu 20.04, it is possible to query the default file manager like so:

$ xdg-mime query default inode/directory
nemo.desktop

then, launching it is as simple as

$ gtk-launch `xdg-mime query default inode/directory`

and focusing a file is:

$ gtk-launch `xdg-mime query default inode/directory` '/path/to/file'

Somehow, even though here it says

qdirstat/README.md

Lines 645 to 646 in 8174478

- %filemanager : File manager application of the current desktop; one of
"konqueror", "nautilus", "thunar", "pcmanfm". The fallback is "xdg-open".

the nautilus I have (but barely use) is not picked up.

Then, the default action (except probably xdg-open) can be changed to %filemanager %p & and the file manager will open and be focused.

@shundhammer
Copy link
Owner

shundhammer commented Aug 12, 2023

That makes a number of assumptions that may work in some scenarios, but not in others:

  • xdg-mime is installed and configured correctly.
  • gtk-launch is installed and configured correctly.

While this probably works on a default GNOME or Xfce4 installation, it may not work at all or only partially on KDE Plasma or on other, more exotic desktops.

Also, it needs several indirections before the interesting thing is started: Your file manager.

In a real-world setup, it would have to do that xdg-mime query default inode/directory the first time that %filemanager macro is used and - importantly - log the result to give the user a fighting chance to do something in case it didn't work as expected.

Using %p instead of %d again makes an assumption: That the file manager that was picked up actually behaves like you described, to set the keyboard focus in the newly opened window to that file, and not simply execute it instead (if it is an executable) or start the associated application if it's a known MIME type that has one.

I'd really hate to get LibreOffice started with a spreadsheet or a text document that I had selected when I just want to open a file manager there.

@shundhammer
Copy link
Owner

If you know that this works in your environment, you are free to change the command line for the "Open File Manager here" cleanup action in the "Cleanup Actions" configuration dialog to the one you proposed here.

But I don't think that would be a good default for all users.

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

No branches or pull requests

2 participants