Shell extension: How to open URL

I’m trying to open an URL in the default browser from my gnome shell extension, and am doing that with GLib.spawn_async:

GLib.spawn_async(                                  
    null,                                          
    ['/usr/bin/xdg-open', 'http://localhost:5666'],
    null, 0, null                                  
);                                                 

Is this the correct way?
I’m unsure because I have to specify the full path to xdg-open, otherwise I get a spawn error (along the lines of “child process could not be executed: File or directory not found”)

Gio.AppInfo.launch_default_for_uri("http://localhost:5666", null);
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.