Skip to content

Commit b7314f1

Browse files
authored
Merge pull request #9601 from keymanapp/fix/linux/9600_snapFirefox
fix(linux): Correctly open files linked from help page
2 parents 82d15b6 + b764a1c commit b7314f1

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

linux/keyman-config/keyman_config/welcome.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/python3
22

33
import logging
4+
import os
45
import webbrowser
56

67
import gi
@@ -55,17 +56,25 @@ def __init__(self, parent, welcomeurl, keyboardname, newlyInstalled=False):
5556
def doc_policy(self, web_view, decision, decision_type):
5657
logging.info("Checking policy")
5758
logging.debug("received policy decision request of type: {0}".format(decision_type.value_name))
58-
if decision_type == WebKit2.PolicyDecisionType.NAVIGATION_ACTION or \
59-
decision_type == WebKit2.PolicyDecisionType.NEW_WINDOW_ACTION:
59+
if decision_type in [
60+
WebKit2.PolicyDecisionType.NAVIGATION_ACTION,
61+
WebKit2.PolicyDecisionType.NEW_WINDOW_ACTION,
62+
]:
6063
nav_action = decision.get_navigation_action()
6164
request = nav_action.get_request()
6265
uri = request.get_uri()
6366
logging.debug("nav request is for uri %s", uri)
64-
if "welcome.htm" not in uri:
65-
logging.debug("opening uri %s in webbrowser")
67+
if not uri.startswith("file://"):
68+
logging.debug("opening external uri %s in webbrowser", uri)
6669
webbrowser.open(uri)
6770
decision.ignore()
6871
return True
72+
elif ".htm" not in uri:
73+
cmd = f'xdg-open {uri}'
74+
logging.debug('opening uri in default app: %s', cmd)
75+
os.system(cmd)
76+
decision.ignore()
77+
return True
6978
return False
7079

7180
def on_openweb_clicked(self, button):

0 commit comments

Comments
 (0)