有几个诉求:
- 能够在快速启动和切换 app
- 能够方便的把 app 移动到不同的显示器上
- 能够方便的调整 app 窗口的大小,比如全屏,等
- 其他杂七杂八的需求,比如调整音量,屏幕亮度,关屏之后自动关闭蓝牙等
解决方案就是 karabiner 和 hammerspoon 。
工作流:
- 使用 HyperKey + C ,就会自动打开 Chrome. 如果 Chrome 已经打开,就会切换到对应的窗口。
- 然后按 HyperKey + ], 就会把 Chrome 移动到下一个显示器上,然后再按 HyperKey + Enter, 就会在新显示器上全屏(非 macos 的全屏,只是调整窗口到全屏幕大小)显示 Chrome 。
- 如果想并排显示两个程序,就 HyperKey + ->, chrome 就只占据屏幕的右半边。另外一个程序,按 HyperKey + <-, 则它就会占据屏幕的左半边。
=========
Karabiner 的作用,是创建一个 hyper key. 我是把 caps lock 键,映射成了 control + option + command + shift. 所以按下 caps lock 键,就相当于触发了这四个键的组合。
hammerspoon 的作用是根据快捷键,来做各种操作。目前配置了如下的快捷功能:
HyperKey: {"cmd", "alt", "ctrl", "shift"}
HyperKey + l: lock screen
HyperKey + b: show battery status on screen
HyperKey + [: move app to left screen
HyperKey + ]: move app to right screen
HyperKey + return: maximize current window
HyperKey + left: resize current window to the left half of the screen
HyperKey + right: resize current window to the right half of the screen
HyperKey + up: resize current window to the top half of the screen
HyperKey + down: resize current window to the bottom half of the screen
HyperKey + x: launch application by x (see key2App in key-bindings.lua, you can customize it in your own way)
{"CMD","Ctrl"} + up: volume up
{"CMD","Ctrl"} + down: volume down
{"option","Ctrl"} + up: screen brightness up
{"option","Ctrl"} + down: screen brightness down
=========
github repos: