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

Adding new LOLCOMMITS_FORK (or --fork) option to fork the runner capturing #109

Merged
merged 1 commit into from
Jul 8, 2013
Merged
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ By default, the lolimages are stored by a Github style short SHA in a `~/.lolcom

Please add your own lolcommit! Add to the [People Using Lolcommits](https://github.com/mroth/lolcommits/wiki/People-Using-Lolcommits) page on the Wiki.

## Installation
## Installation
### Mac OS X
You'll need ImageMagick installed. [Homebrew](http://mxcl.github.com/homebrew/) makes this easy. Simply do:

Expand Down Expand Up @@ -57,6 +57,8 @@ environment variables.
* Set delay persistently (for slow to warmup webcams) - set
`LOLCOMMITS_DELAY` var to time in seconds.
* Set font file location - set `LOLCOMMITS_FONT` environment variable.
* Fork lolcommits runner - set `LOLCOMMITS_FORK` environment variable
(causes capturing command to fork to a new process, speedily returning you to your terminal).

For the full list, see the [configuration variables](https://github.com/mroth/lolcommits/wiki/Configuration-Variables).

Expand Down
50 changes: 32 additions & 18 deletions bin/lolcommits
Original file line number Diff line number Diff line change
Expand Up @@ -134,25 +134,35 @@ def do_capture
capture_device = Choice.choices[:device] || ENV['LOLCOMMITS_DEVICE'] || nil
capture_font = Choice.choices[:font] || ENV['LOLCOMMITS_FONT'] || nil

if Choice.choices[:test]
info "*** Capturing in test mode."
runner = Lolcommits::Runner.new(:capture_delay => capture_delay,
:capture_device => capture_device,
:message => Choice.choices[:msg],
:sha => Choice.choices[:sha],
:config => configuration,
:font => capture_font
)
runner.run

Launchy.open(runner.main_image)
else
runner = Lolcommits::Runner.new(:capture_delay => capture_delay,
:capture_device => capture_device,
:config => configuration,
:font => capture_font
fork_me? do
if Choice.choices[:test]
info "*** Capturing in test mode."
runner = Lolcommits::Runner.new(:capture_delay => capture_delay,
:capture_device => capture_device,
:message => Choice.choices[:msg],
:sha => Choice.choices[:sha],
:config => configuration,
:font => capture_font
)
runner.run
runner.run

Launchy.open(runner.main_image)
else
runner = Lolcommits::Runner.new(:capture_delay => capture_delay,
:capture_device => capture_device,
:config => configuration,
:font => capture_font
)
runner.run
end
end
end

def fork_me?(&block)
if Choice.choices[:fork] || ENV['LOLCOMMITS_FORK']
fork { yield block }
Copy link

Choose a reason for hiding this comment

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

Maybe we should redirect STDOUT from within the child process.

else
yield block
end
end

Expand Down Expand Up @@ -305,6 +315,10 @@ Choice.options do
desc "generate animated gif"
end

option :fork do
long "--fork"
desc "fork the lolcommits runner to the background"
end
end

# Set debug level if needed
Expand Down