Преглед на файлове

Set up defaults based on the hostname, correctly find the screen

offset if there are more than 2 screens
master
Peter J. Jones преди 6 години
родител
ревизия
2fe388e6c7
променени са 1 файла, в които са добавени 31 реда и са изтрити 9 реда
  1. 31
    9
      bin/record-screen.rb

+ 31
- 9
bin/record-screen.rb Целия файл

@@ -15,20 +15,42 @@ class Driver
:x_display => "0.0",
:fps => '25',
:video_bitrate => '256k',
:audio => false,
:audio => true,
:audio_hw => 'hw:0,0',
:audio_bitrate => '64k',
}

##############################################################################
DEFAULTS = {
# My desktop.
'hawkins' => {
:audio_hw => 'hw:2,0',
:screen => 3,
},

# My laptop.
'seward' => {
:audio_hw => 'hw:0,0',
:screen => 2,
},
}

##############################################################################
attr_reader(:options)

##############################################################################
def initialize
@options = OpenStruct.new(OPTIONS)
@hostname = `hostname`.chomp

if DEFAULTS.has_key?(@hostname)
DEFAULTS[@hostname].each {|k, v| options.send("#{k}=", v)}
end

OptionParser.new do |op|
op.on('--screen=N', "Record screen number N") {|n| options.screen = n.to_i}
op.on('--audio', "Enable mic") {|a| options.audio = a}
op.on('--screen=N', 'Record screen number N') {|n| options.screen = n.to_i}
op.on('--[no-]audio', 'Enable/disable mic') {|a| options.audio = a}
op.on('--audio-hw=DEVICE', 'Set audio device') {|h| options.audio_hw = h}
end.parse(ARGV)
end

@@ -49,7 +71,7 @@ class Driver
]

if options.audio
cmd.concat(%w(-f alsa -i hw:2,0 -ac 1 -strict experimental))
cmd.concat(%W(-f alsa -i #{options.audio_hw} -ac 1 -strict experimental))
end

cmd << File.expand_path(options.file)
@@ -62,14 +84,14 @@ class Driver

##############################################################################
def screen_x_offset (screen_num)
x = 0
offset = 0

if screen_num > 1
(x, y) = screen_size(screen_num - 1).split('x')
x = x.to_i
(screen_num - 1).times do |n|
(x, y) = screen_size(n + 1).split('x')
offset += x.to_i
end

x
offset
end

##############################################################################

Loading…
Отказ
Запис