Allow for browser program to contain arguments
This specifically fixes opening firefox in a flatpak, where previously fenen would error if the browser option was set to something like: flatpak run org.mozilla.firefox This fix also makes the "program not found" error more user friendly and allows fenen to keep running even if the browser program was not found.
This commit is contained in:
parent
e1c34dc059
commit
bbda9b9ed9
29
fenen.py
29
fenen.py
|
@ -225,21 +225,24 @@ def get_url(index):
|
|||
|
||||
|
||||
def open_in_browser(indices=None):
|
||||
if not indices:
|
||||
subprocess.Popen(
|
||||
[conf.get_value("browser"), ui.data["post_url"]], stdout=subprocess.DEVNULL
|
||||
browser = conf.get_value("browser").split(" ")
|
||||
try:
|
||||
if not indices:
|
||||
subprocess.Popen(browser + [ui.data["post_url"]], stdout=subprocess.DEVNULL)
|
||||
return
|
||||
indices = interpret_range(indices)
|
||||
for i in indices:
|
||||
url = get_url(i)
|
||||
if url:
|
||||
subprocess.Popen(browser + [url], stdout=subprocess.DEVNULL)
|
||||
sleep(0.1) # Wait a bit so the browser opens URLs in the correct order
|
||||
else:
|
||||
print(f"Entry {i + 1} has no associated URL.")
|
||||
except FileNotFoundError:
|
||||
print(
|
||||
f"Error opening browser: could not find the program '{' '.join(browser)}'."
|
||||
)
|
||||
return
|
||||
indices = interpret_range(indices)
|
||||
for i in indices:
|
||||
url = get_url(i)
|
||||
if url:
|
||||
subprocess.Popen(
|
||||
[conf.get_value("browser"), url], stdout=subprocess.DEVNULL
|
||||
)
|
||||
sleep(0.1) # Wait a bit so the browser opens URLs in the correct order
|
||||
else:
|
||||
print(f"Entry {i + 1} has no associated URL.")
|
||||
|
||||
|
||||
def download_entry(indices=None):
|
||||
|
|
Loading…
Reference in New Issue