[Gambas-user] Get the default file manager

Gianluigi gradobag at gradobag.it
Sat Feb 17 18:12:02 CET 2024


Il 17/02/24 17:08, Bruce Steers ha scritto:
>
>     Hi Martin,
>     I apologize in the suggestion there is an error, the space after
>     the hyphen.
>     For multiple strings you need curly brackets:
>
>     Public Sub Main()
>
>        Dim sApp, s As String
>
>        Shell "xdg-mime query default inode/directory" To sApp  ' Get
>     .desktop file name of filemanager launcher.
>        s = Scan(sApp, "*{.,-, }*")[0]
>        Print s
>
>     End
>
>     Regards
>     Gianluigi
>
>
>
> But that's risky.
> It just checks the first word of the name of the launcher used to run
> the file manager.
> There is no guarantee the first word of the name of the .desktop file
> given by xdg-mime is the command to launch the program.
>
> I guess it depends on the needs. I guess.
>
> To be most correct you should probably use DesktopFile.class as that
> designed for .desktop files then you can access various bits of
> information about it..
>
> Dim sDFile As String
> Shell "echo -n $(xdg-mime query default inode/directory)" To sDFile  '
> Note: echo -n $() trick to omit trailing LF
>
> Dim hDF As DesktopFile = New DesktopFile("/usr/share/applications" &/
> sDFile)  ' get file as a DesktopFile object
>
> Print hDF.ProgramName  ' the actual definitive program command
> Print hDF.Exec ' the complete command string used to launch it
> Print hDF.Name ' just it's name (probably with capital letter)
>
> But i now think none of this is your solution as i mentioned in the
> last post about fixing your desktop configuration.
>
> But it did raise a valid issue.
>
> Why does DesktopMime return nothing for inode/directory ?
>
> Well wishes
> BruceS

Hi,
I was referring to this question from Martin: "how can I get the name of
the default application that manages the files? in my case it is Thunar
because I use XFCE but what is the general way?", and I think the code
passed is correct.
At least with the file managers I have on VBox, it works correctly :-\

Regards
Gianluigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20240217/1e412450/attachment-0001.htm>


More information about the User mailing list