Skip to content

Commit

Permalink
implemented preference setting to launch app in Edge browser
Browse files Browse the repository at this point in the history
  • Loading branch information
tappi287 committed Jul 3, 2023
1 parent ac27c38 commit 20bb037
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
13 changes: 9 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,17 @@ def start_eel(npm_serve=True):
eel.init('web')

# TODO: fetch OSError port in use
edge_cmd = f"{os.path.expandvars('%PROGRAMFILES(x86)%')}\\Microsoft\\Edge\\Application\\msedge.exe"
start_url = f'http://{host}:{url_port}'

try:
eel.start(page, host=host, port=port, block=False, close_callback=close_callback)
app_module_prefs = getattr(AppSettings, 'app_preferences', dict()).get('appModules', list())
if Path(edge_cmd).exists() and 'edge_preferred' in app_module_prefs:
eel.start(page, mode='custom', host=host, port=port, block=False,
cmdline_args=[edge_cmd, '--profile-directory=Default', f'--app={start_url}'])
else:
eel.start(page, host=host, port=port, block=False, close_callback=close_callback)
except EnvironmentError:
start_url = f'http://{host}:{url_port}'
edge_cmd = f"{os.path.expandvars('%PROGRAMFILES(x86)%')}\\Microsoft\\Edge\\Application\\msedge.exe"

# If Chrome isn't found, fallback to Microsoft Chromium Edge
if Path(edge_cmd).exists():
logging.info('Falling back to Edge Browser')
Expand Down
7 changes: 5 additions & 2 deletions vue/src/components/pages/PreferencesPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
<b-checkbox-group :options="appOptions" v-model="appModules" @change="save" />

<b-card-text class="mt-3">
Weather to play audio feedback when using rf2-headlights or certain actions within the app.
Weather to play audio feedback when using rf2-headlights or certain actions within the app.<br />
You can prefer the Windows builtin Chromium Edge browser over Google Chrome to render this app.
Changes apply after an app restart.
</b-card-text>
</b-card>

Expand Down Expand Up @@ -61,7 +63,8 @@ export default {
],
appModules: ['audio'],
appOptions: [
{text: 'Enable Audio', value: 'audio'}
{text: 'Enable Audio', value: 'audio'},
{text: 'Prefer Edge Browser', value: 'edge_preferred'}
]
}
},
Expand Down

0 comments on commit 20bb037

Please sign in to comment.