Standard way to open folder window on Linux?

I want to open a folder window in the appropriate file manager from a cross-platform (windows / mac / linux) Python application.

In OSX, I can open a window in finder with

os.system('open "%s"' % foldername) 

and on windows with

 os.startfile(foldername) 

What about unix / linux? Is there a standard way to do this or do I have a special case of gnome / kde / etc and manually launch the corresponding application (nautilus / konqueror / etc)?

This is similar to what people can point out to freedesktop.org (a python module similar to webbrowser will be nice too!).

+7
python linux cross-platform desktop
source share
3 answers
 os.system('xdg-open "%s"' % foldername) 

xdg-open can be used for files / urls as well

+9
source share

this will probably need to be done manually or as a configuration item, as there are many file managers that users may want to use. Providing options for command options.

There may be a function that runs the default values ​​for kde or gnome in its respective toolboxes, but I had no reason to look for them.

0
source share

You will need to do this based on a working window manager. OSX and Windows have a standard (defacto) standard way because there is only one choice.

You do not need to specify the exact filemanager application, however it should be possible to do this through wm. I know that Gnome does this, and it is important to do this in KDE, since there are two possible file managers (Konqueror / Dolphin) that can be used.

I agree that it would be good for freedesktop.org to standardize, although I doubt it will happen if someone does not get up and achieve it.


EDIT: I did not know about xdg-open. Good to know!

0
source share

All Articles