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

[new script] is dark_mode mac #723

Closed
texastoland opened this issue Jan 3, 2024 · 1 comment
Closed

[new script] is dark_mode mac #723

texastoland opened this issue Jan 3, 2024 · 1 comment

Comments

@texastoland
Copy link
Contributor

texastoland commented Jan 3, 2024

Looking for feedback before PR.

Proposal

export def 'is dark_mode mac' []: nothing -> bool {
  do { ^defaults read -g AppleInterfaceStyle } | complete | $in.exit_code == 0
}

# in my config.nu
if not (mac is_dark_mode) {
  print 'Light theme enabled 🔆'
  $env.config.color_config = $light_theme
}

How it works in Bash

> # light mode: errors and stderr
> defaults read -g AppleInterfaceStyle
defaults[49472:1750663] 
The domain/default pair of (kCFPreferencesAnyApplication, AppleInterfaceStyle) does not exist

> # dark mode: stdout
> defaults read -g AppleInterfaceStyle
Dark

Example alias from my global Git config:

[alias]
delta = !delta $(defaults read -g AppleInterfaceStyle &>/dev/null || echo --light)
@texastoland
Copy link
Contributor Author

Closing in favor of is.nu PR.

Related to https://discord.com/channels/601130461678272522/1192287307215147098.

@texastoland texastoland changed the title [new script] mac is_dark_mode [new script] is dark_mode mac Jan 6, 2024
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

1 participant