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": {"background": "#131221","foreground": "#e0ecf6","cursor": "#e0ecf6"},"colors": {"color0": "#131221","color1": "#6385e3","color2": "#a77be7","color3": "#91a5eb","color4": "#bbccf2","color5": "#b2dbf1","color6": "#cfd7f6","color7": "#e0ecf6","color8": "#9ca5ac","color9": "#6385e3","color10": "#a77be7","color11": "#91a5eb","color12": "#bbccf2","color13": "#b2dbf1","color14": "#cfd7f6","color15": "#e0ecf6"}}
# Regenerate pywal colors if using pywal schemelet theme_file = $"($env.HOME)/nixos/modules/common/theme.nix"let using_pywal = try {let content = open $theme_file$content | str contains 'color_scheme = "pywal";'} catch {false}if $using_pywal {print "Regenerating pywal colors..."# Determine if dark modelet is_dark = try {let content = open $theme_file$content | str contains "is_dark = true;"} catch {false}try {# Clear pywal cache to force regeneration^rm -rf ~/.cache/wallet wal_args = if $is_dark {["-n" "--saturate" "0.7" "-i" $selected]} else {["-n" "--saturate" "0.5" "-l" "-i" $selected]}^${pkgs.pywal}/bin/wal --backend wal ...$wal_args err> /dev/null^cp ~/.cache/wal/colors.json $"($env.HOME)/nixos/pywal-colors.json"print "Colors regenerated!"try {nu -l -c "~/rebuild.nu --quiet"} catch { |e|print "Failed to rebuild."}print "Rebuilt system to apply colors."} catch { |e|print $"Warning: Failed to regenerate colors: ($e.msg)"}}
# Global theme configuration - use `tt dark` or `tt light` to switch.
# Global theme configuration - use `tt dark`/`tt light` to switch light/dark.# Use `tt pywal`/`tt gruvbox` to switch color scheme.
color_scheme = "pywal"; # "gruvbox" or "pywal"# Pywal colors cache - single file updated when theme changes.# Stored in flake directory so Nix can access it (Nix can't read ~/.cache).pywal_cache = self + /pywal-colors.json;# Parse pywal colors and convert to base16 format.# Pywal provides: background, foreground, color0-15.# Base16 needs smooth grayscale gradient base00-07.# Use color0 (black), color8 (gray), color7/15 (white) for gradient.parse_pywal_colors = json: letcolors = builtins.fromJSON json;strip_hash = s: builtins.substring 1 6 s;in {base00 = strip_hash colors.colors.color0; # Background 0.base01 = strip_hash colors.colors.color1; # Background 1.base02 = strip_hash colors.colors.color2; # Background 2.base03 = strip_hash colors.colors.color3; # Background 3.base04 = strip_hash colors.colors.color4; # Foreground 3.base05 = strip_hash colors.colors.color5; # Foreground 2.base06 = strip_hash colors.colors.color6; # Foreground 1.base07 = strip_hash colors.colors.color7; # Foreground 0.base08 = strip_hash colors.colors.color8; # Main colour 1.base09 = strip_hash colors.colors.color9; # Main colour 2.base0A = strip_hash colors.colors.color10; # Main colour 3.base0B = strip_hash colors.colors.color11; # Main colour 4.base0C = strip_hash colors.colors.color12; # Main colour 5.base0D = strip_hash colors.colors.color13; # Main colour 6.base0E = strip_hash colors.colors.color14; # Main colour 7.base0F = strip_hash colors.colors.color15; # Main colour 8.};
# Current color scheme.colors = if is_dark then gruvbox_colors.dark else gruvbox_colors.light;
# Current color scheme (two-dimensional: scheme × light/dark).# Note: pywal colors are pre-generated in the correct mode (light/dark) by tt command.colors = if color_scheme == "pywal"then pywal_colorselse (if is_dark then gruvbox_colors.dark else gruvbox_colors.light);
# Missing wallpapers are handled by `wallpaper-switcher` in `modules/common/theme.nix`.# TODO: Handle this better.wallpaper.light = "${config.users.users.jam.home}/wallpapers/1053268.jpg";wallpaper.dark = "${config.users.users.jam.home}/wallpapers/1005830.jpg";
# Wallpapers are managed by swww - use pick-wallpaper or set-wallpaper commands.# Pywal colors are generated from the current wallpaper when switching themes.
config.home-manager.sharedModules = mkIf config.isDesktopNotWsl [{
config.home-manager.sharedModules = mkIf config.isDesktopNotWsl [(homeArgs: {programs.pywal = enabled;# Pywal colors are now generated in theme.nu before rebuilds. This ensures# the correct mode colors are in ~/.cache/wal/colors.json when the rebuild# happens, preventing the terminal from flickering between modes.
# If using pywal, regenerate colors from current wallpaper.if $using_pywal {print-notify "Regenerating pywal colors..." 20# Get current wallpaper from swww.let wallpaper = try {^swww query | lines | first | parse "{monitor}: image: {path}" | get path.0} catch {null}if $wallpaper != null and ($wallpaper | path exists) {try {# Clear pywal cache to force regeneration from current wallpaper.^rm -rf ~/.cache/wallet wal_args = if $new_theme == "dark" {["-n" "--saturate" "0.7" "-i" $wallpaper]} else {["-n" "--saturate" "0.5" "-l" "-i" $wallpaper]}^wal --backend wal ...$wal_args err> /dev/null^cp ~/.cache/wal/colors.json $"($env.HOME)/nixos/pywal-colors.json"print-notify $"Regenerated ($new_theme) mode pywal colors." 30} catch { |e|print-notify $"Warning: Failed to regenerate pywal colors: ($e.msg)" 30}} else {print-notify "Warning: Could not detect current wallpaper" 30}}
}print-notify $"Switch to the ($new_theme) theme completed!" 100}def switch-scheme [scheme: string] {let theme_file = $"($env.HOME)/nixos/modules/common/theme.nix"# Validate scheme.if $scheme not-in ["pywal", "gruvbox"] {print-notify $"Invalid scheme: '($scheme)'. Use 'pywal' or 'gruvbox'."return
# Using `hyprpaper` now in `modules/linux/hyprland.nix`.# Switch wallpaper to the new theme.# let wallpaper_success: bool = switch-wallpaper $new_theme
# If switching to pywal, generate colors from current wallpaper.if $scheme == "pywal" {print-notify "Generating pywal colors from current wallpaper..." 25# Determine current theme mode.let is_dark = try {let content = open $theme_file$content | str contains "is_dark = true;"} catch {false}# Get current wallpaper from swww.let wallpaper = try {^swww query | lines | first | parse "{monitor}: image: {path}" | get path.0} catch {null}if $wallpaper != null and ($wallpaper | path exists) {try {# Clear pywal cache to force regeneration from current wallpaper.^rm -rf ~/.cache/wallet wal_args = if $is_dark {["-n" "--saturate" "0.7" "-i" $wallpaper]} else {["-n" "--saturate" "0.5" "-l" "-i" $wallpaper]}^wal --backend wal ...$wal_args err> /dev/null^cp ~/.cache/wal/colors.json $"($env.HOME)/nixos/pywal-colors.json"print-notify "Generated pywal colors." 50} catch { |e|print-notify $"Warning: Failed to generate colors: ($e.msg)" 50}} else {print-notify "Warning: Could not detect current wallpaper" 50}}# Update color_scheme in theme.nix.try {let content = open $theme_filelet updated = if $scheme == "pywal" {$content | str replace 'color_scheme = "gruvbox";' 'color_scheme = "pywal";'} else {$content | str replace 'color_scheme = "pywal";' 'color_scheme = "gruvbox";'}$updated | save $theme_file --forceprint $"Updated color_scheme to ($scheme)"} catch { |e|print-notify $"Failed to switch scheme: ($e.msg)"return}# Rebuild configuration to apply new scheme.print-notify $"Rebuilding configuration to apply ($scheme) scheme..." 75try {nu $"($env.HOME)/rebuild.nu" --quiet} catch { |e|print-notify "Error: Rebuild failed, run manually in a terminal."exit 1}print-notify $"Switch to ($scheme) scheme completed!" 100}
# if $wallpaper_success {# print-notify $"Wallpaper switch for the ($new_theme) theme succeeded." 75# } else {# print-notify $"Wallpaper switch failed, continuing with theme switch." 75# }
# Main tt command - handles both light/dark and scheme switching.export def tt [arg?: string] {if $arg == null {print "Usage: tt <dark|light|pywal|gruvbox>"return}
settings.theme.fallback = config.theme.helix;settings.theme.dark = config.theme.themes.helix.dark;settings.theme.light = config.theme.themes.helix.light;
settings.theme = "base16_default_custom";# Pywal output doesn't have gradients like base16 needs.# So it's necessary to override a few colours.themes.base16_default_custom = {inherits = "base16_default";"ui.cursorline.primary".bg = if config.theme.is_dark then "#404040" else "#F0F0F0";"ui.popup".bg = if config.theme.is_dark then "#404040" else "#F0F0F0";"ui.popup.info".bg = if config.theme.is_dark then "#404040" else "#F0F0F0";"ui.selection".bg = if config.theme.is_dark then "#707070" else "#D0D0D0";"ui.selection.primary".bg = if config.theme.is_dark then "#707070" else "#D0D0D0";"comment".fg = if config.theme.is_dark then "#909090" else "#C0C0C0";};