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

Linux support #7

Closed
wants to merge 1 commit into from
Closed
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
17 changes: 16 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,22 @@ class Aperture {
recorderOpts.push(`${cropArea.x}:${cropArea.y}:${cropArea.width}:${cropArea.height}`);
}

this.recorder = execa(path.join(__dirname, 'swift', 'main'), recorderOpts);
if (process.platform === 'darwin') {
this.recorder = execa(path.join(__dirname, 'swift', 'main'), recorderOpts);
} else if (process.platform === 'linux') {
let args = ['-f', 'x11grab', '-i'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let => const

And use long flags whenever possible.


if (opts.cropArea) {
args.push(':0+' + opts.cropArea.x + ',' + opts.cropArea.y);
args.push('-video_size', opts.cropArea.width + 'x' + opts.cropArea.height);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use template literals for these

} else {
args.push(':0');
}

args.push('-framerate', opts.fps, this.tmpPath);

this.recorder = execa('ffmpeg', args);
}

const timeout = setTimeout(() => {
const err = new Error('unnable to start the recorder after 5 seconds');
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"main": "index.js",
"scripts": {
"test": "xo",
"build": "cd swift && xcodebuild && mv build/release/aperture main && rm -r build",
"postinstall": "npm run build"
"build-macos": "cd swift && xcodebuild && mv build/release/aperture main && rm -r build",
"postinstall": "case $OSTYPE in darwin*) npm run build-macos ;; esac"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think [[ $OSTYPE == darwin* ]] && npm run build-macos would be simpler.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be, but it's not supported in plain shell.

Copy link
Contributor

@sindresorhus sindresorhus Dec 8, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could use [ "$(uname)" = "Darwin" ] && npm run build-macos then.

},
"repository": {
"type": "git",
Expand Down