diff --git a/public/electron.js b/public/electron.js index dc9ffe6..aaed232 100644 --- a/public/electron.js +++ b/public/electron.js @@ -15,8 +15,32 @@ const { setMainMenu } = require('./menu'); // be closed automatically when the JavaScript object is garbage collected. let mainWindow; -// Add flash support. If $USER_HOME/.pennywise-flash exists as plugin directory or symlink uses that. -const flashPath = path.join(os.homedir(), ".pennywise-flash"); +// Add flash support. If $USER_HOME/.pennywise-flash exists as plugin directory or symlink uses that, else guesses. +const pepperFlashSearchPaths = { + win32: "c:\\Program Files\\Google\\Chrome\\Application", + darwin: "/Users/colint/Library/Application Support/Google/Chrome/PepperFlash/", + linux: "/usr/lib/chromium-browser/plugins"}; + +function findFlashPath () { + let searchPath = pepperFlashSearchPaths[process.platform]; + let flashPath = null; + let maxVersion = -1; + if (searchPath && fs.existsSync(searchPath)) { + fs.readdirSync(searchPath).forEach(file => { + let version = file.match(/(\d+)(\.\d+)+/); + if (version && version[1] > maxVersion) { + flashPath = file; + maxVersion = version[1]; + } + }); + } + return flashPath === null? null : path.join(searchPath, flashPath, "PepperFlashPlayer.plugin"); +}; + +let flashPath = path.join(os.homedir(), ".pennywise-flash"); +if (!fs.existsSync(flashPath)){ + flashPath = findFlashPath(); +} if (flashPath && fs.existsSync(flashPath)) { try { app.commandLine.appendSwitch('ppapi-flash-path', fs.realpathSync(flashPath)); @@ -25,6 +49,9 @@ if (flashPath && fs.existsSync(flashPath)) { console.log("Error finding flash at " + flashPath + ": " + e.message); } } +else{ + console.log("No flash found at" + flashPath); +} function createWindow() { mainWindow = new BrowserWindow({ diff --git a/readme.md b/readme.md index 17e75af..6d7327b 100644 --- a/readme.md +++ b/readme.md @@ -37,9 +37,11 @@ If you are on MacOS, you can use [Homebrew](https://brew.sh/) to install it brew cask install pennywise ``` -### Enable Flash Support +### Flash Support -To enable flash support, copy or link Chrome's Pepperflash plugin into your $HOME/.pennywise-flash. You can find the plugin at the installation path of the Chrome. For example, on MacOS, you can do the below to enable Flash support +On startup Pennywise attempts to find the Pepperflash plugin to use from your Chrome installation. + +Alternatively, you can copy or link Chrome's Pepperflash plugin into your $HOME/.pennywise-flash. You can find the plugin at the installation path of the Chrome. For example, on MacOS: ``` ln -s ~/Library/Application\ Support/Google/Chrome/PepperFlash/[version]/PepperFlashPlayer.plugin" ~/.pennywise-flash