Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Active color depending on input language #134

Open
adbhutagaurangadas opened this issue Nov 26, 2024 · 1 comment
Open

Active color depending on input language #134

adbhutagaurangadas opened this issue Nov 26, 2024 · 1 comment

Comments

@adbhutagaurangadas
Copy link

I'm working on vim and all the commands are done of cause in English. But sometimes I switch to another language to write some strings. It would be great if possible to highlight border in different color to signal that I should return back to English. Unfortunately I didn't find any app to strongly highlight input language. Border color highlighting would be the best in this case!

@Bellavene
Copy link

Bellavene commented Jan 13, 2025

You could do it by yourself. I use this script for a long time

borders-switch

#!/bin/zsh
case $@ in
    r)
      /opt/homebrew/bin/borders \
        active_color='gradient(top_left=0xaaff0033,bottom_right=0xbbffa100)' \
    ;;
    e)
      /opt/homebrew/bin/borders \
        active_color='gradient(top_left=0xbbffa100,bottom_right=0xaaff0033)' \
    ;;
    *)
      /opt/homebrew/bin/borders \
        active_color='gradient(top_left=0xbbffa100,bottom_right=0xaaff0033)' \
        inactive_color='gradient(top_right=0x4000a100,bottom_left=0x400000aa)' \
        width=8 \
        hidpi=on \
        blacklist="DaVinci Resolve,iPhone Mirroring" \
        order=below \
        ax_focus=on \
        2>/dev/null 1>&2 &
    ;;
esac

Now if you have three options, just borders-switch will initiate borders itself (so this is your startup script), borders-switch e will initiate the front window border color for english, borders-switch r for russian. This will just simplify the next step.

To create an input switch watcher you can choose one of those ways:
1. You can use Hammerspoon with MenubarFlag.spoon and modify the later one to execute the needed borders-switch on language input change, instead of changing the menu bar color it was originally made for. (Feel free to ask how, if you will go this rote and will get stuck, it is pretty easy though)
2. Write a python script watcher.
3. Write a swift system call NS watcher.
4. Not recommended. Create a shell script watcher (with use of InputSourceSwitchCLI or macism) which will check what input is set and execute a command back accordingly. Then set cron task to engage it every n time to track the state of the input language.
5. Felix's Sketchybar also has a watcher build in. So it is possible to script that instead of cron in option 4. sketchybar --add event input_change AppleSelectedInputSourcesChangedNotification. In fact, I totally forgot about that, maybe will check that way too.
6. I myself found out that BetterTouchTool (Paid app) has a much snappier input detection, so I use it instead. Sketchybar should be snappy too.

2025-01-13.at.18.03.11.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants