Sketchybar connection?
Is it possible to send the status of which mode you're in to third party apps? I would like to be able to show the current mode in Sketchybar.
currently there's the environment.json: https://docs.kindavim.app/apis
it contains only the insert, visual and normal Modes. no operator modes at the moment. i'm currently working on an Karabiner-Elements integration in order to bring custom mapping, and most probably the JSON will get some more new key to plays with, but might not be relevant for that SketchyBar use case. could be for other stuff you may have in mind tho.
for the JSON you can watch it with watchman for example and grab what you need with jq (coming with macOS), and call whatever external command you want. (you can set up watchman do start at boot etc. too.) the whole thing might be done in one liner :D
currently there's the
environment.json: https://docs.kindavim.app/apis it contains only theinsert,visualandnormalModes. no operator modes at the moment. i'm currently working on an Karabiner-Elements integration in order to bring custom mapping, and most probably the JSON will get some more new key to plays with, but might not be relevant for that SketchyBar use case. could be for other stuff you may have in mind tho.for the JSON you can watch it with
watchmanfor example and grab what you need withjq(coming with macOS), and call whatever external command you want. (you can set up watchman do start at boot etc. too.) the whole thing might be done in one liner :D
Sounds amazing, I will look into it, thank you so much!
for a middle/long term future i'm not sure. rather than a JSON maybe launch a command/script as an option in the Settings? need to see the advantages/drawbacks. definitely open to feedback on those stuff because 1) it's definitely something i'm not gonna be using myself so i need you guys to tell me 2) in exposing things to the outside world i lose a lot of control which makes it hard to predict what you guys users are gonna create with all that shit and what you're really gonna need and want as features. this could change the structure of kV's development, with all the automated tested happening in the background etc. and so make things difficult. so quick, good feedback is always super important for me to be able to create fast, small releases, that adds one step first, and then we see where they go from there.
Sounds amazing, I will look into it, thank you so much!
#!/bin/sh
kv_env_dir="$HOME/Library/Application Support/kindaVim"
kv_env_name="environment.json"
watchman watch-project "$kv_env_dir"
watchman --json-command <<EOF
[
"trigger", "$kv_env_dir", {
"name": "kindaVimEnvironment",
"expression": ["match", "$kv_env_name"],
"command": [
"sh", "-c",
"karabiner_cli --set-variables \"\$(jq '{kindaVimMode: .mode}' < $kv_env_name)\""
]
}
]
EOF
example with watchman that calls the karabiner_cli and set variables. you should be able to just change that line to call whatever SketchyBar format needs.
Yeah I am not 100% sure what the best approach is! I have been using the exposed state of the layers in both Yabai and Aerospace before to show in Sketchybar and that has been working well. I will look into how they're doing it tomorrow and get back to you, and also I'll try your watchman solution. :) Maybe that's just enough. I think I read somewhere I can exclude apps from the dimming feature, so this will basically act like my global Lualine, I would also like to not have anything show in terms of modes when I am in apps that I have excluded from the app. So I don't show modes when I am in vim or the terminal etc. I will mess with this asap tomorrow.
I think I read somewhere I can exclude apps from the dimming feature
you mean in kV? the option is global, not on a per app basis. but if you have apps in the Off Family then yeah, kV totally backs off. a consequence is that in that case there's no dimming yeah.
I would also like to not have anything show in terms of modes when I am in apps that I have excluded from the app. So I don't show modes when I am in vim or the terminal etc.
hmm. well currently kV's JSON will still contain insert because as far as it's concerned, your macOS is in Insert Mode lol. so the tweaking may have to be done somewhere else. maybe in shell script where you'll call watchman, maybe in some watchman settings, maybe in SketchyBar. no idea really.
next kV's release will bring integration with Karabiner-Elements and kV's Mode will be way more precise. something like Vim's map table (can't find this online anymore?):
pretty sure that from KE you can call command and shell scripts too, so i guess integration with SketchyBar should be possible too? could be another, more robust i think, solution.
kV78 released with integration with KE: https://github.com/godbout/kindaVim.blahblah/releases/tag/78 might be able to call SketchyBar directly from KE? not sure. but you can definitely make shell calls, URL calls etc. and more from KE: https://karabiner-elements.pqrs.org/docs/json/complex-modifications-manipulator-definition/to/
@daphen some fun done with HS and SketchyBar, thread starting here: https://github.com/godbout/kindaVim.blahblah/issues/297#issuecomment-3238071559
there's gists with HS lua config etc. down there. HS has an integrated path watcher with which you can check the changes in the environment.json file and react accordingly.
Personally I'm a fan of how FlashSpace handles its integrations.
Instead of building a bespoke integration for say, SketchyBar, the app has an integrations pane where you can specify exactly what CLI commands you wish to run in response to events, along with passing additional vars about its current state.
From there a SketchyBar integration is trivial, but you can also plug in just about any automation tool you want without needing Karabiner or a filewatcher program.
@NextMerge yeah that's exactly something i've explored and still have in mind. what i'm missing now is people's feedback and see where this part that i can't control is going.
currently what i've done is the bare minimum so that people can 1) have custom mappings 2) explore integrations with other tools and tell me what's missing, what's slow, what frictions they have, what they need or would prefer, etc.
some thoughts (mostly for myself) about why the integration is in its current state:
- i don't wanna build something that it's not gonna be used
- i want to avoid building something that is gonna be wrong
- i want to avoid as much as possible bringing breaking changes, which means avoiding points 1 and 2
- every part of kV is automatedly tested, which means it requires a lot of work and energy to make sure every release is AT LEAST as good as the previous one, which means avoiding points 1 and 2 again lol
- currently kV sends notifications when the Mode changes, but what about if people want/need to be notified with the pending key? or the pending motion? that would require calling external app at different times, sync the data, etc. again big changes in the code, including the tests, so again, avoiding 1 and 2. as long as i'm not more certain about where this is going, it's very hard to start developing concrete foundations.