Class: Vigilem::Evdev::System::KeymapLoaders::DumpkeysLoader
- Inherits:
-
Object
- Object
- Vigilem::Evdev::System::KeymapLoaders::DumpkeysLoader
- Defined in:
- lib/vigilem/evdev/system/keymap_loaders/dumpkeys_loader.rb
Overview
this takes longer than keymap_loader, but is more thorough
Constant Summary collapse
- KeyMap =
Support::KeyMap
Instance Attribute Summary collapse
Class Method Summary collapse
- .available? ⇒ FalseClass || TrueClass
-
.command ⇒ String || NilClass
Returns the command path, otherwise returns nil if there isn’t one.
-
.run_dumpkeys(*dumpkeys_args) ⇒ String || nil
needs sudo on xserver loads dumpkeys string from system command.
-
.tty ⇒ String || nil
as long as it’s sudo does this matter?.
Instance Method Summary collapse
- #available? ⇒ TrueClass || FalseClass
- #exec(args = '') ⇒ KeyMap (also: #key_map!)
- #key_map_info ⇒ KeyMapInfo
Instance Attribute Details
#key_map ⇒ KeyMap
38 39 40 |
# File 'lib/vigilem/evdev/system/keymap_loaders/dumpkeys_loader.rb', line 38 def key_map @key_map ||= exec end |
Class Method Details
.available? ⇒ FalseClass || TrueClass
57 58 59 |
# File 'lib/vigilem/evdev/system/keymap_loaders/dumpkeys_loader.rb', line 57 def available? tty and command end |
.command ⇒ String || NilClass
Returns the command path, otherwise returns nil if there isn’t one
64 65 66 67 68 69 70 71 72 |
# File 'lib/vigilem/evdev/system/keymap_loaders/dumpkeys_loader.rb', line 64 def command if not @checked_for_command str = `which dumpkeys`.chomp @checked_for_command = true @command = str.empty? ? nil : str else @command end end |
.run_dumpkeys(*dumpkeys_args) ⇒ String || nil
needs sudo on xserver loads dumpkeys string from system command
86 87 88 89 90 91 |
# File 'lib/vigilem/evdev/system/keymap_loaders/dumpkeys_loader.rb', line 86 def run_dumpkeys(*dumpkeys_args) if tty and command args = dumpkeys_args.empty? ? '' : "-#{dumpkeys_args.join}" `#{command} #{args} < #{tty}` end end |
.tty ⇒ String || nil
as long as it’s sudo does this matter?
76 77 78 79 |
# File 'lib/vigilem/evdev/system/keymap_loaders/dumpkeys_loader.rb', line 76 def tty @tty_command ||= `which tty`.chomp @tty ||= `#{@tty_command}` if @tty_command end |
Instance Method Details
#available? ⇒ TrueClass || FalseClass
50 51 52 |
# File 'lib/vigilem/evdev/system/keymap_loaders/dumpkeys_loader.rb', line 50 def available? self.class.available? end |
#exec(args = '') ⇒ KeyMap Also known as: key_map!
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/vigilem/evdev/system/keymap_loaders/dumpkeys_loader.rb', line 20 def exec(args='') @key_map = if self.class.available? if args =~ /\s+/ raise ArgumentError, "Argument: `#{args}' invalid" else k = KeyMap.load_string(self.class.run_dumpkeys("fn#{args}")) k.[:loader] = self k end end key_map_info @key_map end |
#key_map_info ⇒ KeyMapInfo
44 45 46 |
# File 'lib/vigilem/evdev/system/keymap_loaders/dumpkeys_loader.rb', line 44 def key_map_info key_map.info ||= key_map.info(self.class.run_dumpkeys('l')) end |