dotremap 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -5
- data/bin/dotremap +1 -2
- data/example.rb +3 -3
- data/lib/dotremap/version.rb +1 -1
- data/lib/dotremap.rb +41 -24
- metadata +2 -3
- data/reload.gif +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a0be0149bc8f1e2f22a3530011bb12951a162b7
|
4
|
+
data.tar.gz: 613a9476f47e93566e72550551c5c380de128450
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 732d4e7c57cb83a53c4af0092d6ed1876b79edb35bbdd723ae21c315a7cd57ab7b6d95feea8ed97966cc2bbfae0feb256eeda686bc9af4589ff0301dbebfeb6e
|
7
|
+
data.tar.gz: 0e8b8b641b31f4d6b41a0625a90da035acfc2732a5cbf8ce4b00424e6abab4d4d327cbdcc87ba12150d1c12ca3f1d962a068740f3dbcec44d843918378056862
|
data/README.md
CHANGED
@@ -44,11 +44,8 @@ It will replace KeyRemap4MacBook's private.xml with compiled ~/.remap:
|
|
44
44
|
</root>
|
45
45
|
```
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
You have to reload private.xml to activate compiled configurations.
|
50
|
-
|
51
|
-

|
47
|
+
dotremap will automatically execute "ReloadXML".
|
48
|
+
Then activate your favorite configurations.
|
52
49
|
|
53
50
|
## Example
|
54
51
|
|
data/bin/dotremap
CHANGED
data/example.rb
CHANGED
@@ -33,7 +33,7 @@ item "Exchange Control + Space and Command + Space" do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
item "CapsLock ON", config_not: "notsave.private_capslock_on" do
|
36
|
-
remap "Cmd-L", to: ["capslock", "
|
36
|
+
remap "Cmd-L", to: ["capslock", "VK_CONFIG_FORCE_ON_notsave_private_capslock_on"]
|
37
37
|
end
|
38
38
|
|
39
39
|
item "CapsLock OFF", config_only: "notsave.private_capslock_on" do
|
@@ -66,7 +66,7 @@ end
|
|
66
66
|
# Use Cmd_R+B/F as M-b/f, and Cmd_R+S as Cmd+F to avoid conflict with M-f
|
67
67
|
item "[Not Terminal] Command+B/F to Option+Left/Right, Command+S to Command+F", not: "TERMINAL" do
|
68
68
|
remap "Cmd-B", to: "Opt-Left"
|
69
|
-
remap "Cmd-
|
69
|
+
remap "Cmd-F", to: "Opt-Right"
|
70
70
|
remap "Cmd-S", to: "Cmd-F"
|
71
71
|
end
|
72
72
|
|
@@ -115,8 +115,8 @@ item "Shift by control" do
|
|
115
115
|
end
|
116
116
|
|
117
117
|
item "Exchange single quote and double quote" do
|
118
|
-
remap "'", to: "Shift-'"
|
119
118
|
remap "Shift-'", to: "'"
|
119
|
+
remap "'", to: "Shift-'"
|
120
120
|
end
|
121
121
|
|
122
122
|
item "[Only Terminal] Command+A to Option+A", only: "TERMINAL" do
|
data/lib/dotremap/version.rb
CHANGED
data/lib/dotremap.rb
CHANGED
@@ -4,44 +4,37 @@ require "unindent"
|
|
4
4
|
require "fileutils"
|
5
5
|
|
6
6
|
class Dotremap
|
7
|
+
XML_FILE_NAME = "private.xml"
|
7
8
|
OLD_XML_DIR = File.expand_path("~/Library/Application Support/KeyRemap4MacBook")
|
8
9
|
NEW_XML_DIR = File.expand_path("~/Library/Application Support/Karabiner")
|
9
|
-
|
10
|
+
OLD_APP_PATH = "/Applications/KeyRemap4MacBook.app"
|
11
|
+
NEW_APP_PATH = "/Applications/Karabiner.app"
|
12
|
+
RELOAD_XML_PATH = "Contents/Applications/Utilities/ReloadXML.app"
|
10
13
|
|
11
14
|
def initialize(config_path)
|
12
15
|
@config_path = config_path
|
13
|
-
@root = Root.new
|
14
16
|
end
|
15
|
-
attr_reader :config_path
|
16
|
-
|
17
|
-
def compile
|
18
|
-
validate_config_existence
|
17
|
+
attr_reader :config_path
|
19
18
|
|
20
|
-
|
21
|
-
|
19
|
+
def apply_configuration
|
20
|
+
replace_private_xml
|
21
|
+
reload_xml
|
22
|
+
puts "Successfully updated Karabiner configuration"
|
22
23
|
end
|
23
24
|
|
25
|
+
private
|
26
|
+
|
24
27
|
def replace_private_xml
|
25
28
|
ensure_xml_dir_existence
|
26
29
|
remove_current_xml
|
27
30
|
write_new_xml
|
28
|
-
puts "Successfully generated private.xml"
|
29
31
|
end
|
30
32
|
|
31
|
-
|
33
|
+
def reload_xml
|
34
|
+
app_path = File.exists?(OLD_APP_PATH) ? OLD_APP_PATH : NEW_APP_PATH
|
35
|
+
reload_xml_path = File.join(app_path, RELOAD_XML_PATH)
|
32
36
|
|
33
|
-
|
34
|
-
return if File.exists?(config_path)
|
35
|
-
|
36
|
-
File.write(config_path, <<-EOS.unindent)
|
37
|
-
#!/usr/bin/env ruby
|
38
|
-
|
39
|
-
# # Example
|
40
|
-
# item "Command+E to Command+W", not: "TERMINAL" do
|
41
|
-
# identifier "option.not_terminal_opt_e"
|
42
|
-
# autogen "__KeyToKey__ KeyCode::E, VK_COMMAND, KeyCode::W, ModifierFlag::COMMAND_L"
|
43
|
-
# end
|
44
|
-
EOS
|
37
|
+
system("open #{reload_xml_path}")
|
45
38
|
end
|
46
39
|
|
47
40
|
def ensure_xml_dir_existence
|
@@ -55,7 +48,31 @@ class Dotremap
|
|
55
48
|
end
|
56
49
|
|
57
50
|
def write_new_xml
|
58
|
-
File.write(File.join(OLD_XML_DIR, XML_FILE_NAME),
|
59
|
-
File.write(File.join(NEW_XML_DIR, XML_FILE_NAME),
|
51
|
+
File.write(File.join(OLD_XML_DIR, XML_FILE_NAME), new_xml)
|
52
|
+
File.write(File.join(NEW_XML_DIR, XML_FILE_NAME), new_xml)
|
53
|
+
end
|
54
|
+
|
55
|
+
def new_xml
|
56
|
+
return @new_xml if defined?(@new_xml)
|
57
|
+
validate_config_existence
|
58
|
+
|
59
|
+
root = Root.new
|
60
|
+
config = File.read(config_path)
|
61
|
+
root.instance_eval(config)
|
62
|
+
@new_xml = root.to_xml.gsub(/ *$/, "")
|
63
|
+
end
|
64
|
+
|
65
|
+
def validate_config_existence
|
66
|
+
return if File.exists?(config_path)
|
67
|
+
|
68
|
+
File.write(config_path, <<-EOS.unindent)
|
69
|
+
#!/usr/bin/env ruby
|
70
|
+
|
71
|
+
# # Example
|
72
|
+
# item "Command+E to Command+W", not: "TERMINAL" do
|
73
|
+
# identifier "option.not_terminal_opt_e"
|
74
|
+
# autogen "__KeyToKey__ KeyCode::E, VK_COMMAND, KeyCode::W, ModifierFlag::COMMAND_L"
|
75
|
+
# end
|
76
|
+
EOS
|
60
77
|
end
|
61
78
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dotremap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -78,7 +78,6 @@ files:
|
|
78
78
|
- lib/dotremap/remap.rb
|
79
79
|
- lib/dotremap/root.rb
|
80
80
|
- lib/dotremap/version.rb
|
81
|
-
- reload.gif
|
82
81
|
homepage: https://github.com/k0kubun/dotremap
|
83
82
|
licenses:
|
84
83
|
- MIT
|
data/reload.gif
DELETED
Binary file
|