Comments (12)
Would be cool, currently is just in order of most preferred/usable by Gluon. Would likely use reg.exe directly to avoid external dependencies.
from gluon.
Would be cool, currently is just in order of most preferred/usable by Gluon. Would likely use reg.exe directly to avoid external dependencies.
winreg doesnt have any external dependencies, so I think it's a safe go, it's also been stable for a few years
from gluon.
I meant having a dependency at all, as you can make a wrapper for reg.exe in ~5 lines
from gluon.
I meant having a dependency at all, as you can make a wrapper for reg.exe in ~5 lines
hm, too bad, wanted to PR this using that lib, but making a wrapper for a windows executable and parsing errors isn't my forte, here's the code using winreg, util.promisify
doesn't seem to work on it :/
import Registry from 'winreg'
const preferred = new Registry({
hive: Registry.HKCU,
key: '\\SOFTWARE\\Microsoft\\Windows\\Shell\\Associations\\URLAssociations\\https\\UserChoice'
})
preferred.get('ProgID', (_err, item) => {
const ProgID = item.value
const browser = new Registry({
hive: Registry.HKLM,
key: `\\SOFTWARE\\Classes\\${ProgID}\\shell\\open\\command`
})
browser.get(Registry.DEFAULT_VALUE, (_err, item) => {
const shell = item.value
console.log(shell)
})
})
from gluon.
Oh, apologies. Code looks good and understandable, using a custom wrapper allows using promises as well so lol.
from gluon.
Possibly could be an easier idea to use file associations like .html instead. Dedicated command line tool for it on Windows so would be much simpler but unsure if some people/browsers don't set file associations.
from gluon.
Preferred file associations for .html
would be a generally safe bet, but accessing based on https preferences may be the best way to go? Windows is a "little" aggressive with their promotion of Microsoft Edge, so they don't reliably change all file types when you update your preferences.
from gluon.
Preferred file associations for
.html
would be a generally safe bet, but accessing based on https preferences may be the best way to go? Windows is a "little" aggressive with their promotion of Microsoft Edge, so they don't reliably change all file types when you update your preferences.
.html is bad as it also lists text editors like vscode which are also in theory chromium, so i just went with https and browser detection
from gluon.
Yeah changed my mind, have an almost complete implementation which I'm leaving for 0.10.0, 0.9.0 should be releasing today with some new APIs.
from gluon.
On macOS I have found a way to obtain the default browser.
You can use plutil -convert json -o - ~/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist
to obtain the mapping of schemes/protocols to bundle IDs. 1 2
From that, you get something like:
{
"LSHandlers" : [
{ /* Other options */ }
{
"LSHandlerPreferredVersions" : {
"LSHandlerRoleAll" : "-"
},
"LSHandlerRoleAll" : "org.mozilla.firefox",
"LSHandlerURLScheme" : "https"
},
{ /* Other options */ }
]
}
Parsing that JSON, you can search for the object whose property LSHandlerURLScheme
equals "https" and obtain the value of the property LSHandlerRoleAll
, which is the bundle identifier of the application -- in this case "org.mozilla.firefox".
Then, you can use mdfind kMDItemCFBundleIdentifier = "org.mozilla.firefox"
, which will return the path of the application that that identifier belongs to. In this case, for my setup, it returned /Applications/Firefox.app
.
From this information, you can access the Info.plist
, which is located in /Applications/Firefox.app/Contents/Info.plist
and once again use plutil
to fetch the executable file that should be run using plutil -extract CFBundleExecutable raw /Applications/Firefox.app/Contents/Info.plist
.
This will return firefox
, which means the final path is /Applications/Firefox.app/Contents/MacOS/firefox
.
You can also use plutil -extract CFBundleName raw /Applications/Firefox.app/Contents/Info.plist
to obtain the application name, which will return "Firefox" for Firefox and "Chrome" for Google Chrome. This can be useful to compare against the supported browsers for gluon.
Footnotes
from gluon.
On Windows getting exe path from this is most universal: HKEY_LOCAL_MACHINE\SOFTWARE\Classes\${ProgID}\shell\open\command
. It will also work when users have non-standard path. Which would be more common for Firefox then Chrome probably.
from gluon.
On Windows getting exe path from this is most universal:
HKEY_LOCAL_MACHINE\SOFTWARE\Classes\${ProgID}\shell\open\command
. It will also work when users have non-standard path. Which would be more common for Firefox then Chrome probably.
its legit in the original post
from gluon.
Related Issues (20)
- Window events
- Custom useragent HOT 1
- How do I package a Gluon app as a native exectuable? HOT 1
- Sample app crashing HOT 3
- HTTPS required for gluon apps? HOT 5
- Change behavior of deno branch to create 'gluon_data/chrome' in current directory HOT 1
- Thorium as a recommended gluon brower-base HOT 5
- Switch CDP -> WebDriver BiDi
- IPC will not be available after page refresh HOT 1
- Error on startup of first example HOT 6
- Links that open in new tab, don't open new browser in firefox, while in edge they do
- Add brower support
- Possible to Use Bundled Wep App (e.g. Vue) Instead of URL HOT 1
- Automatic browser failure fallback
- System installer
- CDP reply error.
- Using gluon on existing Node.js app
- ReCaptcha v2 doesnt work HOT 1
- Browser unsupported for nextcloud server site HOT 1
- Project Status HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gluon.