mobily / awesome-keys

πŸš€ AwesomeKeys is a plugin for Hammerspoon, that allows customizing global and app-specific key bindings.
52 stars 1 forks source link

How do you show the "cheatsheet"? #1

Closed dmitrym0 closed 2 years ago

dmitrym0 commented 2 years ago

Hi @mobily , wonderful package. I can't seem to figure out how to show the cheatsheet (all the key mappings). Are you using a separate spoon for this?

mobily commented 2 years ago

hey @dmitrym0 πŸ‘‹ the plugin only shows defined key bindings :)

firstly, you need to create a new HyperBindings instance:

local hyper =
  keys:createHyperBindings(
  {
    hyperKey = "f20" -- use karabiner to remap any key to f20
  }
)

secondly, add custom key bindings by using hyper:setGlobalBindings (global, top row) or hyper:setAppBindings (app-specific, bottom row), you can actually find a few examples in README.md

once you did it, you can (de)activate the "cheatsheet" with F20 (or any other hyper key you set in the config)

dmitrym0 commented 2 years ago

This is what I'm trying, but I don't get any hints:

local hyper = {"⌘", "βŒ₯", "βŒƒ", "⇧"}

local hyper =
  keys:createHyperBindings(
  {
    hyperKey = "=",
    hyperMods = hyper,
    backgroundColor = {hex = "#000", alpha = 0.9},
    textColor = {hex = "#FFF", alpha = 0.8},
    modsColor = {hex = "#FA58B6"},
    keyColor = {hex = "#f5d76b"},
    fontFamily = "JetBrains Mono",
    separator = "(✌ ゚ βˆ€ ゚)☞ –––",
    position = {x = "center", y = "bottom"}
  }
)

hyper:setGlobalBindings(
   {
      key = "r",
      fn = function()
         local result =
            hs.dialog.blockAlert("Hammerspoon", "You're about to reload hammerspoon config, are you sure?", "OK", "Cancel")

         if result == "OK" then
            hs.reload()
         end
      end
   },
   {
      key = "t",
      fn = function()
         hs.alert("test")
      end
   }

)
dmitrym0 commented 2 years ago

Ahh here it is:

2022-03-07 09:13:20: 09:13:20 ** Warning:   LuaSkin: invalid font specified: JetBrains Mono

I was missing a font, it's all good now, I see the hints.

mobily commented 2 years ago

great to hear that! πŸŽ‰ I thought if a font isn't installed, Hammerspoon will use the system font by default, but apparently, it doesn't do that

dmitrym0 commented 2 years ago

@mobily I've got a couple of other questions if you don't mind!

  1. is it possible to display the cheat sheet for the "global bindings"? Right now I only get the window when I activate the hyper mode.
  2. Once in hyper mode, the only way to deactivate it is to hit the hyper key combo again. Is there a way to quit the hyper mode once the key is hit?

So far this is really great πŸ‘

mobily commented 2 years ago

@dmitrym0

  1. do you mean the bindings that are defined in keys:setGlobalBindings? (and not in hyper:setGlobalBindings) if so, then, unfortunately, it's impossible at the moment, but I'm open to suggestions!
  2. yes, please use the hyperExitKey param, see: https://github.com/mobily/awesome-keys#spoonawesomekeyscreatehyperbindingsconfig
dmitrym0 commented 2 years ago

For #1 there is https://www.hammerspoon.org/Spoons/HSKeybindings.html, It's working fairly well for me, of course not as attractive as yours!

For #2, then awesomekeys uses the modal approach, kind of like vim?