[Gambas-user] Get the default file manager

Gianluigi gradobag at gradobag.it
Sun Feb 18 14:41:19 CET 2024


Il 18/02/24 13:33, BB ha scritto:
> (I suppose you guys do realise that there is no such thing as a
> default file manager, or a default any application, in linux. Even the
> so-called default file manager for a desktop is a furphy.)
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----

Right, so something like this should work?

Public Sub Main()

   Dim sApp, s, sFM As String
   Dim aFM As String[] = ["konqueror", "nautilus", "dolphin", "mc",
"krusader", "pcmanfm-qt", "pcmanfm", "xfe", "nemo", "thunar", "spacefm",
"caja", "ranger", "deepin", "polo", "cfiles", "emacs", "vifm", "worker",
"nnn", "wcm", "4panel", "lf", "jfileprocessor", "qtfm", "fman", "ytree",
"liri", "pantheon", "doublecmd"]

   Shell "xdg-mime query default inode/directory" To sApp  ' Get
.desktop file name of filemanager launcher.
   Print sApp
   For Each s In aFM
     If InStr(sApp, s, 0, gb.IgnoreCase) > 0 Then
       sFM = s
       Break
     Endif
   Next
   If sFM Then
     Shell sFM
   Else
     Message.Warning("Unable to access the file manager")
   Endif

End

Regards
Gianluigi



More information about the User mailing list