karabiner 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/karabiner.rb +1 -1
- data/lib/karabiner/appdef.rb +2 -2
- data/lib/karabiner/dsl/item.rb +11 -5
- data/lib/karabiner/history.rb +24 -0
- data/lib/karabiner/item.rb +2 -2
- data/lib/karabiner/root.rb +18 -6
- data/lib/karabiner/version.rb +1 -1
- data/lib/karabiner/vkopenurldef.rb +22 -4
- metadata +3 -3
- data/lib/karabiner/invoke_history.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8622ef8f018f0acdd26c162ea8215c2b54c7fb4
|
4
|
+
data.tar.gz: bf3b45645ec16cc19559d8315f8463c5387721ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f8f1ff12777f5b3b1ebb8745c99bf27c78622c151513c35d4ca988f588a971360b7bf6e37f506dcd12ac9a5c77d7322a7ef6244c9022fb57a3939c4057df9b3
|
7
|
+
data.tar.gz: 68c4176643b0912e7ed92921188a0efd907409b38c822d7a5b510ef56e4f5c5777fa0ae1e03bc666dc2f834b5735b6e8cf8d6def059b45f8d2b964362703de3e
|
data/README.md
CHANGED
@@ -122,6 +122,10 @@ item "Application shortcuts" do
|
|
122
122
|
remap "C-h", to: invoke("iTerm")
|
123
123
|
end
|
124
124
|
|
125
|
+
item "Copy date" do
|
126
|
+
remap "Cmd-d", to: execute("date|pbcopy")
|
127
|
+
end
|
128
|
+
|
125
129
|
item "Control+PNBF to Up/Down/Left/Right" do
|
126
130
|
remap "C-p", to: "Up"
|
127
131
|
remap "C-n", to: "Down"
|
data/lib/karabiner.rb
CHANGED
data/lib/karabiner/appdef.rb
CHANGED
@@ -3,11 +3,11 @@ require "karabiner/xml_tree"
|
|
3
3
|
class Karabiner::Appdef
|
4
4
|
include Karabiner::XmlTree
|
5
5
|
|
6
|
-
AVAILABLE_OPTIONS = %i
|
6
|
+
AVAILABLE_OPTIONS = %i[
|
7
7
|
equal
|
8
8
|
prefix
|
9
9
|
suffix
|
10
|
-
|
10
|
+
].freeze
|
11
11
|
|
12
12
|
def initialize(appname, options)
|
13
13
|
property = Karabiner::Property.new("appname", appname)
|
data/lib/karabiner/dsl/item.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
|
+
require "karabiner/history"
|
1
2
|
require "karabiner/namespace"
|
2
3
|
require "karabiner/property"
|
3
4
|
require "karabiner/remap"
|
4
|
-
require "karabiner/
|
5
|
+
require "karabiner/vkopenurldef"
|
5
6
|
|
6
7
|
module Karabiner::DSL::Item
|
7
|
-
AVAILABLE_PROPERTIES = %i
|
8
|
+
AVAILABLE_PROPERTIES = %i[
|
8
9
|
name
|
9
10
|
identifier
|
10
11
|
autogen
|
11
|
-
|
12
|
+
].freeze
|
12
13
|
|
13
14
|
def remap(target, options = {})
|
14
15
|
remap = Karabiner::Remap.new(target, options[:to])
|
@@ -21,8 +22,13 @@ module Karabiner::DSL::Item
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def invoke(application)
|
24
|
-
Karabiner::
|
25
|
-
|
25
|
+
Karabiner::History.register_application(application)
|
26
|
+
Karabiner::Vkopenurldef.application_keycode(application)
|
27
|
+
end
|
28
|
+
|
29
|
+
def execute(script)
|
30
|
+
Karabiner::History.register_script(script)
|
31
|
+
Karabiner::Vkopenurldef.script_keycode(script)
|
26
32
|
end
|
27
33
|
|
28
34
|
private
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "set"
|
2
|
+
|
3
|
+
module Karabiner::History
|
4
|
+
def self.clear_histroy
|
5
|
+
registered_applications.clear
|
6
|
+
registered_scripts.clear
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.register_application(application)
|
10
|
+
registered_applications.add(application)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.register_script(script)
|
14
|
+
registered_scripts.add(script)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.registered_applications
|
18
|
+
@@registered_applications ||= Set.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.registered_scripts
|
22
|
+
@@registered_scripts ||= Set.new
|
23
|
+
end
|
24
|
+
end
|
data/lib/karabiner/item.rb
CHANGED
@@ -5,12 +5,12 @@ class Karabiner::Item
|
|
5
5
|
include Karabiner::XmlTree
|
6
6
|
include Karabiner::DSL::Item
|
7
7
|
|
8
|
-
AVAILABLE_OPTIONS = %i
|
8
|
+
AVAILABLE_OPTIONS = %i[
|
9
9
|
not
|
10
10
|
only
|
11
11
|
config_not
|
12
12
|
config_only
|
13
|
-
|
13
|
+
].freeze
|
14
14
|
|
15
15
|
def initialize(name, options = {})
|
16
16
|
@skip_identifier = options.delete(:skip_identifier)
|
data/lib/karabiner/root.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require "karabiner/invoke_history"
|
2
|
-
require "karabiner/vkopenurldef"
|
3
1
|
require "karabiner/dsl/root"
|
2
|
+
require "karabiner/history"
|
3
|
+
require "karabiner/vkopenurldef"
|
4
4
|
|
5
5
|
class Karabiner::Root
|
6
6
|
include Karabiner::XmlTree
|
@@ -11,10 +11,8 @@ class Karabiner::Root
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def to_xml
|
14
|
-
|
15
|
-
|
16
|
-
add_child(vkopenurldef)
|
17
|
-
end
|
14
|
+
add_registered_applications
|
15
|
+
add_registered_scripts
|
18
16
|
|
19
17
|
[
|
20
18
|
"<?xml version=\"1.0\"?>",
|
@@ -24,6 +22,20 @@ class Karabiner::Root
|
|
24
22
|
|
25
23
|
private
|
26
24
|
|
25
|
+
def add_registered_applications
|
26
|
+
Karabiner::History.registered_applications.each do |application|
|
27
|
+
vkopenurldef = Karabiner::Vkopenurldef.for_application(application)
|
28
|
+
add_child(vkopenurldef)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_registered_scripts
|
33
|
+
Karabiner::History.registered_scripts.each do |script|
|
34
|
+
vkopenurldef = Karabiner::Vkopenurldef.for_script(script)
|
35
|
+
add_child(vkopenurldef)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
27
39
|
def add_config(config)
|
28
40
|
@configs << config
|
29
41
|
end
|
data/lib/karabiner/version.rb
CHANGED
@@ -3,9 +3,27 @@ require "karabiner/xml_tree"
|
|
3
3
|
class Karabiner::Vkopenurldef
|
4
4
|
include Karabiner::XmlTree
|
5
5
|
|
6
|
-
def
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
def self.application_keycode(application)
|
7
|
+
"VK_OPEN_URL_APP_#{application.gsub(/ /, "_")}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.script_keycode(script)
|
11
|
+
"VK_OPEN_URL_SHELL_#{script.gsub(/[^a-zA-Z]/, "_")}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.for_application(application)
|
15
|
+
self.new.tap do |definition|
|
16
|
+
name = Karabiner::Property.new("name", "KeyCode::#{application_keycode(application)}")
|
17
|
+
url = Karabiner::Property.new("url", "/Applications/#{application}.app", type: "file")
|
18
|
+
definition.add_child(name, url)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.for_script(script)
|
23
|
+
self.new.tap do |definition|
|
24
|
+
name = Karabiner::Property.new("name", "KeyCode::#{script_keycode(script)}")
|
25
|
+
url = Karabiner::Property.new("url", "<![CDATA[ #{script} ]]>", type: "shell")
|
26
|
+
definition.add_child(name, url)
|
27
|
+
end
|
10
28
|
end
|
11
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: karabiner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -109,7 +109,7 @@ files:
|
|
109
109
|
- lib/karabiner/dsl/item.rb
|
110
110
|
- lib/karabiner/dsl/root.rb
|
111
111
|
- lib/karabiner/group.rb
|
112
|
-
- lib/karabiner/
|
112
|
+
- lib/karabiner/history.rb
|
113
113
|
- lib/karabiner/item.rb
|
114
114
|
- lib/karabiner/key.rb
|
115
115
|
- lib/karabiner/namespace.rb
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require "set"
|
2
|
-
require "karabiner/vkopenurldef"
|
3
|
-
|
4
|
-
module Karabiner::InvokeHistory
|
5
|
-
def self.clear_histroy
|
6
|
-
@@registered_applications = Set.new
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.register(application)
|
10
|
-
registered_applications.add(application)
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.registered_applications
|
14
|
-
@@registered_applications ||= Set.new
|
15
|
-
end
|
16
|
-
end
|