class Fusuma::Plugin::Inputs::TimerInput
libinput commands wrapper
Constants
- DEFAULT_INTERVAL
Attributes
pid[R]
Public Instance Methods
config_param_types()
click to toggle source
# File lib/fusuma/plugin/inputs/timer_input.rb, line 11 def config_param_types { interval: [Float] } end
io()
click to toggle source
# File lib/fusuma/plugin/inputs/timer_input.rb, line 19 def io @io ||= begin reader, writer = create_io @pid = start(reader, writer) reader end end
start(reader, writer)
click to toggle source
# File lib/fusuma/plugin/inputs/timer_input.rb, line 28 def start(reader, writer) pid = fork do timer_loop(reader, writer) end Process.detach(pid) writer.close pid end
timer_loop(reader, writer)
click to toggle source
# File lib/fusuma/plugin/inputs/timer_input.rb, line 37 def timer_loop(reader, writer) reader.close begin loop do sleep interval writer.puts 'timer' end rescue Errno::EPIPE exit 0 rescue StandardError => e MultiLogger.error e end end
Private Instance Methods
create_io()
click to toggle source
# File lib/fusuma/plugin/inputs/timer_input.rb, line 53 def create_io IO.pipe end
interval()
click to toggle source
# File lib/fusuma/plugin/inputs/timer_input.rb, line 57 def interval config_params(:interval) || DEFAULT_INTERVAL end