From b678d979e3b6424e4251bd60f77c506ad4b6e425 Mon Sep 17 00:00:00 2001 From: yqrashawn Date: Tue, 11 Sep 2018 15:06:55 +0800 Subject: [PATCH] seems the previous release version is not usable, the $HOME variable is always /Users/.travis, fixed that. --- CHANGELOG.org | 9 ++++++++- README.org | 3 --- src/karabiner_configurator/core.clj | 28 ++++++++++++++-------------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.org b/CHANGELOG.org index 34a2a53..9f405db 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -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 diff --git a/README.org b/README.org index 84407d0..c0ff6b0 100644 --- a/README.org +++ b/README.org @@ -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 diff --git a/src/karabiner_configurator/core.clj b/src/karabiner_configurator/core.clj index e960ec4..6bd65ca 100644 --- a/src/karabiner_configurator/core.clj +++ b/src/karabiner_configurator/core.clj @@ -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 @@ -74,7 +74,7 @@ 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] @@ -82,8 +82,8 @@ (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 @@ -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" "" @@ -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)