mirror of
https://github.com/harivansh-afk/nix.git
synced 2026-04-15 03:00:47 +00:00
fix
This commit is contained in:
parent
c84611bdf1
commit
856f200244
4 changed files with 134 additions and 102 deletions
|
|
@ -14,6 +14,8 @@ in
|
|||
++ lib.optionals hostConfig.isDarwin (builtins.attrValues customScripts.darwinPackages);
|
||||
|
||||
home.activation.initializeThemeState = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
${customScripts.themeAssetsText}
|
||||
|
||||
mkdir -p "${customScripts.theme.paths.stateDir}" \
|
||||
"${customScripts.theme.paths.fzfDir}" \
|
||||
"${customScripts.theme.paths.ghosttyDir}" \
|
||||
|
|
@ -25,36 +27,20 @@ in
|
|||
mode=$(tr -d '[:space:]' < "${customScripts.theme.paths.stateFile}")
|
||||
else
|
||||
mode="${customScripts.theme.defaultMode}"
|
||||
printf '%s\n' "$mode" > "${customScripts.theme.paths.stateFile}"
|
||||
fi
|
||||
|
||||
case "$mode" in
|
||||
light)
|
||||
fzf_target="${customScripts.theme.paths.fzfDir}/cozybox-light"
|
||||
ghostty_target="${customScripts.theme.paths.ghosttyDir}/cozybox-light"
|
||||
tmux_target="${customScripts.tmuxConfigs.light}"
|
||||
lazygit_target="${customScripts.theme.paths.lazygitDir}/config-light.yml"
|
||||
;;
|
||||
*)
|
||||
printf '%s\n' "${customScripts.theme.defaultMode}" > "${customScripts.theme.paths.stateFile}"
|
||||
fzf_target="${customScripts.theme.paths.fzfDir}/cozybox-dark"
|
||||
ghostty_target="${customScripts.theme.paths.ghosttyDir}/cozybox-dark"
|
||||
tmux_target="${customScripts.tmuxConfigs.dark}"
|
||||
lazygit_target="${customScripts.theme.paths.lazygitDir}/config-dark.yml"
|
||||
;;
|
||||
esac
|
||||
mode="$(theme_normalize_mode "$mode")"
|
||||
printf '%s\n' "$mode" > "${customScripts.theme.paths.stateFile}"
|
||||
theme_load_mode_assets "$mode"
|
||||
|
||||
ln -sfn "$fzf_target" "${customScripts.theme.paths.fzfCurrentFile}"
|
||||
ln -sfn "$ghostty_target" "${customScripts.theme.paths.ghosttyCurrentFile}"
|
||||
ln -sfn "$tmux_target" "${customScripts.theme.paths.tmuxCurrentFile}"
|
||||
ln -sfn "$lazygit_target" "${customScripts.theme.paths.lazygitCurrentFile}"
|
||||
ln -sfn "$THEME_FZF_TARGET" "${customScripts.theme.paths.fzfCurrentFile}"
|
||||
ln -sfn "$THEME_GHOSTTY_TARGET" "${customScripts.theme.paths.ghosttyCurrentFile}"
|
||||
ln -sfn "$THEME_TMUX_TARGET" "${customScripts.theme.paths.tmuxCurrentFile}"
|
||||
ln -sfn "$THEME_LAZYGIT_TARGET" "${customScripts.theme.paths.lazygitCurrentFile}"
|
||||
${lib.optionalString hostConfig.isDarwin ''
|
||||
lg_darwin="${config.home.homeDirectory}/Library/Application Support/lazygit"
|
||||
mkdir -p "$lg_darwin"
|
||||
case "$mode" in
|
||||
light) ln -sfn "$lg_darwin/config-light.yml" "$lg_darwin/config.yml" ;;
|
||||
*) ln -sfn "$lg_darwin/config-dark.yml" "$lg_darwin/config.yml" ;;
|
||||
esac
|
||||
ln -sfn "$THEME_DARWIN_LAZYGIT_TARGET" "$lg_darwin/config.yml"
|
||||
''}
|
||||
|
||||
# seed wallpapers from static assets if no generated ones exist yet
|
||||
|
|
@ -66,10 +52,6 @@ in
|
|||
fi
|
||||
|
||||
# ensure wallpaper symlink points to active mode
|
||||
case "$mode" in
|
||||
light) wp_target="${customScripts.theme.wallpapers.light}" ;;
|
||||
*) wp_target="${customScripts.theme.wallpapers.dark}" ;;
|
||||
esac
|
||||
ln -sfn "$wp_target" "${customScripts.theme.wallpapers.current}"
|
||||
ln -sfn "$THEME_WALLPAPER" "${customScripts.theme.wallpapers.current}"
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,26 +13,53 @@ let
|
|||
aquaNeutral = "#689d6a";
|
||||
gray = "#928374";
|
||||
};
|
||||
wallpaperGeneration = {
|
||||
view = {
|
||||
# Lower zoom shows more terrain in each wallpaper.
|
||||
zoom = 11;
|
||||
tileConcurrency = 6;
|
||||
wallpaperGeneration =
|
||||
let
|
||||
viewPresets = {
|
||||
close = 12;
|
||||
balanced = 11;
|
||||
wide = 10;
|
||||
};
|
||||
densityPresets = {
|
||||
sparse = 14;
|
||||
balanced = 20;
|
||||
dense = 28;
|
||||
};
|
||||
view = "balanced";
|
||||
density = "balanced";
|
||||
candidatePool = {
|
||||
maxCached = 24;
|
||||
randomAttempts = 20;
|
||||
historySize = 10;
|
||||
};
|
||||
label = {
|
||||
enabled = true;
|
||||
fontSize = 14;
|
||||
};
|
||||
in
|
||||
{
|
||||
inherit
|
||||
candidatePool
|
||||
density
|
||||
label
|
||||
view
|
||||
;
|
||||
presetValues = {
|
||||
density = densityPresets;
|
||||
view = viewPresets;
|
||||
};
|
||||
resolved = {
|
||||
candidatePool = candidatePool;
|
||||
contours = {
|
||||
levels = densityPresets.${density};
|
||||
};
|
||||
label = label;
|
||||
view = {
|
||||
tileConcurrency = 6;
|
||||
zoom = viewPresets.${view};
|
||||
};
|
||||
};
|
||||
};
|
||||
contours = {
|
||||
# Higher levels produce denser contour lines.
|
||||
levels = 20;
|
||||
};
|
||||
candidatePool = {
|
||||
maxCached = 24;
|
||||
randomAttempts = 20;
|
||||
historySize = 10;
|
||||
};
|
||||
label = {
|
||||
enabled = true;
|
||||
fontSize = 14;
|
||||
};
|
||||
};
|
||||
wallpapers = {
|
||||
dir = "${config.home.homeDirectory}/Pictures/Screensavers";
|
||||
dark = "${config.home.homeDirectory}/Pictures/Screensavers/wallpaper-dark.jpg";
|
||||
|
|
|
|||
|
|
@ -12,11 +12,71 @@ let
|
|||
};
|
||||
|
||||
wallpaperGenConfig = pkgs.writeText "wallpaper-gen-config.json" (
|
||||
builtins.toJSON theme.wallpapers.generation
|
||||
builtins.toJSON theme.wallpapers.generation.resolved
|
||||
);
|
||||
|
||||
wallpaperPython = pkgs.python3.withPackages (ps: [ ps.pillow ]);
|
||||
|
||||
lazygitDarwinDir = "${config.home.homeDirectory}/Library/Application Support/lazygit";
|
||||
|
||||
modeAssets = {
|
||||
dark = {
|
||||
fzf = "${theme.paths.fzfDir}/cozybox-dark";
|
||||
ghostty = "${theme.paths.ghosttyDir}/cozybox-dark";
|
||||
tmux = "${tmuxConfigs.dark}";
|
||||
lazygit = "${theme.paths.lazygitDir}/config-dark.yml";
|
||||
darwinLazygit = "${lazygitDarwinDir}/config-dark.yml";
|
||||
wallpaper = theme.wallpapers.dark;
|
||||
appleDarkMode = "true";
|
||||
};
|
||||
light = {
|
||||
fzf = "${theme.paths.fzfDir}/cozybox-light";
|
||||
ghostty = "${theme.paths.ghosttyDir}/cozybox-light";
|
||||
tmux = "${tmuxConfigs.light}";
|
||||
lazygit = "${theme.paths.lazygitDir}/config-light.yml";
|
||||
darwinLazygit = "${lazygitDarwinDir}/config-light.yml";
|
||||
wallpaper = theme.wallpapers.light;
|
||||
appleDarkMode = "false";
|
||||
};
|
||||
};
|
||||
|
||||
themeAssetsText = ''
|
||||
theme_normalize_mode() {
|
||||
case "$1" in
|
||||
dark|light) printf '%s\n' "$1" ;;
|
||||
*) printf '%s\n' '${theme.defaultMode}' ;;
|
||||
esac
|
||||
}
|
||||
|
||||
theme_load_mode_assets() {
|
||||
local mode
|
||||
mode="$(theme_normalize_mode "$1")"
|
||||
|
||||
case "$mode" in
|
||||
light)
|
||||
THEME_MODE='light'
|
||||
THEME_FZF_TARGET='${modeAssets.light.fzf}'
|
||||
THEME_GHOSTTY_TARGET='${modeAssets.light.ghostty}'
|
||||
THEME_TMUX_TARGET='${modeAssets.light.tmux}'
|
||||
THEME_LAZYGIT_TARGET='${modeAssets.light.lazygit}'
|
||||
THEME_DARWIN_LAZYGIT_TARGET='${modeAssets.light.darwinLazygit}'
|
||||
THEME_WALLPAPER='${modeAssets.light.wallpaper}'
|
||||
THEME_APPLE_DARK_MODE=${modeAssets.light.appleDarkMode}
|
||||
;;
|
||||
*)
|
||||
THEME_MODE='dark'
|
||||
THEME_FZF_TARGET='${modeAssets.dark.fzf}'
|
||||
THEME_GHOSTTY_TARGET='${modeAssets.dark.ghostty}'
|
||||
THEME_TMUX_TARGET='${modeAssets.dark.tmux}'
|
||||
THEME_LAZYGIT_TARGET='${modeAssets.dark.lazygit}'
|
||||
THEME_DARWIN_LAZYGIT_TARGET='${modeAssets.dark.darwinLazygit}'
|
||||
THEME_WALLPAPER='${modeAssets.dark.wallpaper}'
|
||||
THEME_APPLE_DARK_MODE=${modeAssets.dark.appleDarkMode}
|
||||
;;
|
||||
esac
|
||||
}
|
||||
'';
|
||||
|
||||
mkScript =
|
||||
{
|
||||
file,
|
||||
|
|
@ -107,31 +167,20 @@ let
|
|||
"@STATE_FILE@" = theme.paths.stateFile;
|
||||
"@FZF_DIR@" = theme.paths.fzfDir;
|
||||
"@FZF_CURRENT_FILE@" = theme.paths.fzfCurrentFile;
|
||||
"@FZF_DARK_FILE@" = "${theme.paths.fzfDir}/cozybox-dark";
|
||||
"@FZF_LIGHT_FILE@" = "${theme.paths.fzfDir}/cozybox-light";
|
||||
"@GHOSTTY_DIR@" = theme.paths.ghosttyDir;
|
||||
"@GHOSTTY_CURRENT_FILE@" = theme.paths.ghosttyCurrentFile;
|
||||
"@GHOSTTY_DARK_FILE@" = "${theme.paths.ghosttyDir}/cozybox-dark";
|
||||
"@GHOSTTY_LIGHT_FILE@" = "${theme.paths.ghosttyDir}/cozybox-light";
|
||||
"@TMUX_DIR@" = theme.paths.tmuxDir;
|
||||
"@TMUX_CURRENT_FILE@" = theme.paths.tmuxCurrentFile;
|
||||
"@TMUX_DARK_FILE@" = "${tmuxConfigs.dark}";
|
||||
"@TMUX_LIGHT_FILE@" = "${tmuxConfigs.light}";
|
||||
"@TMUX_CONFIG@" = "${config.xdg.configHome}/tmux/tmux.conf";
|
||||
"@LAZYGIT_DIR@" = theme.paths.lazygitDir;
|
||||
"@LAZYGIT_CURRENT_FILE@" = theme.paths.lazygitCurrentFile;
|
||||
"@LAZYGIT_DARK_FILE@" = "${theme.paths.lazygitDir}/config-dark.yml";
|
||||
"@LAZYGIT_LIGHT_FILE@" = "${theme.paths.lazygitDir}/config-light.yml";
|
||||
"@LAZYGIT_DARWIN_DIR@" = "${config.home.homeDirectory}/Library/Application Support/lazygit";
|
||||
"@LAZYGIT_DARWIN_FILE@" = "${config.home.homeDirectory}/Library/Application Support/lazygit/config.yml";
|
||||
"@LAZYGIT_DARWIN_DARK_FILE@" = "${config.home.homeDirectory}/Library/Application Support/lazygit/config-dark.yml";
|
||||
"@LAZYGIT_DARWIN_LIGHT_FILE@" = "${config.home.homeDirectory}/Library/Application Support/lazygit/config-light.yml";
|
||||
"@LAZYGIT_DARWIN_DIR@" = lazygitDarwinDir;
|
||||
"@LAZYGIT_DARWIN_FILE@" = "${lazygitDarwinDir}/config.yml";
|
||||
"@WALLPAPER_DIR@" = theme.wallpapers.dir;
|
||||
"@WALLPAPER_DARK_FILE@" = theme.wallpapers.dark;
|
||||
"@WALLPAPER_LIGHT_FILE@" = theme.wallpapers.light;
|
||||
"@WALLPAPER_CURRENT_FILE@" = theme.wallpapers.current;
|
||||
"@WALLPAPER_STATIC_DARK@" = "${theme.wallpapers.staticDark}";
|
||||
"@WALLPAPER_STATIC_LIGHT@" = "${theme.wallpapers.staticLight}";
|
||||
"@THEME_ASSETS_TEXT@" = themeAssetsText;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
@ -166,6 +215,7 @@ in
|
|||
darwinPackages
|
||||
nettyPackages
|
||||
theme
|
||||
themeAssetsText
|
||||
tmuxConfigs
|
||||
;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ read_mode() {
|
|||
echo "@DEFAULT_MODE@"
|
||||
}
|
||||
|
||||
@THEME_ASSETS_TEXT@
|
||||
|
||||
set_wallpaper() {
|
||||
if [[ "$(uname -s)" == "Darwin" ]] && command -v osascript >/dev/null 2>&1; then
|
||||
if [[ -f "@WALLPAPER_CURRENT_FILE@" ]]; then
|
||||
|
|
@ -31,43 +33,18 @@ set_wallpaper() {
|
|||
|
||||
link_mode_assets() {
|
||||
local mode="$1"
|
||||
local fzf_target
|
||||
local ghostty_target
|
||||
local tmux_target
|
||||
local apple_dark_mode
|
||||
|
||||
case "$mode" in
|
||||
dark)
|
||||
fzf_target="@FZF_DARK_FILE@"
|
||||
ghostty_target="@GHOSTTY_DARK_FILE@"
|
||||
tmux_target="@TMUX_DARK_FILE@"
|
||||
lazygit_target="@LAZYGIT_DARK_FILE@"
|
||||
wallpaper="@WALLPAPER_DARK_FILE@"
|
||||
apple_dark_mode=true
|
||||
;;
|
||||
light)
|
||||
fzf_target="@FZF_LIGHT_FILE@"
|
||||
ghostty_target="@GHOSTTY_LIGHT_FILE@"
|
||||
tmux_target="@TMUX_LIGHT_FILE@"
|
||||
lazygit_target="@LAZYGIT_LIGHT_FILE@"
|
||||
wallpaper="@WALLPAPER_LIGHT_FILE@"
|
||||
apple_dark_mode=false
|
||||
;;
|
||||
*)
|
||||
echo "invalid mode: $mode" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
theme_load_mode_assets "$mode"
|
||||
mode="$THEME_MODE"
|
||||
|
||||
mkdir -p "@STATE_DIR@" "@FZF_DIR@" "@GHOSTTY_DIR@" "@TMUX_DIR@" "@LAZYGIT_DIR@" "@WALLPAPER_DIR@"
|
||||
printf '%s\n' "$mode" > "@STATE_FILE@"
|
||||
ln -sfn "$fzf_target" "@FZF_CURRENT_FILE@"
|
||||
ln -sfn "$ghostty_target" "@GHOSTTY_CURRENT_FILE@"
|
||||
ln -sfn "$tmux_target" "@TMUX_CURRENT_FILE@"
|
||||
ln -sfn "$lazygit_target" "@LAZYGIT_CURRENT_FILE@"
|
||||
ln -sfn "$THEME_FZF_TARGET" "@FZF_CURRENT_FILE@"
|
||||
ln -sfn "$THEME_GHOSTTY_TARGET" "@GHOSTTY_CURRENT_FILE@"
|
||||
ln -sfn "$THEME_TMUX_TARGET" "@TMUX_CURRENT_FILE@"
|
||||
ln -sfn "$THEME_LAZYGIT_TARGET" "@LAZYGIT_CURRENT_FILE@"
|
||||
|
||||
if [[ -f "$wallpaper" ]]; then
|
||||
ln -sfn "$wallpaper" "@WALLPAPER_CURRENT_FILE@"
|
||||
if [[ -f "$THEME_WALLPAPER" ]]; then
|
||||
ln -sfn "$THEME_WALLPAPER" "@WALLPAPER_CURRENT_FILE@"
|
||||
fi
|
||||
|
||||
if command -v tmux >/dev/null 2>&1 && tmux start-server >/dev/null 2>&1; then
|
||||
|
|
@ -76,13 +53,9 @@ link_mode_assets() {
|
|||
|
||||
if [[ "$(uname -s)" == "Darwin" ]] && command -v osascript >/dev/null 2>&1; then
|
||||
mkdir -p "@LAZYGIT_DARWIN_DIR@"
|
||||
if [[ "$mode" == "dark" ]]; then
|
||||
ln -sfn "@LAZYGIT_DARWIN_DARK_FILE@" "@LAZYGIT_DARWIN_FILE@"
|
||||
else
|
||||
ln -sfn "@LAZYGIT_DARWIN_LIGHT_FILE@" "@LAZYGIT_DARWIN_FILE@"
|
||||
fi
|
||||
ln -sfn "$THEME_DARWIN_LAZYGIT_TARGET" "@LAZYGIT_DARWIN_FILE@"
|
||||
|
||||
osascript -e "tell application \"System Events\" to tell appearance preferences to set dark mode to ${apple_dark_mode}" >/dev/null 2>&1 || true
|
||||
osascript -e "tell application \"System Events\" to tell appearance preferences to set dark mode to ${THEME_APPLE_DARK_MODE}" >/dev/null 2>&1 || true
|
||||
|
||||
set_wallpaper
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue