Move some (all) files around
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
33
hosts/common/user/configs/gui/theme/default.nix
Normal file
33
hosts/common/user/configs/gui/theme/default.nix
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
user ? throw "user argument is required",
|
||||
}:
|
||||
{
|
||||
config,
|
||||
inputs,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
hmConfig = config.home-manager.users.${user.name};
|
||||
themeBin = lib.meta.getExe hmConfig.theme.pkg;
|
||||
in
|
||||
{
|
||||
home-manager.users.${user.name} = {
|
||||
imports = [ ./options.nix ];
|
||||
|
||||
theme.enable = true;
|
||||
|
||||
wayland.windowManager.hyprland.settings.bind = [
|
||||
"CTRL_ALT, r, exec, ${themeBin}"
|
||||
"CTRL_ALT, t, exec, ${themeBin} toggle"
|
||||
];
|
||||
|
||||
home = {
|
||||
activation.themeInit = inputs.home-manager.lib.hm.dag.entryAfter [
|
||||
"writeBoundary"
|
||||
] "run ${themeBin}";
|
||||
persistence."/persist${user.home}".directories = [ "${hmConfig.xdg.relativeConfigHome}/theme" ];
|
||||
};
|
||||
};
|
||||
}
|
387
hosts/common/user/configs/gui/theme/options.nix
Normal file
387
hosts/common/user/configs/gui/theme/options.nix
Normal file
@@ -0,0 +1,387 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.theme;
|
||||
init = pkgs.writeShellApplication {
|
||||
name = "theme";
|
||||
runtimeInputs = with pkgs; [ coreutils ];
|
||||
bashOptions = [
|
||||
"nounset"
|
||||
"pipefail"
|
||||
];
|
||||
runtimeEnv = {
|
||||
CONFIG = cfg.configDir;
|
||||
DEFAULT_WALLPAPER = cfg.wallpaper;
|
||||
DEFAULT_MODE = cfg.mode;
|
||||
SWITCH = lib.meta.getExe (pkgs.writeShellScriptBin "themeExtraConfig" cfg.extraConfig);
|
||||
};
|
||||
text = builtins.readFile ./theme.sh;
|
||||
};
|
||||
in
|
||||
{
|
||||
# https://github.com/Theaninova/TheaninovOS/blob/master/modules/home-manager/theme/md3-evo.nix
|
||||
options.theme =
|
||||
with lib;
|
||||
with types;
|
||||
{
|
||||
enable = mkEnableOption "theme";
|
||||
|
||||
configDir = mkOption {
|
||||
type = str;
|
||||
default = "${config.xdg.configHome}/theme";
|
||||
description = "The path to the theme config directory.";
|
||||
};
|
||||
|
||||
wallpaper = mkOption {
|
||||
type = path;
|
||||
description = "The path to the default wallpaper";
|
||||
};
|
||||
|
||||
pkg = mkOption {
|
||||
type = package;
|
||||
default = init;
|
||||
readOnly = true;
|
||||
description = "The package containing the `theme` script";
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
type = lines;
|
||||
default = "";
|
||||
description = "Extra configuration lines to add to the theme script.";
|
||||
};
|
||||
|
||||
flavour = mkOption {
|
||||
type = enum [
|
||||
"content"
|
||||
"expressive"
|
||||
"fidelity"
|
||||
"fruit-salad"
|
||||
"monochrome"
|
||||
"neutral"
|
||||
"rainbow"
|
||||
"tonal-spot"
|
||||
];
|
||||
default = "tonal-spot";
|
||||
description = "The flavour of the theme.";
|
||||
};
|
||||
|
||||
mode = mkOption {
|
||||
type = enum [
|
||||
"dark"
|
||||
"light"
|
||||
];
|
||||
default = "dark";
|
||||
description = "The default mode of the theme.";
|
||||
};
|
||||
|
||||
contrast = mkOption {
|
||||
type = numbers.between (-1) 1;
|
||||
default = 0;
|
||||
description = "Use a modified contrast.";
|
||||
};
|
||||
|
||||
opacity = mkOption {
|
||||
type = numbers.between 0 1;
|
||||
default = 1;
|
||||
description = "The opacity of apps.";
|
||||
};
|
||||
|
||||
radius = mkOption {
|
||||
type = ints.unsigned;
|
||||
default = 8;
|
||||
description = "The radius of corners.";
|
||||
};
|
||||
|
||||
padding = mkOption {
|
||||
type = ints.unsigned;
|
||||
default = 8;
|
||||
description = "The padding of windows.";
|
||||
};
|
||||
|
||||
blur = mkOption {
|
||||
type = ints.unsigned;
|
||||
default = 0;
|
||||
description = "The blur amount of windows.";
|
||||
};
|
||||
|
||||
color = {
|
||||
semantic = {
|
||||
blend = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = "Blend the colors.";
|
||||
};
|
||||
|
||||
danger = mkOption {
|
||||
type = str;
|
||||
default = "#ff0000";
|
||||
description = "The color of danger.";
|
||||
};
|
||||
|
||||
warning = mkOption {
|
||||
type = str;
|
||||
default = "#ffff00";
|
||||
description = "The color of warning.";
|
||||
};
|
||||
|
||||
success = mkOption {
|
||||
type = str;
|
||||
default = "#00ff00";
|
||||
description = "The color of success.";
|
||||
};
|
||||
|
||||
info = mkOption {
|
||||
type = str;
|
||||
default = "#0000ff";
|
||||
description = "The color of info.";
|
||||
};
|
||||
};
|
||||
|
||||
syntax = {
|
||||
blend = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "Blend the colors.";
|
||||
};
|
||||
|
||||
keywords = mkOption {
|
||||
type = str;
|
||||
default = "#ff8000";
|
||||
description = "The color of keywords.";
|
||||
};
|
||||
|
||||
functions = mkOption {
|
||||
type = str;
|
||||
default = "#0000ff";
|
||||
description = "The color of functions.";
|
||||
};
|
||||
|
||||
properties = mkOption {
|
||||
type = str;
|
||||
default = "#ff00ff";
|
||||
description = "The color of properties.";
|
||||
};
|
||||
|
||||
constants = mkOption {
|
||||
type = str;
|
||||
default = "#ff00ff";
|
||||
description = "The color of constants.";
|
||||
};
|
||||
|
||||
strings = mkOption {
|
||||
type = str;
|
||||
default = "#00ff00";
|
||||
description = "The color of variables.";
|
||||
};
|
||||
|
||||
numbers = mkOption {
|
||||
type = str;
|
||||
default = "#00ffff";
|
||||
description = "The color of numbers.";
|
||||
};
|
||||
|
||||
structures = mkOption {
|
||||
type = str;
|
||||
default = "#ffff00";
|
||||
description = "The color of structures.";
|
||||
};
|
||||
|
||||
types = mkOption {
|
||||
type = str;
|
||||
default = "#00ffff";
|
||||
description = "The color of types.";
|
||||
};
|
||||
};
|
||||
|
||||
ansi = {
|
||||
blend = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "Blend the colors.";
|
||||
};
|
||||
|
||||
red = mkOption {
|
||||
type = str;
|
||||
default = "#ff0000";
|
||||
description = "The color of red.";
|
||||
};
|
||||
|
||||
green = mkOption {
|
||||
type = str;
|
||||
default = "#00ff00";
|
||||
description = "The color of green.";
|
||||
};
|
||||
|
||||
yellow = mkOption {
|
||||
type = str;
|
||||
default = "#ffff00";
|
||||
description = "The color of yellow.";
|
||||
};
|
||||
|
||||
orange = mkOption {
|
||||
type = str;
|
||||
default = "#ff8000";
|
||||
description = "The color of orange.";
|
||||
};
|
||||
|
||||
blue = mkOption {
|
||||
type = str;
|
||||
default = "#0000ff";
|
||||
description = "The color of blue.";
|
||||
};
|
||||
|
||||
magenta = mkOption {
|
||||
type = str;
|
||||
default = "#ff00ff";
|
||||
description = "The color of magenta.";
|
||||
};
|
||||
|
||||
cyan = mkOption {
|
||||
type = str;
|
||||
default = "#00ffff";
|
||||
description = "The color of cyan.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
font = {
|
||||
sansSerif = {
|
||||
names = mkOption {
|
||||
type = listOf str;
|
||||
default = [ "Roboto" ];
|
||||
description = "The sans serif font families.";
|
||||
};
|
||||
|
||||
packages = mkOption {
|
||||
type = listOf package;
|
||||
default = with pkgs; [ roboto ];
|
||||
description = "The sans serif font packages.";
|
||||
};
|
||||
};
|
||||
|
||||
serif = {
|
||||
names = mkOption {
|
||||
type = listOf str;
|
||||
default = [ "Roboto Serif" ];
|
||||
description = "The serif font families.";
|
||||
};
|
||||
|
||||
packages = mkOption {
|
||||
type = listOf package;
|
||||
default = with pkgs; [ roboto-serif ];
|
||||
description = "The serif font packages.";
|
||||
};
|
||||
};
|
||||
|
||||
monospace = {
|
||||
names = mkOption {
|
||||
type = listOf str;
|
||||
default = [ "JetBrainsMono Nerd Font" ];
|
||||
description = "The monospace font families.";
|
||||
};
|
||||
|
||||
packages = mkOption {
|
||||
type = listOf package;
|
||||
default = with pkgs; [ (nerdfonts.override { fonts = [ "JetBrainsMono" ]; }) ];
|
||||
description = "The monospace font packages.";
|
||||
};
|
||||
};
|
||||
|
||||
emoji = {
|
||||
names = mkOption {
|
||||
type = listOf str;
|
||||
default = [
|
||||
"Noto Emoji"
|
||||
"Font Awesome"
|
||||
];
|
||||
description = "The emoji font families.";
|
||||
};
|
||||
|
||||
packages = mkOption {
|
||||
type = listOf package;
|
||||
default = with pkgs; [
|
||||
noto-fonts-color-emoji
|
||||
font-awesome
|
||||
];
|
||||
description = "The emoji font packages.";
|
||||
};
|
||||
};
|
||||
|
||||
size = mkOption {
|
||||
type = ints.positive;
|
||||
default = 12;
|
||||
description = "The font size.";
|
||||
};
|
||||
};
|
||||
|
||||
icon = {
|
||||
names = mkOption {
|
||||
type = listOf str;
|
||||
default = [ "Adwaita" ];
|
||||
description = "The icon theme names.";
|
||||
};
|
||||
|
||||
packages = mkOption {
|
||||
type = listOf package;
|
||||
default = with pkgs; [
|
||||
adwaita-icon-theme
|
||||
nixos-icons
|
||||
];
|
||||
description = "The icon theme packages.";
|
||||
};
|
||||
};
|
||||
|
||||
cursor = {
|
||||
names = mkOption {
|
||||
type = listOf str;
|
||||
default = [ "Adwaita" ];
|
||||
description = "The cursor names.";
|
||||
};
|
||||
|
||||
packages = mkOption {
|
||||
type = listOf package;
|
||||
default = with pkgs; [ adwaita-icon-theme ];
|
||||
description = "The cursor theme packages.";
|
||||
};
|
||||
|
||||
size = mkOption {
|
||||
type = ints.positive;
|
||||
default = 32;
|
||||
description = "The cursor size.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home = {
|
||||
packages =
|
||||
[ cfg.pkg ]
|
||||
++ cfg.font.sansSerif.packages
|
||||
++ cfg.font.serif.packages
|
||||
++ cfg.font.monospace.packages
|
||||
++ cfg.font.emoji.packages
|
||||
++ cfg.icon.packages
|
||||
++ cfg.cursor.packages;
|
||||
|
||||
pointerCursor = {
|
||||
name = builtins.head cfg.cursor.names;
|
||||
package = builtins.head cfg.cursor.packages;
|
||||
inherit (cfg.cursor) size;
|
||||
};
|
||||
};
|
||||
|
||||
fonts.fontconfig = {
|
||||
enable = true;
|
||||
defaultFonts = {
|
||||
sansSerif = cfg.font.sansSerif.names;
|
||||
serif = cfg.font.serif.names;
|
||||
monospace = cfg.font.monospace.names;
|
||||
emoji = cfg.font.emoji.names;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
98
hosts/common/user/configs/gui/theme/theme.sh
Normal file
98
hosts/common/user/configs/gui/theme/theme.sh
Normal file
@@ -0,0 +1,98 @@
|
||||
[ ! -L "$CONFIG"/wallpaper ] && ln -sf "$DEFAULT_WALLPAPER" "$CONFIG"/wallpaper
|
||||
[ ! -f "$CONFIG"/mode ] && echo "$DEFAULT_MODE" > "$CONFIG"/mode
|
||||
|
||||
set_wallpaper() {
|
||||
if [ -f "$1" ]; then
|
||||
WALLPAPER="$1"
|
||||
else
|
||||
echo "Invalid wallpaper path: $1"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
set_mode() {
|
||||
if [ "$1" = "light" ] || [ "$1" = "dark" ]; then
|
||||
MODE="$1"
|
||||
else
|
||||
echo "Invalid mode: $1. Use 'light' or 'dark'."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
toggle_mode() {
|
||||
if [ "$(cat "$CONFIG"/mode)" = "light" ]; then
|
||||
MODE="dark"
|
||||
else
|
||||
MODE="light"
|
||||
fi
|
||||
}
|
||||
|
||||
show_usage() {
|
||||
echo "Usage: theme {toggle|light|dark|mode <mode>|wallpaper <file> [mode]}"
|
||||
}
|
||||
|
||||
finish() {
|
||||
[ -n "$WALLPAPER" ] && ln -sf "$WALLPAPER" "$CONFIG"/wallpaper
|
||||
[ -n "$MODE" ] && echo "$MODE" > "$CONFIG"/mode
|
||||
|
||||
{
|
||||
"$SWITCH"
|
||||
} > /dev/null
|
||||
}
|
||||
|
||||
WALLPAPER=""
|
||||
MODE=""
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
finish
|
||||
else
|
||||
case "$1" in
|
||||
toggle)
|
||||
if [ $# -eq 1 ]; then
|
||||
toggle_mode
|
||||
else
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
light)
|
||||
if [ $# -eq 1 ]; then
|
||||
set_mode "light"
|
||||
else
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
dark)
|
||||
if [ $# -eq 1 ]; then
|
||||
set_mode "dark"
|
||||
else
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
mode)
|
||||
if [ $# -eq 2 ]; then
|
||||
set_mode "$2"
|
||||
else
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
wallpaper)
|
||||
if [ $# -ge 2 ] && [ $# -le 3 ]; then
|
||||
set_wallpaper "$2"
|
||||
[ $# -eq 3 ] && set_mode "$3"
|
||||
else
|
||||
show_usage
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
show_usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
finish
|
||||
fi
|
Reference in New Issue
Block a user