Skip to content
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
10 changes: 7 additions & 3 deletions lib/imgurr/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions lib/imgurr/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down Expand Up @@ -84,6 +87,8 @@ def copy(url)
def capture_command
if darwin?
'screencapture'
elsif linux?
'import'
end
end

Expand Down