Hammerspoon Utilities Documentation

Introduction

This repository provides a set of utility functions built for the Hammerspoon macOS automation tool。These functions allow you to manage your clipboard history,control the positions of your mouse across applications,and execute custom shell commands via keybindings。With this toolset,you can enhance your productivity and make your macOS experience smoother and more streamlined。

Table of Contents

  1. Prerequisites
  2. Installation
  3. Usage
  4. Contributing
  5. License
  6. FAQs
  7. Troubleshooting
  8. Known Issues

Prerequisites

  • macOS:The scripts are tailored for macOS,leveraging the capabilities of Hammerspoon。

  • Hammerspoon:Ensure that you have Hammerspoon installed。It’s a bridge between the operating system and a Lua scripting engine。

Installation

  1. Clone this Repository

    1
    git clone https://github.com/zengtianli/hammerspoon.git
  2. Navigate to Hammerspoon Configuration Folder

    1
    cd ~/.hammerspoon/
  3. Copy the Script:Move the cloned Lua script to the Hammerspoon configuration directory or incorporate its functionalities into your existing init.lua

  4. Reload Hammerspoon:Use the Hammerspoon menu icon to reload the configuration or press the default cmd + ctrl + shift + reload key combination。

Usage

Clipboard Manager

Keybindings:

  • Combine Clipboard Histories:cmd + alt + C
  • Clear Clipboard History:cmd + alt + ctrl + C

Mouse Position Control

Record,recall,and manipulate mouse positions across different apps。

Keybindings:

  • Record mouse position for the active app:cmd + ctrl + shift + R
  • Clear recorded positions for the active app:cmd + ctrl + shift + C
  • Move mouse to a specified position (1,2,or 3) for the active app:cmd + ctrl + shift + [1/2/3]
  • Move mouse to next/previous recorded position:alt + tab / alt + shift + tab

Shell Commands Execution

Trigger specific shell commands via keybindings。

Keybindings:

(Replace shellScripts.[command] with actual commands or scripts you’ve defined。)

  • Toggle Yabai:cmd + shift + y
  • Close Window:cmd + shift + w
  • Toggle Floating Tiling:cmd + shift + l
  • Swap with Next or Move to First:cmd + shift + j
  • Toggle Fullscreen:cmd + ctrl + f
  • Focus on Next or Move to First:cmd + j

Contributing

Contributions are welcome!If you find a bug or would like to add a new feature,feel free to create an issue or open a pull request。

License

This project is licensed under the MIT License。For more details,see the LICENSE file。

FAQs

Troubleshooting

  • **Script not executing?**Ensure that Hammerspoon has the necessary accessibility permissions under System Preferences > Security & Privacy > Privacy。

Known Issues

  • Moving the mouse to recorded positions may not work seamlessly across multiple monitors or virtual desktops。Ensure that the app is on the same screen as the original recording。

For more details,questions,or feedback,please raise an issue or get in touch。Happy coding!🚀