A menu bar app to change input source swiftly using shortcuts on macOS Big Sur or later.

Overview

Source Switcher

A menu bar app to change input sources swiftly using shortcuts on macOS Big Sur and later.

View screenshots

Introduction

This app uses Applescript to manipulate UI operation which is better than using Carbon (a framework most of whose APIs are deprecated) in other tools to change input sources.

Installation / Usage

Download the release version and drop Source Switcher.app into your Applications folder. (may not be the latest version)

Or clone this repo and build it on your Mac.

Notice: You should go to System Preferences -> Security & Privacy -> Privacy -> Accessiblity to make Source Switcher able to execute Applescript on your Mac. You'd better perform this operation before you open this app for the first time. If no input source appears, just lick Reset to get your current input sources.

Notice: If you get Source Switcher.app can't be opened because Apple cannot check it for malicious software, please open your Applications folder, find Source Switcher.app and right click -> Open to open the app.

Background

Search "input source mac" on GitHub and there are plenty of repositories such as hnakamur / inputsource and minoki / InputSourceSelector. They are command line softwares, and you can easily use Alfred to add shortcuts to switch input sources conveniently. However, they have a common problem: when it comes to CJK such as Japanese, they don't work. (check InputSourceSelector issues #2 (Japanese) and stackoverflow questions #22885767 (English) to get more details)

After some analysis, I find that they all use Carbon Core, most of whose APIs are deprecated after macOS 10.8, and use the input source id (eg. com.apple.inputmethod.Kotoeri.RomajiTyping.Japanese) to identify different input sources.

laishulu / macism says it solves the problem. I'm not sure whether it works: it uses Carbon APIs and just stops for some time to deal with that problem...

Then how to solve it? The fact is, if we uses some mature exposed APIs provided by the system, issues not appear! To be concrete, we click the control center in the menu bar or switch input sources in System Preferences instead of calling macOS APIs. They are kind of UI things.

So one way is what hatashiro / kawa uses, which really solves the problem by using a method in System Preferences -> Keyboard -> Shortcuts -> Input Sources -> Select the previous input source. But issue still exists: if you change input sources quickly, you will find kawa doesn't work. This is because Select the previous input source has different functions when triggering the shortcut (⌃␣ if you haven't changed it) at a different speed. Kawa will work (as far as I consider) if change Select the previous input source to Select next source in input menu (see kawa pull #21). By the way, this project also uses Carbon APIs and this repo closes issues...

Innovatively, I use a completely UI way to solve all these problems. Referring to Geoff Taylor | Scripting the menu bar in macOS Big Sur, I use UI Browser to find how to use Applesript to express the Input Source Panel in the menu bar (Control Center). Then refer to Chris J. | How to launch an AppleScript from AppKit on Catalina with Swift to use Applescript in macOS app (which has a drawback that sandbox is disabled). After getting the prototype, I design the UI of this app, make this app a menu bar app, add shortcuts to it and better its code logic to avoid some potential bugs.

Referenced Open Source Projects

menubarpopoverswiftui2 - LICENSE

KeyboardShortcuts - LICENSE

About

Discuss about this app in the Discussion part. Check current desired features in Projects -> TODO.

Any issue or pull request are welcome!

If you find this tiny app improving your efficency, feel free to buy me a cup of coffee using WeChat Pay or Alipay.

Comments
  • ⌘I

    ⌘I "About" tab is broken with overflown Input Sources

    First of all, applause for this new method to switch input sources without irritation! Kawa has add a forced "Switching to US first" method to overcome CJKV problem, but Source Switcher is doing more neatly.

    This is the only graphical glitch I have found: Source Switcher About tab glitch

    Steps to reproduce:

    • Press About in the main dropdown menu of Source Switcher
    • The space above the introduction of the app is broken by too many input sources (I have 15...)
    • ⌘I toggles between the broken view and the main menu
    opened by GJRobert 4
  • The about window should only show on first run

    The about window should only show on first run

    I set the app to run on login, and the about window shows every time when the app is opened. It should only show when the app runs for the first time.

    opened by zcbenz 3
  • The dock icon should be hidden

    The dock icon should be hidden

    The menubar apps generally do not have dock icons. App should only have dock icons when it has a main window to show, otherwise giving focus to the app is meaningless.

    This app only has one about window, which users usually do not want to see.

    opened by zcbenz 2
  • 能识别搜狗输入法通过 shift 切换的中英文的状态吗?

    能识别搜狗输入法通过 shift 切换的中英文的状态吗?

    搜狗输入法 for Mac - 支持全拼、双拼、模糊输入、苹果输入、云输入 这一个输入法,在需要使用英文时,我使用 shift 来切换(搜狗支持通过配置 shift 切换中英文),而不是使用系统的英文输入法。

    你软件能获取搜狗的英文状态吗?因为你软件似乎是把搜狗中英文状态当成了一种,因此只能给搜狗输入法设置一个快捷键,而不能指定搜狗输入法的中文和英文分别设置快捷键。

    opened by GanZhiXiong 1
  • AppleScript not works in macOS 12 Monterey

    AppleScript not works in macOS 12 Monterey

    The AppleScript below does not work for Monterey. Is it a related issue?

    	tell application "System Events"
    		tell process "TextInputMenuAgent"
    			click menu item layoutName of menu 1 of menu bar item 1 of menu bar 2
    			click menu bar item 1 of menu bar 2
    		end tell
    	end tell
    

    Originally posted by @martinmts in https://github.com/Yang-Xijie/InputSourceSwitcher/issues/14#issuecomment-955085182

    opened by Yang-Xijie 8
  • Dispositioned Popover

    Dispositioned Popover

    statusBarItem?.button?.action = #selector(AppDelegate.togglePopover(_:))
    // When starting the app, show the popover. If don't do like this, open the app and shortcuts will not work until click the icon on the menu bar.
    DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
        if let button = self.statusBarItem?.button {
            self.popover.show(
                relativeTo: button.bounds,
                of: button, preferredEdge: NSRectEdge.minY)
        }
    }
    

    The problem is that if the user hide the menu bar (System Preferences -> Dock & Menu Bar -> Dock & Menu Bar -> Automatically hide and show the menu bar -> checked), the popover will appear on the top left corner of the screen, instead of appearing below the menu bar icon.

    Also check https://github.com/zaferarican/menubarpopoverswiftui2/issues/3#issuecomment-894803220

    opened by Yang-Xijie 0
Releases(v1.3)
Owner
A student in Department of Electronic Engineering, Tsinghua University. A leader in Developing Group of THU iOS Club.
null
macOS (>11.0) Menu Bar App for WLED

wledQuickControl functions Left click on the Menubar icon will toggle the WLED device On/Off Right click on the Menubar icon: will update the icon/sli

satrik 15 Nov 8, 2022
adb-tools-mac is a macOS menu bar app written in SwiftUI for common adb tools.

adb-tools-mac is a macOS menu bar app written in SwiftUI for common adb tools.

Naman Dwivedi 930 Jan 2, 2023
Ambar is a macOS Menu Bar app built with SwiftUI.

Ambar Ambar is a macOS Menu Bar app built with SwiftUI. It is a template project which means that it can be used as a starting point for a new Menu Ba

null 16 Nov 14, 2022
macOS menu bar app that displays the current status of SIP (System Integrity Protection)

MenuBarSIPDetector This is a DEMO app for my Swift library TINURecovery and it is a macOS menu bar app that displays the current status of SIP (System

null 19 Dec 18, 2022
a simple macOS menu bar application that shows you the lyrics of current playing spotify track.

lyricsify a simple macOS menu bar application that shows you the lyrics of current playing spotify track.

Krisna Pranav 4 Sep 16, 2021
SwiftBar - Powerful macOS menu bar customization tool

SwiftBar - Powerful macOS menu bar customization tool

SwiftBar 2k Jan 8, 2023
Barber lives in your macOS menu bar and keeps track of what needs to be updated.

Barber Barber is a macOS application to keep track of application updates easily. It lives in your menu bar, and uses homebrew to determine what's out

Max Ainatchi 1 Nov 30, 2021
Control your display's brightness from the macOS menu bar. Simple and easy to use.

MonitorControl Lite Control your display's brightness from the macOS menu bar. Simple and easy to use. About MonitorControl Lite is a simplified versi

null 62 Dec 11, 2022
Let's put notification Messages icon on menu bar of your macOS

DockBar DockBar is just a simple app that show messages icon on your status bar when you have unread messages. This app is very useful for people who

Bastard.y 5 Aug 16, 2022
Paimon's now in your macOS menu bar

PaimonMenuBar Paimon's now in your menu bar! Demo What's this? Genshin Impact has got a complicated daily system, consisting of: 4 Daily commisions. 5

Spencer Woo 138 Dec 30, 2022
Weather Dock is a MacOS headless application that shows popover view under the menu bar with weather info.

Weather Dock Weather forecast in MacOS menu bar Weather Dock is a MacOS headless application that shows popover view under the menu bar with weather i

Alexander Stepanischev 8 Dec 15, 2022
Swift-sidebar-menu-example - Create amazing sidebar menu with animation using swift

 SWIFT SIDEBAR MENU EXAMPLE In this project I create a awesome side bar menu fo

Paolo Prodossimo Lopes 4 Jul 25, 2022
SwiftySideMenu is a lightweight and easy to use side menu controller to add left menu and center view controllers with scale animation based on Pop framework.

SwiftySideMenu SwiftySideMenu is a lightweight, fully customizable, and easy to use controller to add left menu and center view controllers with scale

Hossam Ghareeb 84 Feb 4, 2022
A Slide Menu, written in Swift, inspired by Slide Menu Material Design

Swift-Slide-Menu (Material Design Inspired) A Slide Menu, written in Swift 2, inspired by Navigation Drawer on Material Design (inspired by Google Mat

Boisney Philippe 90 Oct 17, 2020
Slide-Menu - A Simple Slide Menu With Swift

Slide Menu!! Весь интерфейс создан через код

Kirill 0 Jan 8, 2022
EasyMenu - SwiftUI Menu but not only button (similar to the native Menu)

EasyMenu SwiftUI Menu but not only button (similar to the native Menu) You can c

null 10 Oct 7, 2022
Hamburger Menu Button - A hamburger menu button with full customization

Hamburger Menu Button A hamburger menu button with full customization. Inspired by VinhLe's idea on the Dribble How to use it You can config the looks

Toan Nguyen 114 Jun 12, 2022
The elegant yet functional dropdown menu, written in Swift, appears underneath the navigation bar to display a list of defined items when a user clicks on the navigation title.

Introduction The elegant yet functional dropdown menu, written in Swift, appears underneath the navigation bar to display a list of defined items when

Tho Pham 2.7k Dec 28, 2022
Mac menu bar tool to view the architecture of the running application

Silicon Info About Silicon Info is a tiny menu bar application allows the user to quickly view the architecture of the currently running application.

William Castelli (Billy) 260 Dec 29, 2022