Add kitty theming
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -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;
|
||||
}];
|
||||
|
38
users/common/options/home-manager/hyprland/default.nix
Normal file
38
users/common/options/home-manager/hyprland/default.nix
Normal 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}";
|
||||
};
|
||||
}
|
@@ -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}";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@@ -105,12 +105,15 @@ in
|
||||
fi
|
||||
'';
|
||||
|
||||
home = {
|
||||
sessionVariables.NIXOS_OZONE_WL = "1";
|
||||
theme.extraConfig = let name = "reload-hyprland"; in
|
||||
"${pkgs.writeShellApplication {
|
||||
inherit name;
|
||||
runtimeInputs = with pkgs; [ hyprland ];
|
||||
text = ''
|
||||
hyprctl reload
|
||||
'';
|
||||
}}/bin/${name} &";
|
||||
|
||||
packages = with pkgs; [
|
||||
pavucontrol
|
||||
];
|
||||
};
|
||||
home.sessionVariables.NIXOS_OZONE_WL = "1";
|
||||
};
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
{ user ? throw "user argument is required" }: { config, ... }:
|
||||
{ user ? throw "user argument is required" }: { config, pkgs, ... }:
|
||||
|
||||
let
|
||||
hmConfig = config.home-manager.users."${user.name}";
|
||||
@@ -9,9 +9,26 @@ in
|
||||
enable = true;
|
||||
extraConfig = ''
|
||||
confirm_os_window_close 0
|
||||
include theme.conf
|
||||
'';
|
||||
};
|
||||
|
||||
programs.matugen.settings.templates = {
|
||||
kitty = {
|
||||
input_path = ./theme.conf;
|
||||
output_path = "${hmConfig.xdg.configHome}/kitty/theme.conf";
|
||||
};
|
||||
};
|
||||
|
||||
theme.extraConfig = let name = "reload-kitty"; in
|
||||
"${pkgs.writeShellApplication {
|
||||
inherit name;
|
||||
runtimeInputs = with pkgs; [ procps ];
|
||||
text = ''
|
||||
pkill kitty -SIGUSR1
|
||||
'';
|
||||
}}/bin/${name} &";
|
||||
|
||||
home.persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/kitty" ];
|
||||
};
|
||||
}
|
||||
|
29
users/configs/kitty/theme.conf
Normal file
29
users/configs/kitty/theme.conf
Normal file
@@ -0,0 +1,29 @@
|
||||
background_tint 0.0
|
||||
background_opacity {{custom.opacity}}
|
||||
|
||||
background {{colors.surface.default.hex}}
|
||||
foreground {{colors.on_surface.default.hex}}
|
||||
|
||||
selection_background {{colors.primary.default.hex}}
|
||||
selection_foreground {{colors.on_primary.default.hex}}
|
||||
|
||||
url_color {{colors.tertiary.default.hex}}
|
||||
cursor {{colors.on_surface.default.hex}}
|
||||
|
||||
color0 {{colors.surface.default.hex}}
|
||||
color1 {{colors.red.default.hex}}
|
||||
color2 {{colors.green.default.hex}}
|
||||
color3 {{colors.yellow.default.hex}}
|
||||
color4 {{colors.blue.default.hex}}
|
||||
color5 {{colors.magenta.default.hex}}
|
||||
color6 {{colors.cyan.default.hex}}
|
||||
color7 {{colors.on_surface.default.hex}}
|
||||
|
||||
color8 {{colors.outline_variant.default.hex}}
|
||||
color9 {{colors.red.default.hex}}
|
||||
color10 {{colors.green.default.hex}}
|
||||
color11 {{colors.yellow.default.hex}}
|
||||
color12 {{colors.blue.default.hex}}
|
||||
color13 {{colors.magenta.default.hex}}
|
||||
color14 {{colors.cyan.default.hex}}
|
||||
color15 {{colors.on_surface_variant.default.hex}}
|
@@ -1,4 +1,4 @@
|
||||
{ user ? throw "user argument is required" }: { config, ... }:
|
||||
{ user ? throw "user argument is required" }: { config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
hmConfig = config.home-manager.users."${user.name}";
|
||||
@@ -44,6 +44,7 @@ in
|
||||
flavour = hmConfig.theme.flavour;
|
||||
contrast = builtins.toString hmConfig.theme.contrast;
|
||||
opacity = builtins.toString hmConfig.theme.opacity;
|
||||
transparency = builtins.toString (1 - hmConfig.theme.opacity);
|
||||
radius = builtins.toString hmConfig.theme.radius;
|
||||
padding = builtins.toString hmConfig.theme.padding;
|
||||
double_padding = builtins.toString (hmConfig.theme.padding * 2);
|
||||
@@ -54,5 +55,17 @@ in
|
||||
templates = { };
|
||||
};
|
||||
};
|
||||
|
||||
theme.extraConfig = let name = "theme-matugen"; in
|
||||
lib.mkBefore "${pkgs.writeShellApplication {
|
||||
inherit name;
|
||||
runtimeInputs = with pkgs; [ matugen ];
|
||||
text = ''
|
||||
matugen image "${hmConfig.theme.configDir}/wallpaper" \
|
||||
--type scheme-${hmConfig.theme.flavour} \
|
||||
--mode "$(cat "${hmConfig.theme.configDir}/mode")" \
|
||||
--contrast ${builtins.toString hmConfig.theme.contrast}
|
||||
'';
|
||||
}}/bin/${name}";
|
||||
};
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
{ user ? throw "user argument is required" }: { config, pkgs, ... }:
|
||||
{ user ? throw "user argument is required" }: { config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
hmConfig = config.home-manager.users."${user.name}";
|
||||
@@ -10,24 +10,30 @@ in
|
||||
persistence."/cache${user.home}".directories = [ "${hmConfig.xdg.relativeCacheHome}/swww" ];
|
||||
};
|
||||
|
||||
theme.extraConfig = let name = "theme-swww"; in
|
||||
wayland.windowManager.hyprland.initExtraConfig = let name = "init-swww"; in
|
||||
"${pkgs.writeShellApplication {
|
||||
inherit name;
|
||||
runtimeInputs = with pkgs; [
|
||||
coreutils-full
|
||||
swww
|
||||
];
|
||||
text = ''
|
||||
if ! pgrep -x "swww-daemon" > /dev/null; then
|
||||
swww-daemon &> /tmp/swww.log &
|
||||
fi
|
||||
inherit name;
|
||||
runtimeInputs = with pkgs; [ swww ];
|
||||
text = ''
|
||||
swww-daemon &> /tmp/swww.log
|
||||
'';
|
||||
}}/bin/${name} &";
|
||||
|
||||
while ! swww query &> /dev/null; do
|
||||
sleep 0.1
|
||||
done
|
||||
theme.extraConfig = let name = "theme-swww"; in
|
||||
lib.mkAfter "${pkgs.writeShellApplication {
|
||||
inherit name;
|
||||
runtimeInputs = with pkgs; [
|
||||
coreutils-full
|
||||
procps
|
||||
swww
|
||||
];
|
||||
text = ''
|
||||
while ! swww query &> /dev/null; do
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
swww img "${hmConfig.theme.configDir}/wallpaper"
|
||||
'';
|
||||
}}/bin/${name}";
|
||||
swww img "${hmConfig.theme.configDir}/wallpaper"
|
||||
'';
|
||||
}}/bin/${name} &";
|
||||
};
|
||||
}
|
||||
|
@@ -6,6 +6,7 @@ in
|
||||
{
|
||||
home-manager.users."${user.name}" = {
|
||||
theme.enable = true;
|
||||
wayland.windowManager.hyprland.initExtraConfig = "${hmConfig.theme.pkg}/bin/theme &";
|
||||
home.persistence."/persist${user.home}".directories = [ "${hmConfig.xdg.relativeConfigHome}/theme" ];
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user