185 lines
6.2 KiB
Nix
185 lines
6.2 KiB
Nix
{ pkgs, lib, config, ... }:
|
|
|
|
with lib;
|
|
with lib.my;
|
|
let
|
|
cfg = config.modules.desktop.themes;
|
|
in {
|
|
options.modules.desktop.themes = with types; {
|
|
active = mkOption {
|
|
type = types.nullOr types.str;
|
|
default = null;
|
|
description = "Name of the theme to apply; see modules/desktop/themes for a list of valid options";
|
|
};
|
|
|
|
dark = mkOpt bool false;
|
|
|
|
gtkTheme = {
|
|
name = mkOpt str "";
|
|
package = mkPackageOption pkgs "gtk" {};
|
|
};
|
|
kvantumTheme = {
|
|
name = mkOpt str "";
|
|
package = mkPackageOption pkgs "kvantum" {};
|
|
};
|
|
iconTheme = {
|
|
name = mkOpt str "";
|
|
package = mkPackageOption pkgs "icon" {};
|
|
};
|
|
cursorTheme = {
|
|
name = mkOpt str "";
|
|
package = mkPackageOption pkgs "cursor" {};
|
|
size = mkOpt int 24;
|
|
};
|
|
sddmTheme = {
|
|
name = mkOpt str "";
|
|
package = mkPackageOption pkgs "sddm" {};
|
|
};
|
|
plymouthTheme = {
|
|
name = mkOpt str "";
|
|
package = mkPackageOption pkgs "plymouth" {};
|
|
};
|
|
|
|
editor = {
|
|
vscode = {
|
|
colorTheme = {
|
|
name = mkOpt str "";
|
|
extension = mkPackageOption pkgs "extension" {};
|
|
};
|
|
iconTheme = {
|
|
name = mkOpt str "";
|
|
extension = mkPackageOption pkgs "extension" {};
|
|
};
|
|
};
|
|
};
|
|
|
|
hyprland = {
|
|
source = mkOpt (nullOr str) null;
|
|
extraConfig = mkOpt (nullOr str) null;
|
|
};
|
|
|
|
waybar = mkOpt str "";
|
|
|
|
wob = {
|
|
borderColor = mkOpt (nullOr str) null;
|
|
backgroundColor = mkOpt (nullOr str) null;
|
|
barColor = mkOpt (nullOr str) null;
|
|
};
|
|
|
|
rofi = mkOpt (nullOr path) null;
|
|
|
|
wezterm = mkOpt (nullOr str) null;
|
|
|
|
nwg-drawer = mkOpt (nullOr str) null;
|
|
};
|
|
|
|
config = mkIf (cfg.active != null) {
|
|
programs.dconf.enable = true;
|
|
hm.dconf = {
|
|
enable = true;
|
|
settings."org/gnome/desktop/interface".color-scheme = mkIf cfg.dark "prefer-dark";
|
|
settings."org/gnome/desktop/interface".gtk-theme = cfg.gtkTheme.name;
|
|
settings."org/gnome/desktop/interface".icon-theme = cfg.iconTheme.name;
|
|
settings."org/gnome/desktop/interface".cursor-theme = cfg.cursorTheme.name;
|
|
settings."org/gnome/desktop/interface".cursor-size = cfg.cursorTheme.size;
|
|
|
|
settings."org/gnome/shell/extensions/user-theme".name = cfg.gtkTheme.name;
|
|
};
|
|
|
|
hm.gtk = {
|
|
enable = true;
|
|
cursorTheme = {
|
|
name = cfg.cursorTheme.name;
|
|
package = cfg.cursorTheme.package;
|
|
size = cfg.cursorTheme.size;
|
|
};
|
|
iconTheme = cfg.iconTheme;
|
|
theme = cfg.gtkTheme;
|
|
gtk3.extraConfig.gtk-application-prefer-dark-theme = mkIf cfg.dark "1";
|
|
gtk4.extraConfig.gtk-application-prefer-dark-theme = mkIf cfg.dark "1";
|
|
};
|
|
|
|
hm.qt = {
|
|
enable = true;
|
|
platformTheme.name = "qtct";
|
|
style.name = "kvantum";
|
|
};
|
|
|
|
hm.home.pointerCursor = {
|
|
gtk.enable = true;
|
|
x11.enable = true;
|
|
name = cfg.cursorTheme.name;
|
|
package = cfg.cursorTheme.package;
|
|
size = cfg.cursorTheme.size;
|
|
};
|
|
|
|
hm.services.dunst.iconTheme = {
|
|
name = cfg.iconTheme.name;
|
|
package = cfg.iconTheme.package;
|
|
};
|
|
|
|
hm.programs.vscode = {
|
|
extensions = [
|
|
cfg.editor.vscode.colorTheme.extension
|
|
cfg.editor.vscode.iconTheme.extension
|
|
];
|
|
userSettings = {
|
|
"workbench.colorTheme" = cfg.editor.vscode.colorTheme.name;
|
|
"workbench.iconTheme" = cfg.editor.vscode.iconTheme.name;
|
|
};
|
|
};
|
|
|
|
hm.wayland.windowManager.hyprland = {
|
|
settings.source = mkIf (cfg.hyprland.source != null) [ cfg.hyprland.source ];
|
|
extraConfig = mkIf (cfg.hyprland.extraConfig != null) cfg.hyprland.extraConfig;
|
|
};
|
|
|
|
hm.programs.waybar.style = cfg.waybar;
|
|
|
|
hm.services.wob.settings."" = {
|
|
border_color = cfg.wob.borderColor;
|
|
background_color = cfg.wob.backgroundColor;
|
|
bar_color = cfg.wob.barColor;
|
|
};
|
|
|
|
hm.programs.rofi.theme = cfg.rofi;
|
|
|
|
hm.xdg.configFile = let
|
|
iniFmt = pkgs.formats.ini {};
|
|
mkQtctConf = version: let
|
|
zeroCount = if version == 5 then 5 else if version == 6 then 10 else builtins.throw "invalid qtct version";
|
|
zeros = builtins.concatStringsSep "," (builtins.genList (_: "0") zeroCount);
|
|
weight = if version == 5 then 50 else if version == 6 then 400 else builtins.throw "invalid qtct version";
|
|
in {
|
|
Appearance = {
|
|
icon_theme = cfg.iconTheme.name;
|
|
standard_dialogs = "xdgdesktopportal";
|
|
style = "kvantum";
|
|
};
|
|
|
|
Fonts = with config.modules.desktop.fonts.fonts; {
|
|
# i'm going to go on a rant here
|
|
# this actually SUCKS omg
|
|
# god is dead and The Qt Company killed him
|
|
# (for qt5, font weight is on a different scale where 50 is equivalent to 400 in qt6, even more fun)
|
|
# font weight is set to 400, this is the default weight for every font ever and it will fall back to something else if the font doesn't have a 400 weight (ex. cozette only has a 500 weight)
|
|
# setting the font style name is BAD!! i found it breaks font selection for others that aren't the weight that is given, and it's not required anyway
|
|
# technically this isn't perfect because we are setting the font size in points to -1, but it doesn't matter since we define it in pixels right afterwards. this causes only a warning in the logs for some qt apps!! so it's fine but it's still a bit annoying because i'm weird
|
|
# oh and, because why not, the qt5 font config has less zeros than the qt6 font config. the docs don't say anything about this. i am going to kill myself @The Qt Company
|
|
# yapping over. this is the best we can do for now
|
|
general = ''"${sansSerif.family},-1,${toString sansSerif.size},5,${toString weight},${zeros},1"'';
|
|
fixed = ''"${monospace.family},-1,${toString monospace.size},5,${toString weight},${zeros},1"'';
|
|
};
|
|
};
|
|
in {
|
|
"Kvantum/${cfg.kvantumTheme.name}".source = "${cfg.kvantumTheme.package}/share/Kvantum/${cfg.kvantumTheme.name}";
|
|
"Kvantum/kvantum.kvconfig".text = ''
|
|
[General]
|
|
theme=${cfg.kvantumTheme.name}
|
|
'';
|
|
|
|
"qt5ct/qt5ct.conf".source = iniFmt.generate "qt5ct.conf" (mkQtctConf 5);
|
|
"qt6ct/qt6ct.conf".source = iniFmt.generate "qt6ct.conf" (mkQtctConf 6);
|
|
};
|
|
};
|
|
}
|