All Projects → oniatsu → HotSwitch-HS

oniatsu / HotSwitch-HS

Licence: MIT License
Window switcher app using 2 stroke hotkey for macOS

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to HotSwitch-HS

HotSwitch
Fastest window switcher using 2 stroke hotkey for macOS
Stars: ✭ 46 (+283.33%)
Mutual labels:  window-manager, window-switcher
Spacehammer
Hammerspoon config inspired by Spacemacs
Stars: ✭ 280 (+2233.33%)
Mutual labels:  hammerspoon, window-manager
dotfiles
🏡 There's no place like ~/
Stars: ✭ 59 (+391.67%)
Mutual labels:  hammerspoon, window-manager
Stackline
Visualize yabai window stacks on macOS. Works with yabai & hammerspoon.
Stars: ✭ 195 (+1525%)
Mutual labels:  hammerspoon, window-manager
forge
Forge - Tiling and Window Manager for Gnome-Shell
Stars: ✭ 144 (+1100%)
Mutual labels:  window-manager, window-management
hammerspoon
Boosts productivity and adds useful features to OSX.
Stars: ✭ 18 (+50%)
Mutual labels:  hammerspoon, window-manager
mx
Framework window manager for macOS
Stars: ✭ 45 (+275%)
Mutual labels:  window-manager, window-management
dotfiles
CLI, Emacs, Hammerspoon
Stars: ✭ 20 (+66.67%)
Mutual labels:  hammerspoon
maxwelm
Maxwelm is a simple window manager for small displays
Stars: ✭ 20 (+66.67%)
Mutual labels:  window-manager
fusuma-plugin-wmctrl
Window Manager plugin for Fusuma
Stars: ✭ 36 (+200%)
Mutual labels:  window-manager
dotfiles
💎 My vim/neovim, fish, git, and tmux configuration files
Stars: ✭ 49 (+308.33%)
Mutual labels:  hammerspoon
eseed-window
A minimal cross-platform C++17 window management library for rendering (deprecated)
Stars: ✭ 18 (+50%)
Mutual labels:  window-manager
dotfiles
⚡️ Sharpen dat knife.
Stars: ✭ 29 (+141.67%)
Mutual labels:  hammerspoon
dotfiles
🗿 dotfilery, configuration, environment settings, automation, etc. 🛖
Stars: ✭ 67 (+458.33%)
Mutual labels:  hammerspoon
gobble
Rust rewrite of Devour
Stars: ✭ 23 (+91.67%)
Mutual labels:  window-manager
conductor
A lightweight OS X window manager for hackers
Stars: ✭ 24 (+100%)
Mutual labels:  window-manager
qtile-config
My ~/.config/qtile
Stars: ✭ 25 (+108.33%)
Mutual labels:  window-manager
ModMove
Move/Resize windows using modifiers and the mouse
Stars: ✭ 86 (+616.67%)
Mutual labels:  window-manager
glfwm
GLFW Manager - C++ wrapper with multi-threading
Stars: ✭ 60 (+400%)
Mutual labels:  window-manager
hammerspoon-vimouse
Control the mouse with Hammerspoon in a Vim-ish way
Stars: ✭ 19 (+58.33%)
Mutual labels:  hammerspoon

What is HotSwitch-HS

top

HotSwitch-HS is a window switcher using 2 stroke hotkey for macOS.

It provides fastest window switching, no matter how many windows there are. HotSwitch-HS uses Hammerspoon, and is rewritten for a substitution of HotSwitch.

You can switch any windows by like command + . + x (this key is always fixed).

HotSwitch-HS's window switching steps is these.

  1. Register a fixed key to windows on list. (Press Space. It's easy and fast.)
  2. Switch any windows by using the key you registered. (You can switch in a flash without thinking time.)

In addition, HotSwitch-HS provides auto generated keys before your key registration. However, I highly recommend that you register keys, because it enable you to switch windows faster than ever.

Usage

Simple way

Try it. It's easy and fast to understand.

Key Action
The key you set Open or close the HotSwitch-HS panel
Space Toggle registration mode
Tab or Down Select a next window
Shift+Tab or Up Select a previous window
Delete Delete the key on the selected window
Return Focus the selected window
Escape Close the panal
[a-zA-Z0-9] Focus the window or register the key
- or [ or ] or . or / Focus the window or register the key

Details

Concretely, HotSwitch-HS's window switching steps is these.

  1. Register a fixed key to windows on list.
  2. Switch any windows by using the key you registered.

1. Register a fixed key to windows on list.

  1. Open HotSwitch-HS panel. (Press command + . that you registered)
  2. Select a window on lists. (Press Tab or cursor keys.)
  3. Chanege the panel to registeration mode. (Press Space)
  4. Register a fixed key to the window. (Press any character keys. a, b, c, etc.)

The registered key become a reserversion key, so the key doesn't appear as auto generated keys.

If you want to delete a registered key combined with the window, select the window on lists and press Delete.

2. Switch any windows by using the key you registered.

  1. Open HotSwitch-HS panel. (Press command + . that you registered)
  2. Switch the target window by using a fixed key. (Press the key you registered.)

It looks like that 2 stroke hotkey is working to focus any windows. The important thing is that the 2 stroke key bind is fixed anytime.

That is why window switching by HotSwitch-HS is always fastest.

Installation

1. Install Hammerspoon

2. Download HotSwitch-HS

In terminal, execute a command. You need to place a directory to hotswitch-hs.

git clone https://github.com/oniatsu/HotSwitch-HS.git ~/.hammerspoon/hotswitch-hs

Directory tree is like this:

~/.hammerspoon/
├── init.lua
└── hotswitch-hs/
  ├── lib/
  ├── LICENSE
  ├── README.md
  └── hotswitch-hs.lua

If you have installed Hammerspoon just right now, ~/.hammerspoon/init.lua doesn't exist yet.

3. Put a code at your Hammerspoon's ~/.hammerspoon/init.lua

If the file does not exist, create it and add the codes.

local hotswitchHs = require("hotswitch-hs/hotswitch-hs")
hotswitchHs.enableAutoUpdate() -- If you don't want to update automatically, remove this line.
hs.hotkey.bind({"command"}, ".", hotswitchHs.openOrClose) -- Set a keybind you like to open HotSwitch-HS panel.

For example, you can set the keybind to open HotSwitch-HS like these.

-- These are valid.
hs.hotkey.bind({"command"}, ".", hotswitchHs.openOrClose) -- command + .
hs.hotkey.bind({"command"}, ";", hotswitchHs.openOrClose) -- command + ;
hs.hotkey.bind({"option"}, "tab", hotswitchHs.openOrClose) -- option + tab
hs.hotkey.bind({"control"}, 'space', hotswitchHs.openOrClose) -- control + space
hs.hotkey.bind({"command", "shift"}, "a", hotswitchHs.openOrClose) -- command + shift + a

-- These are NOT valid normally. Hammerspoon cannot override the keys, because the keys may be registered and used by macOS.
hs.hotkey.bind({"command"}, "tab", hotswitchHs.openOrClose) -- command + tab
hs.hotkey.bind({"command"}, "space", hotswitchHs.openOrClose) -- command + space

Here is how to set hs.hotkey.bind().

Advanced option

If you want to replace the macOS's app switcher command + tab with HotSwitch-HS, you can do forcibly by using Karabiner-Elements.

~/.config/karabiner/karabiner.json

{
    "from": {
        "key_code": "tab",
        "modifiers": { "mandatory": [ "command" ] }
    },
    "to": [ {
        "key_code": "f13"
    } ],
    "type": "basic"
}

~/.hammerspoon/init.lua

hs.hotkey.bind({}, "f13", hotswitchHs.openOrClose)

4. Run Hammerspoon

And open HotSwitch-HS panel by using the keybind you set. If you have some probrems, check these.

Preferences

If you want to set some preferences, you can use some option by adding codes at ~/.hammerspoon/init.lua.

For example:

local hotswitchHs = require("hotswitch-hs/hotswitch-hs")
hotswitchHs.enableAutoUpdate()
hotswitchHs.setAutoGeneratedKeys({"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"})
hotswitchHs.enableAllSpaceWindows()
hs.hotkey.bind({"command"}, ".", hotswitchHs.openOrClose)

See below to know what these means.

Auto update

Add this. It will update HotSwitch-HS by git pull automatically when needed.

hotswitchHs.enableAutoUpdate()

Auto generated keys

You can define auto generated keys. The order you specified will be used to generate keys.

hotswitchHs.setAutoGeneratedKeys({"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"})

Default auto generated keys are these.

Showing all space windows

If you want to see all space windows on the lists, add this.

hotswitchHs.enableAllSpaceWindows()

Default: the current space windows are only shown.

Additonal symbol keys

You can add symbol keys to register windows. (Only the Japanese keyboard layout symbols are available now.)

hotswitchHs.addJapaneseKeyboardLayoutSymbolKeys()

Always showing the panel on primary screen

To show the panel not on main screen but on primary screen. Main screen is the one containing the currently focused window.

hotswitchHs.setPanelToAlwaysShowOnPrimaryScreen()

If you have some probrems,

Check these.

  • If the keybind you set is not enabled, open Hammerspoon console and check some error messages. First, click Hammerspoon's menubar icon. Second, click Console....
  • Update HotSwtich-HS. cd ~/.hammerspoon/hotswitch-hs && git pull

Known issues

Sometimes, getting windows is failed after the macOS has woken up from sleep.

It would be fixed by reloading Hammerspoon config. It's possibly Hammerspoon's bug. I recommend that you add a keybind to reload Hammerpoon config quickly.

-- For example: you can reload by "command + option + control + r".
hs.hotkey.bind({"command", "option", "control"}, "r", hs.reload)
hs.hotkey.bind({"command"}, ".", hotswitchHs.openOrClose)
-- It's message showing the completion of reloading.
hs.alert.show("Hammerspoon is reloaded")

Update manually

cd ~/.hammerspoon/hotswitch-hs
git pull

Uninstallation

rm -rf ~/.hammerspoon/hotswitch-hs

Development

Requirements

  • Hammerspoon

Steps

  1. Edit codes.
  2. Reload Hammerspoon config and check that it's working correctly.

Owner's steps

  1. Check latest git tag. (git describe --tags --abbrev=0)
  2. Add a new git tag.
  3. Push the tag. Then, the release on GitHub is automatically created.

Option

If you would update the class diagram,

  1. Install PlantUML. (brew install graphviz && brew install plantuml)
  2. Edit doc/uml/class_diagram.pu.
  3. Execute plantuml doc/uml -o ../img at your terminal.

Directory structure

The class diagram is roughly like this.

class_diagram

Note

  • Pay attention to Lua's garvage collection.

Some ChangeLogs

  • v2.2.5: Add option to always show the panel on primary screen
    • hotswitchHs.setPanelToAlwaysShowOnPrimaryScreen()
  • v2.1.5: Change saving keys to use bundleID instead of app name
    • If you used this app before this version, you need register keys again.
  • v2.1.0: Add auto updater
    • hotswitchHs.enableAutoUpdate()
  • v2.0.0: Connect Git tag with GitHub Release
  • v1.17: Add auto generated keys
  • v1.4: Change app info text to app icon on panel
  • v1.0: First release
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].