Add kitty theming

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2024-06-23 20:46:43 +03:00
parent 3d503fd1c2
commit bedf27aa5f
9 changed files with 271 additions and 56 deletions

View File

@@ -1,4 +1,4 @@
{ config, inputs, ... }:
{ config, inputs, pkgs, ... }:
{
imports = [
@@ -16,11 +16,19 @@
sharedModules = [{
imports = [
./options/home-manager/xdg
./options/home-manager/hyprland
./options/home-manager/matugen
./options/home-manager/theme
];
home.stateVersion = "24.05";
home = {
packages = with pkgs; [
pavucontrol
];
stateVersion = "24.05";
};
systemd.user.startServices = "sd-switch";
nix.settings = config.nix.settings;
}];

View File

@@ -0,0 +1,38 @@
{ config, pkgs, lib, ... }:
let
cfg = config.wayland.windowManager.hyprland;
in
{
options.wayland.windowManager.hyprland = with lib; with types; {
initExtraConfig = mkOption {
type = lines;
default = "";
description = "Extra configuration lines to add to exec-once";
};
reloadExtraConfig = mkOption {
type = lines;
default = "";
description = "Extra configuration lines to add to exec";
};
};
config = {
wayland.windowManager.hyprland.settings.exec-once = let name = "init-hyprland"; in
"${pkgs.writeShellApplication {
inherit name;
text = ''
${cfg.initExtraConfig}
'';
}}/bin/${name}";
wayland.windowManager.hyprland.settings.exec = let name = "reload-hyprland"; in
"${pkgs.writeShellApplication {
inherit name;
text = ''
${cfg.reloadExtraConfig}
'';
}}/bin/${name}";
};
}

View File

@@ -2,6 +2,111 @@
let
cfg = config.theme;
init = pkgs.writeShellApplication {
name = "theme";
runtimeInputs = with pkgs; [ coreutils-full ];
bashOptions = [ "nounset" "pipefail" ];
text = ''
[ ! -L "${cfg.configDir}/wallpaper" ] && ln -sf "${cfg.wallpaper}" "${cfg.configDir}/wallpaper"
[ ! -f "${cfg.configDir}/mode" ] && echo "${cfg.mode}" > "${cfg.configDir}/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 "${cfg.configDir}/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" "${cfg.configDir}/wallpaper"
[ -n "$MODE" ] && echo "$MODE" > "${cfg.configDir}/mode"
{
${cfg.extraConfig}
} > /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
'';
};
in
{
# https://github.com/Theaninova/TheaninovOS/blob/master/modules/home-manager/theme/md3-evo.nix
@@ -19,6 +124,13 @@ in
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 = "";
@@ -40,6 +152,15 @@ in
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;
@@ -231,36 +352,15 @@ in
};
};
config =
let
name = "theme-init";
init = pkgs.writeShellApplication {
inherit name;
runtimeInputs = with pkgs; [ coreutils-full ];
text =
let
wallpaperPath = "${cfg.configDir}/wallpaper";
in
''
if [ ! -L "${wallpaperPath}" ]; then
ln -sf "${cfg.wallpaper}" "${wallpaperPath}"
fi
config = lib.mkIf cfg.enable {
home = {
packages = [ cfg.pkg ];
${cfg.extraConfig}
'';
pointerCursor = {
inherit (cfg.cursor) package name size;
gtk.enable = true;
x11.enable = true;
};
in
lib.mkIf cfg.enable {
home = {
packages = [ init ];
pointerCursor = {
inherit (cfg.cursor) package name size;
gtk.enable = true;
x11.enable = true;
};
};
wayland.windowManager.hyprland.settings.exec-once = "${init}/bin/${name}";
};
};
}