Pocketed input macOS 2 It is how to restart the free activation input method

On macOS,Install the input method has always been a nightmare,To open the system input method directory,We should drag input into this directory,The process also enter a password,Full manual bad enough,After we had to reboot the system to recognize,Not really a headache。

Later, we gradually realized the problem,Pocketed input method is also provided macOS standard installation package pkg。

Having said that,But in fact it seems that there is a way to automatically load input method,such asSogouHe did restart free,After installing only be able to identify without rebooting,Even the automatic installation package can also help you choose the right Sogou input method!

They do not know exactly how,I also have conducted my own research。

Profiles

In short,Everything is starting from the configuration file,First, I found the system configuration file to be read,This file determines which input method is currently active users,The selected input method which is:

In this plist.,have Appleanbledinputsourches Field,This side contains the current input method which is enabled,For example, Sogou input method、R0uter Input Tool、Pinyin system, etc.; AppleInputSourceHistory Field contains the user's history switch,It seems to be related and automatically switch; AppleSelectedInputSources Field indicates the current input method selected by the user,For example, you currently useR0uter Input ToolTyping,This is off the grid input method,If you switch to the English keyboard,This will become an English keyboard。

In theory,We edit this file,You can change the configuration of the system,But apparently,This profile is not real-time read,We edit the file,Restart preference management system and the terminal command Finder: killall cfprefsd && killall Finder

Good luck,He has the ok。

In fact ---,Generally you will not be lucky。

Obviously,Want insurance, then,Or restart the job。In short,This is already a progress,After all, does not require the user to manually add the complete restart input method, right?

System-level API

Then,Can there other more elegant options? I ended up in Carbon Framework found the answer:

For Swift is,Also calls painless,After we installed input method,Only need to input method app file passed to the function address,It can be registered in the system input method,This time it can make without having to reboot the system to recognize input method:

Remember import Carbon

Then,I also want the system automatically shuts down the list to add my input method (ie activate input method):

This function is called it will not be so easy,The main difficulty is this TISInputSource No way to directly create,So to use another function to search,We have registered a fall in input grid system,The next step is to find pocketed input This input source in all of the available input methods,If the direct exhaust all available input sources,It will be very slow (API exact words),We need to add search conditions:

If there is no accident,We can get off the grid input method of the input source,There are two,One is the input method,A real model is used to input the user can enter (at both the user's perspective is the same,Off the grid because there is only one input method input mode - two in English mode is the only mode of different states)。

Then there is the added:

This time,Users can immediately switch in the upper right corner after installation to click off the grid input - good luck,You do not even need to switch。

discuss

This method looks very good,It seems from macOS 10.5 You can start with,But the real test to see only the latest macOS Mojave 10.14 It's effective,I'm here 10.13 The test is invalid,Whether to change the configuration or call the system API,All indifferent,I prefer my version of this particular system bug,Since when has the top right corner off the input method of the API call icon,However, the selection list is not pocketed input method,Even registration failed。

In short,for 10.14 New users,Installation pocketed experience input becomes excellent。

Original article written by LogStudio:R0uter's Blog » Pocketed input macOS 2 It is how to restart the free activation input method

Reproduced Please keep the source and description link:https://www.logcg.com/archives/3263.html

About the Author

R0uter

The non-declaration,I have written articles are original,Reproduced, please indicate the link on this page and my name。

Leave a Reply

Your email address will not be published. Required fields are marked *