Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look for flash directory #110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions public/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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({
Expand Down
6 changes: 4 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down