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

Change colorscheme of all active Micro instances from outside of Micro #2509

Closed
bartekpacia opened this issue Jul 23, 2022 · 7 comments
Closed

Comments

@bartekpacia
Copy link
Contributor

Description of the problem or steps to reproduce

I'd like to be able to make Micro dynamically react to OS-wide dark theme setting. To do this, I'd like to be able to change a colorscheme of a running Micro instance from outside

I wanted to write a Python script which runs in the background all the time and listens for OS theme changes. When such change occurs, the script would do something like:

micro -colorscheme default # for dark mode
# or
micro -colorscheme bubblegum # for light mode

But the above commands do the different thing than I expected – they launch a new micro instance with changed colorscheme, and not modify the colorscheme of all running micro instances.

So, how can I achieve that auto-theme-changing behavior?

Specifications

OS: macOS 12.4
Terminal: iTerm 2 v3.4.16

@bartekpacia
Copy link
Contributor Author

@zyedidia Does it sound like a reasonable feature? I could contribute it.

@zamsyt
Copy link

zamsyt commented Apr 20, 2023

I found there's another way to get automatic dark/light mode. Some of the colorschemes, like cmc-16 and geany, match the dark/light mode of the terminal. Just picking one of these seems to work for me.

@bartekpacia
Copy link
Contributor Author

Oh how nice! Thanks for sharing!

Unfortunately geany is barely readable in light mode (yellow text...):

Screenshot 2023-04-25 at 9 22 08 PM

but cmc-16 works great - my new default :)

@zyedidia
Copy link
Owner

I think we shouldn't have code that tries to read the system default for light/dark mode, but there are non 256-color colorschemes (like cmc-16 or simple) that just use the 16 colors from the terminal palette that should be able to serve this purpose well.

@zyedidia
Copy link
Owner

By the way, you can modify the colorscheme of all instances by modifying the settings in ~/.config/micro/settings.json, so you could make a script that edits the json there.

@texastoland
Copy link

texastoland commented Jan 22, 2024

Some of the colorschemes, like cmc-16 and geany, match the dark/light mode of the terminal.

Cool! Looks like simple and (ironically) solarized work too. If you still want to switch you can use the defaults trick on Mac from dandavison/delta#447 (comment).

@bartekpacia
Copy link
Contributor Author

bartekpacia commented Mar 13, 2024

I have this in my ~/.zshrc and it works great! I hope you'll like it too:

if command -v micro >/dev/null 2>&1; then
    if [ "$(uname)" = Darwin ]; then
        # automatically set light/dark theme on macOS
        alias micro="micro -colorscheme=\$(defaults read -globalDomain AppleInterfaceStyle &> /dev/null && echo monokai || echo bubblegum)"
    fi
fi

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

4 participants