Sha256: 483049221705a68cff953428d451de975c3742fc330393fc59de06a4147269a8

Contents?: true

Size: 862 Bytes

Versions: 1

Compression:

Stored size: 862 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
      s = Config.shortcut(self)
      return unless s
      c = "xdotool key #{s}"
      MultiLogger.warn 'shortcut property is deprecated.'
      MultiLogger.warn "Use command: #{c} instead of shortcut: #{s}"
      c
    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.2 lib/fusuma/command_executor.rb