initial commit
This commit is contained in:
67
modules/home/theme-switcher.nix
Normal file
67
modules/home/theme-switcher.nix
Normal file
@@ -0,0 +1,67 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
palettes = import ../../themes/nomarchy-palettes.nix;
|
||||
themeNames = builtins.attrNames palettes;
|
||||
themeList = builtins.concatStringsSep "\\n" themeNames;
|
||||
|
||||
nomarchy-theme-selector = pkgs.writeShellScriptBin "nomarchy-theme-selector" ''
|
||||
STATE_DIR="$HOME/.config/home-manager"
|
||||
THEME_STATE_FILE="$STATE_DIR/theme-state.nix"
|
||||
WALLPAPER_STATE_FILE="$STATE_DIR/wallpaper-state.nix"
|
||||
THEMES_DIR="/etc/nixos/themes" # This depends on where the repo is cloned
|
||||
|
||||
mkdir -p "$STATE_DIR"
|
||||
|
||||
SELECTED_THEME=$(echo -e "${themeList}" | walker --dmenu)
|
||||
|
||||
if [ -n "$SELECTED_THEME" ]; then
|
||||
echo "$SELECTED_THEME" > "$THEME_STATE_FILE"
|
||||
|
||||
# Try to find a background for this theme
|
||||
BG_DIR="$THEMES_DIR/$SELECTED_THEME/backgrounds"
|
||||
if [ -d "$BG_DIR" ]; then
|
||||
BG=$(ls "$BG_DIR" | head -n 1)
|
||||
if [ -n "$BG" ]; then
|
||||
echo "$BG_DIR/$BG" > "$WALLPAPER_STATE_FILE"
|
||||
fi
|
||||
fi
|
||||
|
||||
env-update
|
||||
fi
|
||||
'';
|
||||
nomarchy-font-selector = pkgs.writeShellScriptBin "nomarchy-font-selector" ''
|
||||
STATE_DIR="$HOME/.config/home-manager"
|
||||
STATE_FILE="$STATE_DIR/font-state.nix"
|
||||
|
||||
mkdir -p "$STATE_DIR"
|
||||
|
||||
# Simple list of common nerd fonts, could be expanded
|
||||
FONTS="JetBrainsMono Nerd Font\nRobotoMono Nerd Font\nFiraCode Nerd Font\nUbuntuMono Nerd Font"
|
||||
SELECTED_FONT=$(echo -e "$FONTS" | walker --dmenu)
|
||||
|
||||
if [ -n "$SELECTED_FONT" ]; then
|
||||
echo "$SELECTED_FONT" > "$STATE_FILE"
|
||||
env-update
|
||||
fi
|
||||
'';
|
||||
nomarchy-wallpaper-selector = pkgs.writeShellScriptBin "nomarchy-wallpaper-selector" ''
|
||||
STATE_DIR="$HOME/.config/home-manager"
|
||||
WALLPAPER_STATE_FILE="$STATE_DIR/wallpaper-state.nix"
|
||||
THEMES_DIR="/etc/nixos/themes"
|
||||
|
||||
mkdir -p "$STATE_DIR"
|
||||
|
||||
# List all images in all themes backgrounds
|
||||
WALLPAPERS=$(find "$THEMES_DIR" -type f \( -name "*.jpg" -o -name "*.png" \))
|
||||
SELECTED_WP=$(echo -e "$WALLPAPERS" | walker --dmenu)
|
||||
|
||||
if [ -n "$SELECTED_WP" ]; then
|
||||
echo "$SELECTED_WP" > "$WALLPAPER_STATE_FILE"
|
||||
env-update
|
||||
fi
|
||||
'';
|
||||
in
|
||||
{
|
||||
home.packages = [ nomarchy-theme-selector nomarchy-font-selector nomarchy-wallpaper-selector ];
|
||||
}
|
||||
Reference in New Issue
Block a user