Skip to content

Commit

Permalink
seems the previous release version is not usable, the $HOME variable …
Browse files Browse the repository at this point in the history
…is always

  /Users/.travis, fixed that.
  • Loading branch information
yqrashawn committed Sep 11, 2018
1 parent 02cdb59 commit b678d97
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.org
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ All notable changes to this project will be documented in this file. This change

** Unreleased

[Unreleased]: https://github.com/yqrashawn/GokuRakuJoudo/compare/v0.1.2...HEAD
[Unreleased]: https://github.com/yqrashawn/GokuRakuJoudo/compare/v0.1.3...HEAD

** 0.1.3 - 2018-09-11
*** Fixed
- seems the previous release version is not usable, the $HOME variable is always
/Users/.travis, fixed that.

[0.1.2]: https://github.com/yqrashawn/GokuRakuJoudo/compare/v0.1.2...v0.1.3

** 0.1.2 - 2018-09-10
*** Fixed
Expand Down
3 changes: 0 additions & 3 deletions README.org
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[[https://travis-ci.com/yqrashawn/GokuRakuJoudo.svg?branch=master]]
[[https://coveralls.io/repos/github/yqrashawn/GokuRakuJoudo/badge.svg]]
* GokuRakuJoudo
NOTE: the goku executable doesn't work right now. Seems the graalvm compile make
it "too static", will be fixed today.

Goku is a tool to let you manage your karabiner's configuration with ease.

Karbiner-Elements uses json as it's config file. It lead to thounds lines of
Expand Down
28 changes: 14 additions & 14 deletions src/karabiner_configurator/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,23 @@
(init-conf-data)
(generate conf))

(defn karabiner-json-path []
(if (System/getenv "XDG_CONFIG_HOME")
(str (System/getenv "XDG_CONFIG_HOME") "karabiner/karabiner.json")
(str (System/getenv "HOME") "/.config/karabiner/karabiner.json")))

(def karabiner-json-path (if (System/getenv "XDG_CONFIG_HOME")
(str (System/getenv "XDG_CONFIG_HOME") "karabiner/karabiner.json")
(str (System/getenv "HOME") "/.config/karabiner/karabiner.json")))

(def config-file
(defn config-file []
(if (System/getenv "XDG_CONFIG_HOME")
(str (System/getenv "XDG_CONFIG_HOME") "karabiner.edn")
(str (System/getenv "HOME") "/.config/karabiner.edn")))

;; (println (str "$XDG_CONFIG_HOME: " (System/getenv "XDG_CONFIG_HOME")))
;; (println (str "$HOME: " (System/getenv "HOME")))
;; (println (str "karabiner json path: " karabiner-json-path))
;; (println (str "edn config file path: " config-file))
;; (println (str "karabiner json path: " (karabiner-json-path )))
;; (println (str "edn config file path: " (config-file )))

(defn update-to-karabiner-json [rules]
(let [karabiner-config (load-json karabiner-json-path)
(let [karabiner-config (load-json (karabiner-json-path))
profile-indexed-list (map-indexed (fn [idx itm] [idx itm]) (:profiles karabiner-config))
profile-to-update
(first
Expand All @@ -74,16 +74,16 @@
updated-profile (:profile (assoc-in profile-to-update [:profile :complex_modifications :rules] updated-rules))
updated-profiles (assoc (:profiles karabiner-config ) (:index profile-to-update) updated-profile)
updated-configs (assoc karabiner-config :profiles updated-profiles)]
(spit karabiner-json-path
(spit (karabiner-json-path)
(json/generate-string updated-configs {:pretty true}))))

(defn parse-edn [path]
(update-to-karabiner-json (parse (load-edn path)))
(println "Done!"))

(defn watch []
(println (str "watching " config-file))
(shell/sh "watchexec" "-w" config-file "goku"))
(println (str "watching " (config-file)))
(shell/sh "watchexec" "-w" (config-file) "goku"))

;; cli things
(def cli-opts
Expand All @@ -97,8 +97,8 @@
(->> ["GokuRakuJoudo -- karabiner configurator"
""
"goku will read config file and update `Goku` profile in karabiner.json"
(str "- goku config file location: " config-file)
(str "- karabiner config file: " karabiner-json-path)
(str "- goku config file location: " (config-file))
(str "- karabiner config file: " (karabiner-json-path))
""
"run without arg to update once, run with `-w` to update on .edn file change"
""
Expand Down Expand Up @@ -146,7 +146,7 @@
(let [{:keys [action options exit-message ok?]} (validate-args args)]
(if exit-message
(case action
"run" (do (parse-edn config-file)
"run" (do (parse-edn (config-file))
(exit (if ok? 0 1)))
"watch" (watch)
"help" (exit (if ok? 0 1) exit-message)
Expand Down

0 comments on commit b678d97

Please sign in to comment.