Module: Keyremac
- Defined in:
- lib/keyremac.rb,
lib/keyremac/key.rb,
lib/keyremac/base.rb,
lib/keyremac/dump.rb,
lib/keyremac/version.rb,
lib/keyremac/constants.rb
Defined Under Namespace
Modules: Autogen, Container, Delegator, Focus, Keyable
Classes: ConsumerKey, Item, Key, Raw, Root
Constant Summary
collapse
- CLI_PATH =
'/Applications/Karabiner.app/Contents/Library/bin/karabiner'
- DEFAULT_SETTINGS_PATH =
'~/Library/Application Support/Karabiner/private.xml'
- VERSION =
"1.0.0"
- CONSUMER_KEYS =
[
'BRIGHTNESS_DOWN',
'BRIGHTNESS_UP',
'KEYBOARDLIGHT_OFF',
'KEYBOARDLIGHT_LOW',
'KEYBOARDLIGHT_HIGH',
'MUSIC_PREV',
'MUSIC_PLAY',
'MUSIC_NEXT',
'MUSIC_PREV_18',
'MUSIC_NEXT_17',
'VOLUME_MUTE',
'VOLUME_DOWN',
'VOLUME_UP',
'EJECT',
'POWER',
'NUMLOCK',
'VIDEO_MIRROR',
]
- SYMBOL_TABLE =
{
'`' => 'BACKQUOTE',
'\\' => 'BACKSLASH',
'[' => 'BRACKET_LEFT',
']' => 'BRACKET_RIGHT',
',' => 'COMMA',
'.' => 'DOT',
'=' => 'EQUAL',
'-' => 'MINUS',
'\'' => 'QUOTE',
';' => 'SEMICOLON',
'0' => 'KEY_0',
'1' => 'KEY_1',
'2' => 'KEY_2',
'3' => 'KEY_3',
'4' => 'KEY_4',
'5' => 'KEY_5',
'6' => 'KEY_6',
'7' => 'KEY_7',
'8' => 'KEY_8',
'9' => 'KEY_9',
}
- SHIFT_TABLE =
Class Method Summary
collapse
Class Method Details
.collect_identifiers ⇒ Object
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/keyremac.rb', line 12
def self.collect_identifiers
xml = get_root.dump
doc = REXML::Document.new(xml)
result = []
doc.elements.each('//identifier') {|e|
result << e.text
}
result
end
|
.dump ⇒ Object
8
9
10
|
# File 'lib/keyremac.rb', line 8
def self.dump
puts get_root.dump
end
|
.reload ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/keyremac.rb', line 26
def self.reload
File.write File.expand_path(DEFAULT_SETTINGS_PATH), get_root.dump
`#{CLI_PATH} reloadxml`
self.collect_identifiers.each { |id|
`#{CLI_PATH} enable #{id}`
}
end
|
.run ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/keyremac.rb', line 34
def self.run
require 'optparse'
OptionParser.new { |op|
op.on('--dump', 'dump private.xml') { Keyremac::dump }
op.on('--reload', 'reload private.xml') { Keyremac::reload }
op.on('--ids', 'collect identifiers') { puts Keyremac::collect_identifiers }
}.parse!(ARGV.dup)
end
|