koekeishiya / skhd

Simple hotkey daemon for macOS
MIT License
6.05k stars 204 forks source link

Can we get more examples of skhdrc #329

Open simonvdm opened 8 months ago

simonvdm commented 8 months ago

Introduction

Hello @koekeishiya , thanks for managing this great project. I really like the syntax and simplicity. Super happy with the first results.

I have to admit I am struggling to completely grasp all the features of skhd just from the lexical description. It's also not obvious for me how to build some real life cases (mostly related to yabai usage).

I looked online for examples skhdrc and found some but they don't cover all the cases I'm interested in and I would sometimes needs some explanatory comments.

Would it be possible to provide one or several examples of common uses?

Specifically

How does one setup a leader key?

This is my take. I don't know whether it's good practice though.

rcmd - d ; windows
windows < escape; default

windows < h : yabai -m window --focus west && skhd -k "escape"
windows < j : yabai -m window --focus south && skhd -k "escape"
windows < k : yabai -m window --focus north && skhd -k "escape"
windows < l : yabai -m window --focus east && skhd -k "escape"

How do I jump to a specific window of an application?

I have hotkeys for common apps. Certain apps (like Sunsama) have more than window open. How do I jump to the right one. They have different names so I presume it would be a series of calls on yabai (query and such).

rcmd - q : open -a ScreenSaverEngine
rcmd - f : open -a /Applications/Todoist.app
rcmd - j : open -a /Applications/Sunsama.app
...

How do I ensure new apps are created on new desktops every time?

For a know app (ie: todoist), open it if it does not exist, switch to it if it already does (example above). But, when you open it, put it on it's own desktop by default (crreate one I guessà.

What does @ do exactly?

What is it good for? Can we have some real-life examples?

What does proc_map do?

How does one use *, -> and tilde in practice?

Switch display in batch for a predefined list of apps

This is very much a Yabai question so may be off topic here.

I often switch been mono display (on the move) and dual display (at desk). I'd like to have a key binding (and/or script) that moves all my typical apps to the right display when I switch to dual. ie: when I presse a key, move the following apps to display 2: browser, terminal, mail, etc ...

Any pointers/pseudo code you could provide would be appreciated.

Thank you very much! Simon

PhrantiK commented 7 months ago

I have the same struggles with tools like this. The docs/man pages are usually a pretty dry read and I have a brain that is smoother than a lubed up slippery slide.

The best way I have found to find real-life examples is by doing a path search on git and shamelessly stealing from people that have figured it out:

https://github.com/search?q=path%3Askhd%2Fskhdrc&type=code

I finally got the mode feature nailed in my config by lifting it out of this blokes config:

https://github.com/typkrft/chezmoi/blob/29dea8810f355c1e5103d68707fc8075e81e911f/dot_config/skhd/skhdrc

Every so often you'll find a grail that has a ton of comments in it like the above and the penny will finally drop.