diff --git a/lib/imgurr/command.rb b/lib/imgurr/command.rb index d6375bb..4ae66d8 100644 --- a/lib/imgurr/command.rb +++ b/lib/imgurr/command.rb @@ -139,13 +139,17 @@ def upload(major) # Note: Only supported on OS X for now # Returns nothing def capture - unless Platform.darwin? - puts "Capture command is only supported on OS X for the time being." + unless Platform.darwin? || Platform.linux? + puts "Capture command is only supported on OS X or Linux for the time being." return end image_path = "#{ENV['HOME']}/.imgurr.temp.png" - Platform.capture('-W', image_path) + if Platform.darwin? + Platform.capture('-W', image_path) + elsif Platform.linux? + Platform.capture('', image_path) + end # User might have canceled or it takes some time to write to disk. # Check up to 3 times with 1 sec delay diff --git a/lib/imgurr/platform.rb b/lib/imgurr/platform.rb index a9bfa44..59a8abe 100644 --- a/lib/imgurr/platform.rb +++ b/lib/imgurr/platform.rb @@ -28,6 +28,9 @@ def windows? !!(RUBY_PLATFORM =~ /mswin|mingw/) end + def linux? + !(darwin? || windows?) + end # Public: returns the command used to open a file or URL # for the current platform. # @@ -84,6 +87,8 @@ def copy(url) def capture_command if darwin? 'screencapture' + elsif linux? + 'import' end end