# Is it possible to show current \`Text Input\` language on TouchBar

**URL:** <https://community.folivora.ai/t/is-it-possible-to-show-current-text-input-language-on-touchbar/3633>\
**Category:** Configuration Help & General Discussion\
**Tags:** touch-bar\
**Created:** [September 10, 2018, 12:56pm UTC](https://community.folivora.ai/t/is-it-possible-to-show-current-text-input-language-on-touchbar/3633 "2018-09-10T12:56:51Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikivi](https://community.folivora.ai/user_avatar/community.folivora.ai/nikivi/32/8641_2.png) [@nikivi](https://community.folivora.ai/u/nikivi)\
**Post date:** [September 10, 2018, 12:56pm UTC](https://community.folivora.ai/t/is-it-possible-to-show-current-text-input-language-on-touchbar/3633/1 "2018-09-10T12:56:51Z")

</div>

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.

Thank you.

---

<div class="post-metadata">

**Author:** ![Doa](https://community.folivora.ai/user_avatar/community.folivora.ai/doa/32/12562_2.png) [@Doa](https://community.folivora.ai/u/Doa)\
**Post date:** [September 10, 2018, 5:55pm UTC](https://community.folivora.ai/t/is-it-possible-to-show-current-text-input-language-on-touchbar/3633/2 "2018-09-10T17:55:17Z")

</div>

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 **to**  **my** getActiveKeyboardLayout()  
> **on** getActiveKeyboardLayout()  
> **set** plistPath **to**"~/Library/Preferences/com.apple.HIToolbox.plist"  
> **try**  
> **do shell script**"defaults read " & plistPath & " dummy"  
> **end**  **try**
> 
> **tell** _application_ "System Events"  
> **repeat**  **with** pli **in** _property list items_ **of** ¬  
> _property list item_ "AppleSelectedInputSources" **of** ¬  
> _property list file_ plistPath  
> **try**  
> **return** value **of** _property list item_ "KeyboardLayout Name" **of** pli  
> **end**  **try**  
> **end**  **repeat**  
> **end**  **tell**  
> **end** getActiveKeyboardLayout
> 
> - **- Make it return flag instead of words.**
> 
> **if** activeKbdLayout **is**"Khmer" **then**
> 
> **return**"🇰🇭"
> 
> **else**  **if** activeKbdLayout **is**"U.S." **then**
> 
> **return**"🇺🇸"
> 
> **else**  **if** activeKbdLayout **is**"Greek" **then**
> 
> **return**"🇬🇷"
> 
> **else**  **if** activeKbdLayout **is**"French" **then**
> 
> **return**"🇫🇷"
> 
> **else**  **if** activeKbdLayout **is**"Thai" **then**
> 
> **return**"🇹🇭"
> 
> **end**  **if**

---

<div class="post-metadata">

**Author:** ![nikivi](https://community.folivora.ai/user_avatar/community.folivora.ai/nikivi/32/8641_2.png) [@nikivi](https://community.folivora.ai/u/nikivi)\
**Post date:** [September 10, 2018, 6:58pm UTC](https://community.folivora.ai/t/is-it-possible-to-show-current-text-input-language-on-touchbar/3633/3 "2018-09-10T18:58:52Z")

</div>

Thank you. I made it work.

However to make it really work I need to run this script every second as I want to get the same behavior as what menu bar's keyboard input action has.

Is there any way that is more performant that constantly querying to see what language I currently have. As that seems expensive. 😞

---

<div class="post-metadata">

**Author:** ![Doa](https://community.folivora.ai/user_avatar/community.folivora.ai/doa/32/12562_2.png) [@Doa](https://community.folivora.ai/u/Doa)\
**Post date:** [September 11, 2018, 4:20am UTC](https://community.folivora.ai/t/is-it-possible-to-show-current-text-input-language-on-touchbar/3633/4 "2018-09-11T04:20:25Z")

</div>

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:

 ![39%20pm](https://community.folivora.ai/uploads/default/original/2X/7/7acd7f23e39bb82203900e00027a0fc9f7397039.png)

Let me know if you want either of those options and I'll give you the script.

---

<div class="post-metadata">

**Author:** ![Caliguvara](https://community.folivora.ai/user_avatar/community.folivora.ai/caliguvara/32/42570_2.png) [@Caliguvara](https://community.folivora.ai/u/Caliguvara)\
**Post date:** [January 29, 2019, 8:18pm UTC](https://community.folivora.ai/t/is-it-possible-to-show-current-text-input-language-on-touchbar/3633/5 "2019-01-29T20:18:57Z")

</div>

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").

---

<div class="post-metadata">

**Author:** ![nikivi](https://community.folivora.ai/user_avatar/community.folivora.ai/nikivi/32/8641_2.png) [@nikivi](https://community.folivora.ai/u/nikivi)\
**Post date:** [January 30, 2019, 8:24pm UTC](https://community.folivora.ai/t/is-it-possible-to-show-current-text-input-language-on-touchbar/3633/6 "2019-01-30T20:24:05Z")

</div>

Please share it. I'm still looking for a good solution.

---

<div class="post-metadata">

**Author:** ![111139](https://community.folivora.ai/user_avatar/community.folivora.ai/111139/32/13082_2.png) [@111139](https://community.folivora.ai/u/111139)\
**Post date:** [June 13, 2020, 9:27am UTC](https://community.folivora.ai/t/is-it-possible-to-show-current-text-input-language-on-touchbar/3633/7 "2020-06-13T09:27:20Z")

</div>

wait for it

---

<div class="post-metadata">

**Author:** ![Ryan\_Mak](https://community.folivora.ai/user_avatar/community.folivora.ai/ryan_mak/32/28456_2.png) [@Ryan\_Mak](https://community.folivora.ai/u/Ryan_Mak)\
**Post date:** [June 13, 2020, 11:40am UTC](https://community.folivora.ai/t/is-it-possible-to-show-current-text-input-language-on-touchbar/3633/8 "2020-06-13T11:40:59Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Doa](https://community.folivora.ai/user_avatar/community.folivora.ai/doa/32/12562_2.png) [@Doa](https://community.folivora.ai/u/Doa)\
**Post date:** [June 13, 2020, 3:15pm UTC](https://community.folivora.ai/t/is-it-possible-to-show-current-text-input-language-on-touchbar/3633/9 "2020-06-13T15:15:01Z")

</div>

Haven't used that button in ages, but just tried it, and it's not working at all. No idea why. Sorry

---

<div class="post-metadata">

**Author:** ![luhmann](https://community.folivora.ai/letter_avatar_proxy/v4/letter/l/ed655f/32.png) [@luhmann](https://community.folivora.ai/u/luhmann)\
**Post date:** [December 11, 2022, 11:56am UTC](https://community.folivora.ai/t/is-it-possible-to-show-current-text-input-language-on-touchbar/3633/10 "2022-12-11T11:56:04Z")

</div>

Is there any easy to use widget that will do this? I can't figure it out...
