简体   繁体   中英

Change default browser linux - Python

i want to change the default browser in ubuntu and the open a url

What is tried:

def makedefault():
    subprocess.call(('xdg-settings set default-web-browser google-chrome.desktop')
    webbrowser.get().open('http://google.com')

but it is launcing the url in firefox. Thanks for the help.

Btw when i run xgd command in terminal it changed the default url

You can use google-chrome command to open a particular url in chrome via subprocess

google-chrome www.google.com

Note: If google-chrome is not in your PATH variable, use absolute path or add the path to PATH variable

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM