xdg-open not open default browser

前端 未结 2 2118
醉梦人生
醉梦人生 2021-02-20 03:44

I have the following scenario: Ubuntu 16.04 machine with firefox and chrome installed, chrome being my default browser.

I check this actions in the shell :



        
2条回答
  •  误落风尘
    2021-02-20 04:04

    To set a default browser, make sure that a .desktop file exists for your preferred browser. I'll be setting Mozilla Iceweasel for this example:

    $ ls /usr/share/applications/iceweasel.desktop
    iceweasel.desktop
    

    Assured you have the file, run:

    $ xdg-settings set default-web-browser iceweasel.desktop
    # Test that it works
    $ xdg-open "http://example.com"
    

    If you don't have a .desktop file:

    I use the program surf, which doesn't have a .desktop file. To set this as your web browser, first create the file ~/.local/share/applications/surf.desktop with this following content:

    [Desktop Entry]
    Type=Application
    Name=surf
    Comment=Surf minimal web browser
    Terminal=false
    Exec=surf
    Categories=Network;WebBrowser
    

    While not all of this content is required, it helps categorize the file for any future use.

    Set the default browser like normal:

    $ xdg-settings set default-web-browser surf.desktop
    

    And now you're good to go!

提交回复
热议问题