I need to programatically "Show in Directory" a file (or another directory, but that's less important).
I intend to copy the feature from browsers that allows the user to click a button to open the file manager in the Downloads directory, but with the downloaded file selected in the view.
I have looked at
xdg-open but it doesn't seem to be able to do this (in my opinion, a crucial design flaw, since it aims for compatibility).
My current approach for Windows and Macintosh looks like this.
def show_file(path): if sys.platform == "darwin": subprocess.check_call(["open", "--reveal", path]) elif sys.platform == "linux": pass elif sys.platform == "win32": subprocess.check_call(["explorer", "/select", path])
Is there no other alternative to manually creating a table of all of the commands for the most popular Linux file managers?
I can use
nautilus --select [path], but what about others?
How does Chromium do it? And where is that code?