A modal-based window management tool built on Hammerspoon, inspired by Vim's modal system.
My collection of lua scripts for [Hammerspoon](http://www.hammerspoon.org/). It has highly modal-based, vim-styled key bindings, provides some functionality like desktop widgets, window management, application launcher, dictionary translation, cheatsheets... etc.
Add private dir for personal use Model hotkeys mapping and AppLaunchers.
- Similar to Vim's modal system
- Each modal represents a specific set of functionalities (window management, app switching, etc.)
- Users can switch between different modes via hotkeys
modalmgr = hs.hotkey.modal.new(modalmgr_keys[1], modalmgr_keys[2], 'Toggle Modal Supervisor')
- Acts as the top-level controller
- Manages entry/exit of all other modals
- Default activation:
Alt + Space
modes/
├── appM.lua -- Application management
├── clipboardM.lua -- Clipboard management
├── resizeM.lua -- Window resizing
├── viewM.lua -- View management
└── windowspace.lua -- Move Window to Space management
init.lua
loads all modules- Initializes modal manager
- Registers hotkeys for each module
- Starts default modal
- User presses
Alt + M
to enter modal manager, default key can be changed based on the private/awesomeconfig.lua - From modal manager, can choose:
Alt + A
→ Application ModeAlt + R
→ Resize ModeAlt + V
→ View ModeEscape
→ Exit Modal
modal_stat()
- Shows current modal statusmodal_bg
- Background displaymodal_show
- Status displayhotkeytext
- Hotkey hints
- All hotkeys are customizable
- Hotkey configurations stored in variables with
_keys
suffix - Examples:
modalmgr_keys
,appM_keys
,resizeM_keys
- Start Hammerspoon
- Press
Alt + M
to enter modal manager - Choose from:
Alt + A
→ Application switching modeAlt + R
→ Window resize modeAlt + V
→ View management mode- And more...
- Use corresponding hotkeys in each mode
- Press
Escape
orQ
to exit current mode
The framework is highly modular, with each functionality encapsulated in independent modals and managed uniformly through the modal manager. This design makes feature extension and maintenance relatively easy.
Feel free to submit issues and enhancement requests!
caffeinator -- Prevent computer fall asleep, controlled by bar icon.
AppLauncher -- custom launcher
AClock -- custom transparent green Digital Clock show on top left of every space.
SpaceNumber -- custom transparent green Space Number show on top right of every space.
Cheatsheet -- showavailableHotkey (you don't need to remember lots of keybindings, just call cheatsheet.)
CountDownNumber -- custom plugin to display countdown number, complete with an alert sound, with a chooser
Window Resize -- using keys to control window size
SpoonInstall -- thirdparty Plugin manager
WindowGrid -- thirdparty window manager plugin
Emojis -- thirdparty Emoji plugin
DeepLTranslate -- thirdparty translate plugin
Cherry -- thirdparty pomodoro plugin, just change some picture/time
Reload Plugins-- thirdparty reload plugin
Custom commands -- send 'exit' hotkey; hide desktop hotkey; show desktop hotkey
Clipboard -- show clipboard content
Mouse control key -- move mouse through keyboard
windowspace -- move window to lefe/right space integrated from https://github.com/Hammerspoon/hammerspoon/issues/3636#issuecomment-2384239506
- Install Hammerspoon first.
- Clone my configuration
git clone https://github.com/zzuse/hammerspoon.git ~/.hammerspoon
- Reload the configutation.
and you're set.
cd ~/.hammerspoon && git pull
init.lua
==> private config (awesomeconfig.lua
) ==> modalmgr(call basicmode.lua
) ==> loadSpoon plugins
2. The modalmgr controls entering appMode, clipboardMode, cheatsheetMode, resizeMode, viewMode, a sign on the bottom right will show mode.
Key bindings | Movement |
---|---|
⌥ + M | Mode on/off |
⌥ + A | Enter app mode |
⌥ + C | Enter clipboard mode |
⌥ + R | Enter resize mode |
⌥ + S | Enter cheatsheet mode |
⌥ + T | Count down number |
⌥ + P | Count down number pause |
⌥ + V | Enter view mode |
⌥ + I | Windows Hint |
⌥ + Z | Toggle Hammerspoon console |
⌥ + G | Plugin Window grid |
⌥ + E | Plugin Emojis |
⇧ ^ + E | send EXIT to terminal |
⇧ ^ + H | hide desktop file |
⌘ ⇧ ^ + H | show desktop file |
^ ⌥ ⌘ + C | spoon.ReloadConfigure |
^ ⌥ ⌘ + D | DeepL Translate |
^ ⌥ ⌘ + S | pomodoro timer tart |
^ ⌥ ⌘ + P | pomodoro timer pause |
^ ⌥ ⌘ + R | pomodoro timer resume |
^ ⌥ ⌘ + T | toggle current time |
Key bindings | Movement |
---|---|
H | Scroll Leftward |
L | Scroll Rightward |
J | Scroll Downward |
K | Scroll Upward |
^ + H | Move Mouse Leftward by 50px |
^ + L | Move Mouse Rightward by 50px |
^ + J | Move Mouse Downward by 50px |
^ + K | Move Mouse Upward by 50px |
⇧ + H | Move Mouse Leftward by 10px |
⇧ + L | Move Mouse Rightward by 10px |
⇧ + K | Move Mouse Upward by 10px |
⇧ + J | Move Mouse Downward by 10px |
^ ⇧ + H | Move Mouse Leftward by 1px |
^ ⇧ + L | Move Mouse Rightward by 1px |
^ ⇧ + K | Move Mouse Upward by 1px |
^ ⇧ + J | Move Mouse Downward by 1px |
, | Left Mouse Click |
. | Right Mouse Click |
Q | EXIT |
Key bindings | Movement |
---|---|
⇧ + Y | 'Shrink Leftward' |
⇧ + O | 'Stretch Rightward' |
⇧ + M | 'Stretch Downward' |
⇧ + I | 'Shrink Upward' |
F | 'Fullscreen' |
C | 'Center Window' |
⇧ + C | 'Resize & Center' |
H | 'Lefthalf of Screen' |
J | 'Downhalf of Screen' |
K | 'Uphalf of Screen' |
L | 'Righthalf of Screen' |
Y | 'NorthWest Corner' |
N | 'SouthWest Corner' |
M | 'SouthEast Corner', |
O | 'NorthEast Corner', |
= | 'Stretch Outward', |
- | 'Shrink Inward', |
⇧ + H | 'Move Leftward', |
⇧ + L | 'Move Rightward', |
⇧ + J | 'Move Downward', |
⇧ + K | 'Move Upward', |
[ | 'Focus Westward', |
] | 'Focus Eastward', |
up | 'Move to monitor above' |
down | 'Move to monitor below' |
right | 'Move to monitor right' |
left | 'Move to monitor left', |
space | 'Move to next monitor' |
Q | EXIT |
More details
UPDATE: Add new widget hcalendar
and make it default module. The design borrowed from here.
Key bindings | Movement |
---|---|
⇧⌥ + 1 | move window to one left space |
⇧⌥ + 3 | move window to one right space |
...
More details
https://github.com/zzamboni/oh-my-hammerspoon
https://github.com/scottcs/dot_hammerspoon
https://github.com/dharmapoudel/hammerspoon-config
Share your scripts and thoughts.
: )