Basically I want to show the flag of the language I am currently writing in on TouchBar if possible. I would love for this action to be included in the BTT as one of the default widgets.
I don't need the widget to be actionable in any way, just show the flag for what language I am currently using.
You can use this applescript in a widget to get your current language. You'll need to change/add the flag/icons of the languages you want though.
-- Get current language set activeKbdLayout tomy getActiveKeyboardLayout() on getActiveKeyboardLayout() set plistPath to "~/Library/Preferences/com.apple.HIToolbox.plist" try do shell script "defaults read " & plistPath & " dummy" endtry
tellapplication "System Events" repeatwith pli inproperty list itemsof ¬ property list item "AppleSelectedInputSources" of ¬ property list file plistPath try return value ofproperty list item "KeyboardLayout Name" of pli endtry endrepeat endtell end getActiveKeyboardLayout
It likely won't make any noticable difference. But compare the energy impact in Activity Monitor (just make sure to close the BTT preference window while doing so or it will seem really high).
Also, I know you said it doesn't need to be actionable, but it is possible to make it so that pressing the button rotates between languages, or you can make a group with buttons for each language you use and set them to switch to that language when pressed. Like this:
Is this still up to date for you? I made a shell script widget/group trigger for exactly this, can share it if you want.
(Besides being a shell script, I put the widget in my "settings group" with the setting "only run when visible").
Hi there @Doa.
The script doesn't seem to work with Chinese or Japanese. I think this may be because these languages have different input methods. The widget simply disappears when I switch the keyboard language to those languages. Any idea why?