Sha256: 411d89b4c07cca7bd4cf2468ed1bd4f85f4c0b926ce4720f479084c0d3577e33

Contents?: true

Size: 715 Bytes

Versions: 1

Compression:

Stored size: 715 Bytes

Contents

module Fusuma
  # Execute Command
  class CommandExecutor
    def initialize(finger, vector)
      @finger      = finger.to_i
      @direction   = vector.direction
      @event_type = vector.class::TYPE
    end
    attr_reader :finger, :direction, :event_type

    def execute
      `#{command_or_shortcut}`
      MultiLogger.info("Execute: #{command_or_shortcut}")
    end

    private

    def command_or_shortcut
      @command_or_shortcut ||= command || shortcut || no_command
    end

    def command
      Config.command(self)
    end

    def shortcut
      Config.shortcut(self).tap { |s| return "xdotool key #{s}" if s }
    end

    def no_command
      'echo "Command is not assigned"'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fusuma-0.10.1 lib/fusuma/command_executor.rb