Skip to content

Commit

Permalink
Add: modifier keys without left or right (#63)
Browse files Browse the repository at this point in the history
resolve #62
  • Loading branch information
yqrashawn committed May 28, 2020
1 parent 97bc50e commit 9fe23d5
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 15 deletions.
23 changes: 22 additions & 1 deletion CHANGELOG.org
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,28 @@ All notable changes to this project will be documented in this file. This change

** Unreleased

[Unreleased Commits]: https://github.com/yqrashawn/GokuRakuJoudo/compare/v0.3.1...HEAD
[Unreleased Commits]: https://github.com/yqrashawn/GokuRakuJoudo/compare/v0.3.2...HEAD

** 0.3.2 - 2020-05-28
*** Added
- support specify ~command~ rather than ~left_command~ or ~shift~ rather than
~left_shift~ or ... in ~!CTOS~ format
- ~!~ to ~[:left_command :left_control :left_option :left_shift]~
- ~!A~ to ~[:command :control :option :shift]~
- ~C~ to ~:left_command~
- ~Q~ to ~:right_command~
- ~CC~ to ~:command~
- ~T~ to ~:left_control~
- ~W~ to ~:right_control~
- ~TT~ to ~:control~
- ~O~ to ~:left_option~
- ~E~ to ~:right_option~
- ~OO~ to ~:option~
- ~S~ to ~:left_shift~
- ~R~ to ~:right_shift~
- ~SS~ to ~:shift~

[commits in 0.3.2]: https://github.com/yqrashawn/GokuRakuJoudo/compare/v0.3.1...0.3.2

** 0.3.1 - 2020-05-10
*** Fixed
Expand Down
56 changes: 45 additions & 11 deletions src/karabiner_configurator/keys.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
(:require
[karabiner-configurator.misc :refer :all]
[karabiner-configurator.data :refer :all]
[karabiner-configurator.modifiers :as kmodifier]))
[karabiner-configurator.modifiers :as kmodifier]
[clojure.string :refer [includes? join]]))

(def any-key-keywords {:consumer_key_code {}
:pointing_button {}
Expand Down Expand Up @@ -30,8 +31,8 @@
[mkey]
(into {} (map update-mouse-map mkey)))

(def special-modi-re #"(^![!CSTOQWERFP]+#[#CSTOQWERFP]+)")
(def special-modi-mandatory-re #"(^![!CSTOQWERFP]+)")
(def special-modi-re #"(^![!ACSTOQWERFP]+#[#CSTOQWERFP]+)")
(def special-modi-mandatory-re #"(^![!ACSTOQWERFP]+)")
(def special-modi-optional-re #"(^#[#CSTOQWERFP]+)")
(def special-modi-optional-both-re #"(#[#CSTOQWERFP]+)")

Expand Down Expand Up @@ -60,21 +61,54 @@
[vec]
(if (vector? vec)
(let [result []
result (if (contains?? vec \C) (conj result (name :left_command)) result)
result (if (contains?? vec \T) (conj result (name :left_control)) result)
result (if (contains?? vec \O) (conj result (name :left_option)) result)
result (if (contains?? vec \S) (conj result (name :left_shift)) result)
s (join "" vec)
result (cond
(includes? s "CC")
(conj result (name :command))
(contains?? vec \C)
(conj result (name :left_command))
:else
result)
result (cond
(includes? s "TT")
(conj result (name :control))
(contains?? vec \T)
(conj result (name :left_control))
:else
result)
result (cond
(includes? s "OO")
(conj result (name :option))
(contains?? vec \O) (conj result (name :left_option))
:else
result)
result (cond
(includes? s "SS")
(conj result (name :shift))
(contains?? vec \S)
(conj result (name :left_shift))
:else
result)
result (if (contains?? vec \Q) (conj result (name :right_command)) result)
result (if (contains?? vec \W) (conj result (name :right_control)) result)
result (if (contains?? vec \E) (conj result (name :right_option)) result)
result (if (contains?? vec \R) (conj result (name :right_shift)) result)
result (if (contains?? vec \F) (conj result (name :fn)) result)
result (if (contains?? vec \P) (conj result (name :caps_lock)) result)
result (if (contains?? vec \#) [(name :any)] result)
result (if (contains?? vec \!) [(name :left_command)
(name :left_control)
(name :left_option)
(name :left_shift)] result)]
result (cond
(includes? s "!A")
[(name :command)
(name :control)
(name :option)
(name :shift)]
(contains?? vec \!)
[(name :left_command)
(name :left_control)
(name :left_option)
(name :left_shift)]
:else
result)]
result)
nil))

Expand Down
29 changes: 26 additions & 3 deletions test/karabiner_configurator/rules_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
(def example-mains [{:des "a to 1" :rules [[:condi :chunkwm-move-mode]
[:profiles :Default :test-profile-2]
[:a :1]]} ;; a to 1
{:des "left command a to control 1" :rules [[:!C#Pa :!T1]]}
{:des "[left] command a to control 1" :rules [[:!C#Pa :!T1]
[:!CC#Pa :!TT1]
[:!CCTTOOSS#Pa :!TT1]]}
{:des "right command a to control 1" :rules [[:!Q#Pa :!T1]]} ;; command a to control 1
{:des "my spacebar to control 1" :rules [[:my-spacebar :!T1]]} ;; my-spacebar to control 1
{:des "press b to insert 12" :rules [[:b [:1 :2]]]} ;; key to key
Expand All @@ -26,7 +28,8 @@
[:!C#Pq ["command-q" 1] :safari {:delayed {:invoked ["command-q" 0] :canceled ["command-q" 0]}}]]}
{:des "Mouse button"
:rules [[{:pkey :button5} :mission_control]
[{:pkey :button4} [{:pkey :button1} {:pkey :button1} :!!grave_accent_and_tilde]]]}
[{:pkey :button4} [{:pkey :button1} {:pkey :button1} :!!grave_accent_and_tilde]]
[{:pkey :button4} [{:pkey :button1} {:pkey :button1} :!!Agrave_accent_and_tilde]]]}
{:des "Change input source"
:rules [[:i :us :q-mode]
[:o :squirrel :q-mode]]}
Expand Down Expand Up @@ -142,13 +145,25 @@
:conditions
[{:name "chunkwm-move-mode", :value 1, :type "variable_if"}],
:type "basic"}]}
{:description "left command a to control 1",
{:description "[left] command a to control 1",
:manipulators
[{:from
{:key_code "a",
:modifiers
{:mandatory ["left_command"], :optional ["caps_lock"]}},
:to [{:key_code "1", :modifiers ["left_control"]}],
:type "basic"}
{:from
{:key_code "a",
:modifiers
{:mandatory ["command"], :optional ["caps_lock"]}},
:to [{:key_code "1", :modifiers ["control"]}],
:type "basic"}
{:from
{:key_code "a",
:modifiers
{:mandatory ["command", "control", "option", "shift"], :optional ["caps_lock"]}},
:to [{:key_code "1", :modifiers ["control"]}],
:type "basic"}]}
{:description "right command a to control 1",
:manipulators
Expand Down Expand Up @@ -327,6 +342,14 @@
{:key_code "grave_accent_and_tilde",
:modifiers
["left_command" "left_control" "left_option" "left_shift"]}],
:type "basic"}
{:from {:pointing_button "button4"},
:to
[{:pointing_button "button1"}
{:pointing_button "button1"}
{:key_code "grave_accent_and_tilde",
:modifiers
["command" "control" "option" "shift"]}],
:type "basic"}]}
{:description "Change input source",
:manipulators
Expand Down

0 comments on commit 9fe23d5

Please sign in to comment.