yqrashawn / GokuRakuJoudo

config karabiner with ease
GNU General Public License v3.0
1.13k stars 122 forks source link

Generating `karabiner.json` from scratch? #243

Open toxxmeister opened 2 months ago

toxxmeister commented 2 months ago

Hi! Do you have any plans on making Goku able to generate karabiner.json from scratch in the future?

I understand that some users use Karabiner in more complex ways that require a lot of setup in karabiner.json that is not already covered by Goku, but in my particular case, the only things I am missing are global options. In fact, up until recently, my karabiner-template.json looked like this:

{
  "global": {
    "check_for_updates_on_startup": false,
    "show_in_menu_bar": false
  },
  "profiles": [{"name": "Default"}]
}

with everything else coming from karabiner.edn. I had a simple script that'd replace karabiner.json with karabiner-template.json and then run goku.

It could be that I am pushing this too far, as my use case might be a bit particular, given that I don't have any complex device setups, heck I don't even define fn keys functionality there, but as regular complex modifications. Still might be worth discussing whether Goku could in the future be "standalone".


As a reference to anyone in a similar situation, I currently have global settings embedded into karabiner.edn and use jet to parse them and profiles to create karabiner.json on the fly without using any explicit template, before running goku:

# update-karabiner.sh
cat "$XDG_CONFIG_HOME/karabiner/karabiner.edn" | jet --to json --func \
  '#(assoc (select-keys % [:global])
           :profiles (map (fn [[k _]] {:name k}) (:profiles %)))'     \
  > "$XDG_CONFIG_HOME/karabiner/karabiner.json"

goku
;; karabiner.edn
{:global {:check_for_updates_on_startup false :show_in_menu_bar false}
 :profiles {:Default {:default true :sim 50 :delay 500 :alone 1000 :held 1000}}
 ;; ...