时间:2011-01-06 18:29:02

标签: continuous-integration

2 个答案:

答案 0 :(得分:3)

答案 1 :(得分:1)

步骤1)撕开旧的Thinkpad,直到可以使用键盘灯。

步骤2)找到一个合适的继电器,你可以在灯的位置接线(以便运行更大的灯)。

步骤3)修改以下脚本以满足您的需求(或者从构建的任何检查中按原样运行):

#!/usr/bin/ruby
light_filename = '/proc/acpi/ibm/light'
num_cycles = 1

# see if we have an argument telling how many times to flash
ARGV.each do |a| 
    if a =~ /-c=(\d+)/ 
        num_cycles = $1.to_i 
    else 
        puts 'Unknown argument: ' + a
        exit
    end 
end

# method that reverses the state
def reverse(state)
        return 'on' if state.include? 'off'
        return 'off'
end

# find starting state
state = 'off'
File.open(light_filename, 'r') do |inf| 
    state='on' if inf.gets.include? 'on'
end

# double the cycle num to get how many times we should flip
flips = num_cycles * 2
# do the cycles
flips.times do |i|
    # reverse state
    File.open(light_filename, 'w') do |out| 
        state = reverse(state)
        out.write(state) 
    end
    # wait 1/4 sec before looping again
    sleep 0.250
end

(我可能从某个地方偷了那些代码,但是很久以前我就不记得了)