finish switch to stylix

This commit is contained in:
Chris Kruining 2024-08-20 20:19:52 +02:00
parent 4dd4497139
commit f4774a6cae
10 changed files with 229 additions and 548 deletions

View file

@ -142,229 +142,6 @@ in {
};
config = mkIf (cfg.active != null) (mkMerge [
{
# Allow HM to control GTK Theme:
programs.dconf.enable = true;
hm.gtk = let
inherit (cfg.font) sans;
inherit (cfg) gtk iconTheme;
in {
enable = true;
font = {
name = sans.family;
size = sans.size;
};
theme = {
name = gtk.name;
package = gtk.package;
};
iconTheme = {
name = iconTheme.name;
package = iconTheme.package;
};
gtk3.bookmarks = map (dir: "file://${config.user.home}/" + dir) [
"data/Github/.files"
];
gtk4.extraConfig = {
gtk-cursor-blink = false;
gtk-recent-files-limit = 20;
};
};
home.pointerCursor = let
inherit (cfg.pointer) name package size;
in {
name = name;
package = package;
size = size;
gtk.enable = true;
};
fonts = let
inherit (cfg.fontConfig) packages emoji mono sans;
in {
packages = packages;
fontconfig.defaultFonts = {
monospace = mono;
sansSerif = sans;
emoji = emoji;
};
};
hm.programs.vscode.extensions = let
inherit (cfg.vscode.extension) name publisher version hash;
in
pkgs.vscode-utils.extensionsFromVscodeMarketplace [
{
name = "${name}";
publisher = "${publisher}";
version = "${version}";
hash = "${hash}";
}
];
}
(mkIf (desktop.type == "wayland") (mkMerge [
{
programs.regreet.settings.GTK = let
inherit (cfg) pointer font iconTheme gtk;
in {
cursor_theme_name = "${pointer.name}";
font_name = "${font.mono.family}";
icon_theme_name = "${iconTheme.name}";
theme_name = "${gtk.name}";
};
}
(mkIf (cfg.wallpaper != null) {
user.packages = attrValues {inherit (pkgs) swww;};
hm.systemd.user.services = {
swww = {
Unit = {
Description = "Wallpaper daemon for wayland";
After = ["graphical-session.target"];
PartOf = ["graphical-session.target"];
};
Install.WantedBy = ["graphical-session.target"];
Service = {
Type = "simple";
ExecStart = "${pkgs.swww}/bin/swww-daemon";
ExecStop = "${getExe pkgs.swww} kill";
Restart = "on-failure";
};
};
swww-wallpaper = {
Unit = {
Description = "Default swww wallpaper";
After = ["swww.service"];
PartOf = ["swww.service"];
};
Service = {
Type = "oneshot";
ExecStart = ''
if [ -e "$XDG_DATA_HOME/wallpaper" ]; then
${getExe pkgs.swww} \
img $XDG_DATA_HOME/wallpaper \
--transition-type random \
--transition-fps 60
fi
'';
Restart = "on-failure";
};
Install.WantedBy = ["swww.service"];
};
};
create.dataFile =
mkIf (cfg.wallpaper != null) {"wallpaper".source = cfg.wallpaper;};
})
]))
(mkIf (desktop.type == "x11") (mkMerge [
{
hm.xresources = {
path = "${config.user.home}/.Xresources";
properties = let
inherit (cfg.colors.main) bright normal types;
in {
"*.foreground" = "${types.fg}";
"*.background" = "${types.bg}";
"*.color0" = "${normal.black}";
"*.color8" = "${bright.black}";
"*.color1" = "${normal.red}";
"*.color9" = "${bright.red}";
"*.color2" = "${normal.green}";
"*.color10" = "${bright.green}";
"*.color3" = "${normal.yellow}";
"*.color11" = "${bright.yellow}";
"*.color4" = "${normal.blue}";
"*.color12" = "${bright.blue}";
"*.color5" = "${normal.magenta}";
"*.color13" = "${bright.magenta}";
"*.color6" = "${normal.cyan}";
"*.color14" = "${bright.cyan}";
"*.color7" = "${normal.white}";
"*.color15" = "${bright.white}";
};
};
home.pointerCursor.x11 = {
enable = true;
defaultCursor = "left_ptr";
};
}
# Apply theme options -> lightdm-mini-greeter
(mkIf (cfg.loginWallpaper != null) {
services.xserver.displayManager.lightdm = {
greeters.mini.extraConfig = let
inherit (cfg.colors.main) normal types;
in ''
background-image = "${cfg.loginWallpaper}"
background-image-size = "100% 100%"
text-color = "${types.bg}"
password-background-color = "${normal.black}"
window-color = "${types.border}"
border-color = "${types.border}"
'';
};
})
# Auto-set wallpaper to prevent $HOME pollution!
(mkIf (cfg.wallpaper != null) (let
wCfg = config.services.xserver.desktopManager.wallpaper;
command = ''
if [ -e "$XDG_DATA_HOME/wallpaper" ]; then
${getExe pkgs.feh} --bg-${wCfg.mode} \
${optionalString wCfg.combineScreens "--no-xinerama"} \
--no-fehbg \
$XDG_DATA_HOME/wallpaper
fi
'';
in {
modules.themes.onReload.wallpaper = command;
services.xserver.displayManager.sessionCommands = command;
create.dataFile =
mkIf (cfg.wallpaper != null) {"wallpaper".source = cfg.wallpaper;};
}))
(mkIf (cfg.loginWallpaper != null) {
programs.regreet.settings.background = {
path = cfg.loginWallpaper;
fit = "Fill";
};
})
(mkIf (cfg.onReload != {}) (let
reloadTheme = let
inherit (pkgs) stdenv writeScriptBin;
in (writeScriptBin "reloadTheme" ''
#!${stdenv.shell}
echo "Reloading current theme: ${cfg.active}"
${concatStringsSep "\n" (mapAttrsToList (name: script: ''
echo "[${name}]"
${script}
'')
cfg.onReload)}
'');
in {
user.packages = [reloadTheme];
system.userActivationScripts.reloadTheme = ''
[ -z "$NORELOAD" ] && ${reloadTheme}/bin/reloadTheme
'';
}))
]))
(mkIf (desktop.type == "wayland") (mkMerge []))
]);
}