Skip to content

Instantly share code, notes, and snippets.

@sstelfox
Created February 4, 2013 20:40
Show Gist options
  • Save sstelfox/4709573 to your computer and use it in GitHub Desktop.
Save sstelfox/4709573 to your computer and use it in GitHub Desktop.
Linux version of the imagesnap post-commit git hooks. To use create the file .git/hooks/post-commit in any repository you commit in often. Requires you have fswebcam installed (most distros have a package for it). Snapshots are stored in ~/.gitshots.
#!/usr/bin/env ruby
#
require 'fileutils'
fswebcam_path = `which fswebcam`.strip
exit 0 if fswebcam_path.empty?
print "Snapshotting your pretty mug..."
base_path = File.expand_path("~/.gitshots")
file = File.join(base_path, "#{Time.now.to_f}.png")
FileUtils.mkdir_p(base_path)
system("#{fswebcam_path} --png -1 --save #{file} -q")
puts "Done"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment