Skip to content

Commit

Permalink
fix: resolve #181
Browse files Browse the repository at this point in the history
  • Loading branch information
yqrashawn committed Jul 17, 2022
1 parent 2295ee4 commit 3106498
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 27 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.org
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ All notable changes to this project will be documented in this file. This change

** Unreleased

[Unreleased Commits]: https://github.com/yqrashawn/GokuRakuJoudo/compare/v0.5.5...HEAD
[Unreleased Commits]: https://github.com/yqrashawn/GokuRakuJoudo/compare/v0.5.6...HEAD

** 0.5.6 - 2022-07-17
*** Added
~goku --where-is-my-config- shows detected config path
*** Fixed
- fix https://github.com/yqrashawn/GokuRakuJoudo/issues/181

[commits in 0.5.6]: https://github.com/yqrashawn/GokuRakuJoudo/compare/v0.5.5...v0.5.6

** 0.5.5 - 2022-07-12
*** Fixed
Expand Down
46 changes: 26 additions & 20 deletions src/karabiner_configurator/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@
"/usr/local/bin:" ;; homebrew
(get sys-env "PATH"))}))))

(defn exit [status & [msg]]
(when msg (println msg))
(when-not (env :is-dev) (System/exit status)))
(defn exit
([status] (exit [status nil]))
([status msg]
(when msg (println msg))
(when-not (env :is-dev) (System/exit status))))

;; paths
(defn json-config-file-path
Expand Down Expand Up @@ -71,7 +73,7 @@
(let [{:keys [applications devices keyboard-type input-sources tos froms modifiers layers simlayers ;; raws
main simlayer-threshold templates profiles]} conf]
(if (nil? profiles)
(profiles/parse-profiles (:profiles d/conf-data))
(profiles/parse-profiles (:profiles @d/conf-data))
(profiles/parse-profiles profiles))
(update-static-conf :applications applications)
(update-static-conf :devices devices)
Expand Down Expand Up @@ -177,13 +179,13 @@
[["-h" "--help"]
["-V" "--version"]
["-l" "--log"]
[nil "--where-is-my-config"]
["-c" "--config PATH" "Config PATH"
:parse-fn abs-path
:validate [(fn [path]
(let [path (abs-path path)]
(and (fs/exists? path)
(fs/file? path)
(fs/readable? path))))
(and (fs/exists? path)
(fs/file? path)
(fs/readable? path)))
"Make sure the file is exits and readable"]]
["-d" "--dry-run"]
["-A" "--dry-run-all"]])
Expand All @@ -201,11 +203,14 @@
{:action "exit-with-message"
:ok? true
:exit-message (help-message summary)}
(:where-is-my-config options)
{:action "show-config-path"
:ok? true}
;; version
(:version options)
{:action "exit-with-message"
:ok? true
:exit-message "0.5.3"}
{:action "exit-with-message"
:ok? true
:exit-message "0.5.6"}
;; log
(:log options)
{:action "log"
Expand All @@ -229,15 +234,14 @@
[& args]
(let [{:keys [action ;; options
exit-message ok? config dry-run dry-run-all]} (validate-args args)]
(when exit-message
(case action
"run" (do (parse (or config (edn-config-file-path)) dry-run dry-run-all)
(exit (if ok? 0 1) exit-message))
"log" (do (open-log-file)
(exit 0))
"exit-with-message" (exit (if ok? 0 1) exit-message)
"errors" (exit (if ok? 0 1) exit-message)
"default" (exit (if ok? 0 1) exit-message)))))
(case action
"run" (do (parse (or config (edn-config-file-path)) dry-run dry-run-all)
(exit (if ok? 0 1) exit-message))
"show-config-path" (exit 0 (or config (edn-config-file-path)))
"log" (do (open-log-file) (exit 0))
"exit-with-message" (exit (if ok? 0 1) exit-message)
"errors" (exit (if ok? 0 1) exit-message)
"default" (exit (if ok? 0 1) exit-message))))

(comment
(-main)
Expand All @@ -246,10 +250,12 @@
(-main "-l")
(-main "--log")
(-main "--config" "./")
(-main "--where-is-my-config")
(-main "-c" "./")
(-main "-dc" "./")
(-main "-dc" "~/.config/karabiner.edn")
(-main "-dc" "~/.config/karabiner.test.edn")
(-main "-c" "~/.nixpkgs/modules/yqrashawn/home-manager/dotfiles/karabiner.edn")
(-main "-d")
(-main "-V")
(-main "--version"))
13 changes: 7 additions & 6 deletions src/karabiner_configurator/modifiers.clj
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@

(defn generate
[modifiers]
(assoc @d/conf-data :modifiers
(into
{}
(for [[modifier-name modifier-info] modifiers]
{modifier-name
(parse-single-modifier-definition modifier-info modifier-name)}))))
(d/assoc-conf-data
:modifiers
(into
{}
(for [[modifier-name modifier-info] modifiers]
{modifier-name
(parse-single-modifier-definition modifier-info modifier-name)}))))

(defn parse-modifiers
"parse modifires to string"
Expand Down
1 change: 1 addition & 0 deletions src/karabiner_configurator/profiles.clj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
:basic.to_delayed_action_delay_milliseconds delay
:basic.to_if_alone_timeout_milliseconds alone
:basic.to_if_held_down_threshold_milliseconds held}}}))))

(defn parse-rules
"Parse generated rules into profiles"
[rules]
Expand Down

0 comments on commit 3106498

Please sign in to comment.