Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vim-like modal keybindings workflow #152

Open
nikhgupta opened this issue Nov 16, 2020 · 9 comments
Open

vim-like modal keybindings workflow #152

nikhgupta opened this issue Nov 16, 2020 · 9 comments

Comments

@nikhgupta
Copy link

nikhgupta commented Nov 16, 2020

Hello,

I wanted to share my skhd keybindings that I use with (SIP disabled) yabai to manage windows, launch apps, etc.
I am using skhd as a central place for triggering shortcuts.

https://github.com/nikhgupta/dotfiles/blob/osx/user/.config/skhd/skhdrc#L74-L128
^^ can be useful for VIM users. I can trigger my vim bindings using SPACE as leader and OSX bindings using CAPS LOCK as leader key.

However, I have one simple issue - when space does not have any windows, I can not display borders to know which modal state I am in.

  • I searched for AppleScript to display an overlay screen, but could not find one.
  • I, also, used hammerspoon but it had an issue that resulted in slow yabai commands.
  • I can display this modal state via Alfred or Ubersicht, but if possible I would prefer to rely on skhd, and terminal commands alone.
  • I can display a custom wallpaper with the current modal state as text for this purpose, but it's a bit complicated to setup.

If anyone has any ideas for displaying modal state or better yet, display cheat sheet for possible keybindings, please advise.

@MuhammedZakir
Copy link

If you stay in a mode only for a short time, then a simple notification using AppleScript is probably enough? If you want to know your current mode anytime, a simple(?) method would be to write your current mode to a file [1] each time you enter/exit one. Then, you can assign a key for calling a notification with that file's content, i.e. the current mode.

[1] This can be avoided if skhd supports setting/getting a variable.

@nikhgupta
Copy link
Author

nikhgupta commented Nov 16, 2020

If you stay in a mode only for a short time, then a simple notification using AppleScript is probably enough? If you want to know your current mode anytime, a simple(?) method would be to write your current mode to a file [1] each time you enter/exit one. Then, you can assign a key for calling a notification with that file's content, i.e. the current mode.

[1] This can be avoided if skhd supports setting/getting a variable.

Would not that be a very obtrusive approach to any workflow?

  • It's not instant (keypresses are often very fast)
  • We can't display a lot of key bindings (aka cheat-sheet)
  • Has side-effects: these alerts would remain in Notification Center.

I am looking for something like this (ideally): ref


@MuhammedZakir
Copy link

MuhammedZakir commented Nov 17, 2020

Would not that be a very obtrusive approach to any workflow?

  • It's not instant (keypresses are often very fast)

  • We can't display a lot of key bindings (aka cheat-sheet)

  • Has side-effects: these alerts would remain in Notification Center.

I am looking for something like this (ideally): ref

![](https://github.com/casouri/lunarySpoon/raw/master/screenshot/screenshot0.png)
![](https://github.com/casouri/lunarySpoon/raw/master/screenshot/screenshot1.png)

I thought you only want to know the name of current mode you are in. That's why I suggested notification. Many do the same thing with Karabiner-Elements too!* But, if you want to show next possible commands, then this indeed will be very difficult and ugly using alerts.

* You don't need to write to a file, however, as KE has conditionals.

Edit: About Hammerspoon: How slow was it? If it's really slow, do open an issue in Hammerspoon repo.

@dsanson
Copy link

dsanson commented Mar 27, 2021

I use spacebar https://github.com/cmacrae/spacebar, and have these lines in my skhdrc, which change the background color of spacebar when I change modes:

:: default : spacebar -m config background_color 0xff202020
:: m1 @ : spacebar -m config background_color  0xee009900
:: m2 @ : spacebar -m config background_color  0xee990000

There isn't any lag.

@nikhgupta
Copy link
Author

nikhgupta commented Apr 21, 2021

@dsanson I was staying away from spacebar - it has some bugs. But, I liked your idea and started using it and implemented the same workflow. However, I still need to display cheat-sheet when I enter a particular mode - would be very handy. Preferably, I would want it to set an overlay over the whole screen and display available commands starting with that mode/chords. That would be a perfect setup :)

@dsanson
Copy link

dsanson commented Apr 21, 2021

Not quite what you want, but this is a decent gui fuzzy finder for OSX:

https://github.com/chipsenkbeil/choose

Not too hard to feed it a list of all your shortcuts with descriptions. That gives you a kind of cheatsheet, and it can be easily invoked from skhd. (While you are at it, might as well write a script that parses your selected command, and uses skhd -k to execute it for you.)

@nikhgupta
Copy link
Author

nikhgupta commented Apr 22, 2021

@dsanson - ty. This is perfect - and exactly the last piece (rofi) in my switch from Arch to OSX. This is my ArchLinux setup and the rofi integration used to look like this.

@glingy
Copy link

glingy commented Nov 3, 2022

I'll add that I just made a GUI like what was mentioned here since I wanted it too: https://github.com/glingy/skhdgui. It displays a window in the upper right corner when you are in a mode which lists possible shortcuts from that mode.

@es183923
Copy link

es183923 commented Nov 3, 2022

You can also take a look at sketchybar. specifically this post: FelixKratz/SketchyBar#12
Also, you can take advantage ov sketchybar's popups feature to show the possible shortcuts.
also, https://github.com/es183923/query-skhd is a POC of a way to easily parse the skhd config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants