GoForum🌐 V2EX

介绍一下我使用 karabiner 和 hammerspoon 的经验

dantifer · 2026-06-29 06:13 · 0 次点赞 · 0 条回复

有几个诉求:

  1. 能够在快速启动和切换 app
  2. 能够方便的把 app 移动到不同的显示器上
  3. 能够方便的调整 app 窗口的大小,比如全屏,等
  4. 其他杂七杂八的需求,比如调整音量,屏幕亮度,关屏之后自动关闭蓝牙等

解决方案就是 karabiner 和 hammerspoon 。

工作流:

  1. 使用 HyperKey + C ,就会自动打开 Chrome. 如果 Chrome 已经打开,就会切换到对应的窗口。
  2. 然后按 HyperKey + ], 就会把 Chrome 移动到下一个显示器上,然后再按 HyperKey + Enter, 就会在新显示器上全屏(非 macos 的全屏,只是调整窗口到全屏幕大小)显示 Chrome 。
  3. 如果想并排显示两个程序,就 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:

https://github.com/zfdang/macos-softwares-and-tips

https://github.com/zfdang/hammerspoon-config

0 条回复
添加回复
你还需要 登录 后发表回复

登录后可发帖和回复

登录 注册
主题信息
作者: dantifer
发布: 2026-06-29
点赞: 0
回复: 0