all repos — nixfiles @ e73ff2535a3b0c5fe837ea439003961b4c5c87d4

System and user configuration, managed by nix and home-manager

move Apple Terminal theme switcher to per-term function

Alin
commit

e73ff2535a3b0c5fe837ea439003961b4c5c87d4

parent

0deb085c8fd582166a39e01656c2933974d74acd

D scripts/terminal/set-terminal-theme.applescript
@@ -1,29 +0,0 @@
-global lightProfile, darkProfile - -set lightProfile to "Flexoki Light" -set darkProfile to "Flexoki Dark" - -to getTargetProfile() - tell application "System Events" - set isDark to dark mode of appearance preferences - end tell - if isDark then - return darkProfile - else - return lightProfile - end if -end getTargetProfile - -to setTerminalProfile(targetProfile) - tell application "Terminal" - set default settings to settings set targetProfile - set startup settings to settings set targetProfile - - repeat with existingWindow in windows - set current settings of existingWindow to settings set targetProfile - end repeat - end tell -end setTerminalProfile - -getTargetProfile() -setTerminalProfile(result)
D scripts/terminal/toggle-light-dark
@@ -1,11 +0,0 @@
-#!/usr/bin/env fish - -set --function cmd osascript (status dirname)/set-terminal-theme.applescript - -set --function apple_interface_style (defaults read -g AppleInterfaceStyle 2> /dev/null) - -if test "$apple_interface_style" = Dark - $cmd $TERMINAL_THEME_DARK $argv -else - $cmd $TERMINAL_THEME_LIGHT $argv -end
M user/settings/fish/per-term/Apple_Terminal.fish → user/settings/fish/per-term/Apple_Terminal.fish
@@ -45,3 +45,18 @@ return
end end end + +function set_terminal_appearance --description="Set Terminal to use a [light|dark] theme (default=toggle)" + if test -n "$argv[1]" + set --function target $argv[1] + else + if test $fish_terminal_color_theme = light + set --function target dark + else + set --function target light + end + end + + echo Making it $target... + osascript (status dirname)/set-terminal-theme.applescript $target +end
A user/settings/fish/per-term/set-terminal-theme.applescript
@@ -0,0 +1,42 @@
+#!/usr/bin/env osascript +use scripting additions + +to getSystemAppearance() + tell application "System Events" + set isDark to dark mode of appearance preferences + end tell + + if isDark then + return "dark" + else + return "light" + end if +end getSystemAppearance + +to setTerminalProfile(targetProfile) + tell application "Terminal" + set default settings to settings set targetProfile + set startup settings to settings set targetProfile + + repeat with existingWindow in windows + set current settings of existingWindow to settings set targetProfile + end repeat + end tell +end setTerminalProfile + +on run argv + set lightProfile to "Flexoki Light" + set darkProfile to "Flexoki Dark" + + if length of argv is 0 then + set targetMode to getSystemAppearance() + else + set targetMode to item 1 of argv + end if + + if targetMode = "dark" then + setTerminalProfile(darkProfile) + else + setTerminalProfile(lightProfile) + end if +end run