Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re^2: Open a folder

by jerre_111 (Sexton)
on Mar 21, 2013 at 12:01 UTC ( #1024727=note: print w/replies, xml ) Need Help??

in reply to Re: Open a folder
in thread Open a folder

Yes, I mean a file manager like that, I'm using the "thunar" file manager.

But if i call them with "system()", I guess that on another pc without Thunar, nothing will happen? or worst case an error will appear?

I don't want a file selector thank you. To say it in "windows words", I want to open explorer at the position where my new image is located.

I already have the Path where the new image is located from a dialog box off getSaveFile(). So I want to say, open explorer at that path. But then in unix except windows.

Replies are listed 'Best First'.
Re^3: Open a folder
by marto (Bishop) on Mar 21, 2013 at 12:14 UTC

    So if you were using MS Windows I'd advise you to use something like start $directory, where $directory is the path you wish to open. Now depending on your window manager the equivalent method could be many things, for example for xfce xdg-open $directory, gnome-open $directory, kde-open $directory and so on. So you're going to have to figure out the details of the end user platform (unless this is for a specific target that you know about), and cater for each accordingly.

    Update: you may want to play around with the following basic example:

    #!/usr/bin/perl use strict; use warnings; my $wm = $ENV{'XDG_CURRENT_DESKTOP'}; print "Window Manager: $wm"; # later on, call specific system command for the running window manage +r

      I'm using kde on opensuse and xdg-open works even in kde. So it might just suffice to check for availability of any of the mentioned programs and call it irrespective of the window manager actually running. It would probably be a 99% solution

        Thanks for the info. I guess it depends on the system in question, perhaps they're lucky and only have to target a specific setup. Failing that I updated my reply with an example of pulling the running window manager from the environment variable, then it's simply a case of catering for each valid response.

Re^3: Open a folder
by jethro (Monsignor) on Mar 21, 2013 at 12:21 UTC

    So your problem is to find a suitable file manager on any linux box.

    It seems xdg-open will do what you want. On my machine it opens dolphin if I call "xdg-open ."

    There also might be methods to find standard applications in window managers like gnome or kde, but I'm just guessing. Probably they just use xdg-open too

    If nothing works you could have a list of filemanagers in your script that you simply check if they are installed.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1024727]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2017-05-26 00:57 GMT
Find Nodes?
    Voting Booth?