@TOC

Operating Environment Requirements

Tested available systems: MacOS 10.14 and above Hammerspoon version: 0.9.81Copy the code

Script Functions

The following functions have been performed for the script address

  1. The status bar displays the status of the input method
  2. Time Synchronization function
  3. Screen color function
  4. JSON formatting
  5. Translation function (baidu and Youdao API support)
  6. Caffeine (set the system to never sleep)
  7. Memo function

2020-11-13—- V0.1.2 Updates

  1. Modified the initialization logic to prevent the configuration file from being modified during the update.
  2. Fixed some bugs (monitor im status stuck, caffeine status bar icon disappears without reason)
  3. After the text is selected, enter the translation shortcut key to automatically translate the selected text
  4. The Hammerspoon version needs to be at least 0.9.81

Hammerspoon configuration

Method of use

How to install

  1. Download and install Hammerspoon. Make sure it is version 0.9.81 or later, github is a little slow please wait patiently ~
  2. Delete the ~/.Hammerspoon folder if it already exists. The terminal then executes the command:
git clone https://github.com/sugood/hammerspoon.git ~/.hammerspoon
Copy the code
  1. When you run Hammerspoon, you are prompted to request accessibility rights. Please allow.
  2. If the system needs to be started, select Launch Hammerspoon at Login on the configuration page

How to update

  1. Execute the following two instructions on the terminal
Open the Hammerspoon configuration folder
cd ~/.hammerspoon
# Pull updates performed
git pull origin master
Copy the code
  1. Click hammerspoon’s Reload Config to update the configuration file

Function Description

Shortcut Key Icon

A specialized
Shift
Control
Option
Command

function

The status bar displays the status of the input method

  1. The interface is as follows

2. Function Description Can display case status, input status, Chinese and English status. Only sogou input method has been tested

Snippets and memos

  • + XAdd a snippet or memo
  • + VList fragments or memos and use them

JSON formatting

  • + GJSON formatting

Interface and function description

  1. The interface is as follows

Ps: For the first time, please right-click the window and remove substitutions -> Smart Quotas. This feature will automatically complete some characters and will cause errors if there are Chinese characters, so turn it off.

  1. Under the function into the
  • The implementation of JSON formatting function
  • Save the current data to the local
  • Json code highlighted
  • One-key replication

Automatic synchronization time

  • + TAutomatic synchronization time

Interface and function description

  1. The interface is as follows

Ps: This feature is off by default, so to use it, install Expect on the MAC and enter the power-on password in the location shown in the figure above. In general, MAC time synchronization is fine. But like my black Apple sleep wake up time is not correct, I have made sure the Bios battery is ok, also reset the system time synchronization server is not solved. Other people’s computers become inaccurate after a period of time. You can try using this feature. 2

  • Use the domestic Ali time synchronization server ntp.aliyun.com. Stability is good
  • Sync only once when the system or screen wakes up. Instead of using scheduled tasks, monitor system status for time synchronization. So, don’t worry about consuming system resources all the time.

translation

  • + Ftranslation

Interface and function description

interface

  1. Setup instructions

Support baidu and Youdao translation API. Baidu Translation can be used directly. Youdao Translation needs to apply for the Youdao Translation API and configure appKey and appSecret

  1. The interface is as follows

3. Function description

  • Support baidu translation API and Youdao translation API double engine switch. The Baidu Translation API uses my personal account. You can use it directly, or you can register and change the AppKey and AppSecret if you don’t want to use mine. Youdao Translation must register the API itself. New users sign up for 50 yuan of experience money, used up will be charged
  • Webpage details can be opened
  • Can save the data to the local, the next open can also display the last result
  • If the translation is very long. You can right click to see the details or go to the web page to see the details

Screen color function

  1. The interface is as follows

  1. Functional specifications

On the menu bar, click the screen to take color. After the interface of taking color appears, click the color picker to obtain the color value of the current mouse position on the screen

caffeine

  1. The interface is as follows

  1. Functional specifications

Click “Caffeine” on the menu bar to turn on the system never sleep function. After the function is turned on, a coffee cup icon will appear in the status bar. Click again to close it, and the coffee cup icon in the status bar will disappear

Window management

Half the screen

  • + pleaseMoves the current window to the left half screen
  • + -Moves the current window to the right half screen
  • + writeMoves the current window to the upper half screen
  • + leftMoves the current window to the lower half screen

A quarter of the screen

  • + pleaseMoves the current window to the upper left quarter of the screen
  • + -Moves the current window to the bottom right quarter of the screen
  • + writeMoves the current window to the upper right quarter of the screen
  • + leftMoves the current window to the lower left quarter of the screen

Multiple display

Move the cursor
  • + pleaseMove the cursor to the next monitor
  • + -Move the cursor to the previous display
Move the window
  • + pleaseMoves the currently active window to the previous display
  • + -Moves the currently active window to the next display
  • + 1Moves the currently active window to the first display and maximizes the window
  • + 2Moves the current active window to the second monitor and maximizes the window

other

  • + FFull screen
  • + MMaximize window
  • + CPut the window in the middle
  • + HToggle active Windows
  • + /Displays shortcut keys for window switching

System tools

  • + LLock screen

Quick start

  • + I IntelliJ IDEA
  • + T Terminal
  • + Z Calculator
  • + D Finder
  • + Q Activity Monitor
  • + S System Preferences
  • + C Google Chrome
  • + A Launchpad

conclusion

The status bar is finally not full. Happy: -)