treewide: conditionally add theming

This commit is contained in:
Anthony Rodriguez 2024-11-21 17:44:42 +01:00
parent 81852b26d2
commit f06229cc33
Signed by: nezia
GPG key ID: EE3BE97C040A86CE
5 changed files with 207 additions and 193 deletions

View file

@ -5,7 +5,7 @@
osConfig, osConfig,
... ...
}: let }: let
inherit (osConfig.theme.scheme) palette; inherit (lib) mkMerge mkIf;
in { in {
imports = [./binds.nix]; imports = [./binds.nix];
@ -22,79 +22,85 @@ in {
}; };
}; };
programs.niri = { programs.niri = mkMerge [
settings = { {
input = { settings = {
power-key-handling.enable = false; input = {
keyboard.xkb = { power-key-handling.enable = false;
layout = "us"; keyboard.xkb = {
options = "compose:ralt"; layout = "us";
}; options = "compose:ralt";
};
prefer-no-csd = true;
hotkey-overlay.skip-at-startup = true;
layout = {
focus-ring = {
enable = true;
active.color = palette.base0E;
};
always-center-single-column = true;
};
# https://github.com/sodiboo/system/blob/2978f4d79c51a5bd7e38a9cd75e3ec9046aa7e75/niri.mod.nix#L418-L434
outputs = let
cfg = config.programs.niri.settings.outputs;
in {
"HDMI-A-1" = {
mode = {
width = 1920;
height = 1080;
refresh = 60.0;
}; };
position.x = -cfg."HDMI-A-1".mode.width;
position.y = 0;
}; };
"DP-1" = {
mode = { prefer-no-csd = true;
width = 2560; hotkey-overlay.skip-at-startup = true;
height = 1440;
refresh = 144.0; layout = {
focus-ring = {
enable = true;
}; };
position.x = 0; always-center-single-column = true;
position.y = 0; };
# https://github.com/sodiboo/system/blob/2978f4d79c51a5bd7e38a9cd75e3ec9046aa7e75/niri.mod.nix#L418-L434
outputs = let
cfg = config.programs.niri.settings.outputs;
in {
"HDMI-A-1" = {
mode = {
width = 1920;
height = 1080;
refresh = 60.0;
};
position.x = -cfg."HDMI-A-1".mode.width;
position.y = 0;
};
"DP-1" = {
mode = {
width = 2560;
height = 1440;
refresh = 144.0;
};
position.x = 0;
position.y = 0;
};
};
window-rules = [
{
draw-border-with-background = false;
geometry-corner-radius = let
r = 8.0;
in {
top-left = r;
top-right = r;
bottom-left = r;
bottom-right = r;
};
clip-to-geometry = true;
}
{
matches = [
{app-id = "foot";}
];
default-column-width = {proportion = 0.5;};
}
];
environment = {
"NIXOS_OZONE_WL" = "1";
"DISPLAY" = ":0";
"_JAVA_AWT_WM_NONREPARENTING" = "1"; # https://wiki.archlinux.org/title/Sway#Java_applications
}; };
}; };
}
window-rules = [ (mkIf osConfig.theme.enable (let
{ inherit (osConfig.theme.scheme) palette;
draw-border-with-background = false; in {
geometry-corner-radius = let layout.focus-ring.active.color = palette.base0E;
r = 8.0; }))
in { ];
top-left = r;
top-right = r;
bottom-left = r;
bottom-right = r;
};
clip-to-geometry = true;
}
{
matches = [
{app-id = "foot";}
];
default-column-width = {proportion = 0.5;};
}
];
environment = {
"NIXOS_OZONE_WL" = "1";
"DISPLAY" = ":0";
"_JAVA_AWT_WM_NONREPARENTING" = "1"; # https://wiki.archlinux.org/title/Sway#Java_applications
};
};
};
# copied from https://github.com/linyinfeng/dotfiles/blob/c00fe3b1562ad947672863a43e455bc2f01a56b6/home-manager/profiles/niri/default.nix#L594-L611 # copied from https://github.com/linyinfeng/dotfiles/blob/c00fe3b1562ad947672863a43e455bc2f01a56b6/home-manager/profiles/niri/default.nix#L594-L611
systemd.user.services.xwayland-satellite = { systemd.user.services.xwayland-satellite = {

View file

@ -1,9 +1,10 @@
{ {
pkgs, pkgs,
osConfig, osConfig,
lib,
... ...
}: let }: let
inherit (osConfig.theme.scheme) palette; inherit (lib) mkMerge mkIf;
in { in {
# requires `security.pam.services.swaylock = { };` at the system level or else # requires `security.pam.services.swaylock = { };` at the system level or else
# unlock will not work. # unlock will not work.
@ -11,46 +12,53 @@ in {
enable = true; enable = true;
package = pkgs.swaylock-effects; package = pkgs.swaylock-effects;
settings = { settings = mkMerge [
clock = true; {
timestr = "%H:%M"; clock = true;
timestr = "%H:%M";
indicator = true; indicator = true;
indicator-radius = 111; indicator-radius = 111;
indicator-thickness = 9; indicator-thickness = 9;
screenshots = true; screenshots = true;
effect-blur = "7x5"; effect-blur = "7x5";
effect-vignette = "0.75:0.75"; effect-vignette = "0.75:0.75";
effect-pixelate = 5; effect-pixelate = 5;
ignore-empty-password = false; # needed for PAM to work with fprintd / password ignore-empty-password = false; # needed for PAM to work with fprintd / password
}
inside-color = palette.base01; (mkIf
inside-clear-color = palette.base0C; osConfig.theme.enable
inside-caps-lock-color = palette.base09; (let
inside-ver-color = palette.base0D; inherit (osConfig.theme.scheme) palette;
inside-wrong-color = palette.base08; in {
key-hl-color = palette.base0B; inside-color = palette.base01;
layout-bg-color = palette.base00; inside-clear-color = palette.base0C;
layout-border-color = palette.base05; inside-caps-lock-color = palette.base09;
layout-text-color = palette.base07; inside-ver-color = palette.base0D;
line-color = palette.base00; inside-wrong-color = palette.base08;
line-clear-color = palette.base0C; key-hl-color = palette.base0B;
line-caps-lock-color = palette.base09; layout-bg-color = palette.base00;
line-ver-color = palette.base0D; layout-border-color = palette.base05;
line-wrong-color = palette.base08; layout-text-color = palette.base07;
ring-color = palette.base02; line-color = palette.base00;
ring-clear-color = palette.base0C; line-clear-color = palette.base0C;
ring-caps-lock-color = palette.base09; line-caps-lock-color = palette.base09;
ring-ver-color = palette.base0D; line-ver-color = palette.base0D;
ring-wrong-color = palette.base08; line-wrong-color = palette.base08;
separator-color = palette.base02; ring-color = palette.base02;
text-color = palette.base07; ring-clear-color = palette.base0C;
text-clear-color = palette.base04; ring-caps-lock-color = palette.base09;
text-caps-lock-color = palette.base04; ring-ver-color = palette.base0D;
text-ver-color = palette.base04; ring-wrong-color = palette.base08;
text-wrong-color = palette.base04; separator-color = palette.base02;
}; text-color = palette.base07;
text-clear-color = palette.base04;
text-caps-lock-color = palette.base04;
text-ver-color = palette.base04;
text-wrong-color = palette.base04;
}))
];
}; };
} }

View file

@ -5,106 +5,103 @@
}: let }: let
inherit (osConfig.theme.scheme) palette; inherit (osConfig.theme.scheme) palette;
inherit (builtins) concatStringsSep; inherit (builtins) concatStringsSep;
inherit (lib) mapAttrsToList; inherit (lib) mapAttrsToList mkIf mkMerge;
generateGtkColors = palette: (concatStringsSep "\n" generateGtkColors = palette: (concatStringsSep "\n"
(mapAttrsToList (mapAttrsToList
(name: color: "@define-color ${name} ${color};") (name: color: "@define-color ${name} ${color};")
palette)); palette));
in { in {
programs.waybar.style = '' programs.waybar.style = mkMerge [
${ (mkIf osConfig.theme.enable generateGtkColors palette)
if osConfig.theme.enable ''
then generateGtkColors palette * {
else "" /* `otf-font-awesome` is required to be installed for icons */
} border: none;
border-radius: 0px;
min-height: 0;
}
* { window#waybar {
/* `otf-font-awesome` is required to be installed for icons */ border-radius: 2em;
border: none; font-family: "Symbols Nerd Font", Inter, sans-serif;
border-radius: 0px; font-size: 16px;
min-height: 0; font-style: normal;
} background: alpha(
@base00,
0.9999999
); /* niri issue workaround, thanks https://github.com/oatmealine/nix-config/blob/bfdddd2cb36ef659bcddc28e0dbb542b6db8b3bc/modules/desktop/themes/catppuccin/waybar.css#L14 */
color: @base05;
}
window#waybar { #workspaces,
border-radius: 2em; .modules-right box {
font-family: "Symbols Nerd Font", Inter, sans-serif; background: @base02;
font-size: 16px; padding: 0.15em 0.25em;
font-style: normal; border-radius: 1em;
background: alpha( margin: 0 0.25em;
@base00, }
0.9999999
); /* niri issue workaround, thanks https://github.com/oatmealine/nix-config/blob/bfdddd2cb36ef659bcddc28e0dbb542b6db8b3bc/modules/desktop/themes/catppuccin/waybar.css#L14 */
color: @base05;
}
#workspaces, #workspaces {
.modules-right box { padding: 0;
background: @base02; background: @base02;
padding: 0.15em 0.25em; }
border-radius: 1em;
margin: 0 0.25em;
}
#workspaces { #workspaces button:nth-child(1) {
padding: 0; border-top-left-radius: 1em;
background: @base02; border-bottom-left-radius: 1em;
} }
#workspaces button:nth-last-child(1) {
border-top-right-radius: 1em;
border-bottom-right-radius: 1em;
}
#workspaces button:nth-child(1) { #workspaces button {
border-top-left-radius: 1em; padding: 0 0.5em;
border-bottom-left-radius: 1em; background-color: transparent;
} }
#workspaces button:nth-last-child(1) {
border-top-right-radius: 1em;
border-bottom-right-radius: 1em;
}
#workspaces button { #workspaces button:hover {
padding: 0 0.5em; background: rgba(255, 255, 255, 0.1);
background-color: transparent; box-shadow: none;
} }
#workspaces button:hover { #workspaces button.active {
background: rgba(255, 255, 255, 0.1); background: @base0E;
box-shadow: none; color: @base02;
} }
#workspaces button.active { #workspaces button.urgent {
background: @base0E; background: @base08;
color: @base02; }
}
#workspaces button.urgent { #window {
background: @base08; margin-left: 1em;
} }
#window { .modules-left,
margin-left: 1em; .modules-right {
} margin: 0.4em 0.5em;
}
.modules-left, #battery,
.modules-right { #clock,
margin: 0.4em 0.5em; #pulseaudio,
} #tray,
#power-profiles-daemon {
padding: 0 0.8em;
}
#battery, .modules-left,
#clock, .modules-right {
#pulseaudio, margin: 0.4em 0.5em;
#tray, }
#power-profiles-daemon {
padding: 0 0.8em;
}
.modules-left,
.modules-right {
margin: 0.4em 0.5em;
}
#custom-power { #custom-power {
padding: 0 1.2em; padding: 0 1.2em;
color: @base08; color: @base08;
} }
''; ''
];
} }

View file

@ -3,7 +3,9 @@
config, config,
lib, lib,
... ...
}: { }: let
inherit (lib) mkIf;
in {
programs.foot = { programs.foot = {
enable = true; enable = true;
settings = { settings = {
@ -12,7 +14,7 @@
font = "monospace:size=14"; font = "monospace:size=14";
shell = "${lib.getExe config.programs.fish.package}"; shell = "${lib.getExe config.programs.fish.package}";
}; };
colors = let colors = mkIf osConfig.theme.enable (let
inherit (lib) mapAttrs; inherit (lib) mapAttrs;
inherit (lib.strings) removePrefix; inherit (lib.strings) removePrefix;
# because someone thought this was a great idea: https://github.com/tinted-theming/schemes/commit/61058a8d2e2bd4482b53d57a68feb56cdb991f0b # because someone thought this was a great idea: https://github.com/tinted-theming/schemes/commit/61058a8d2e2bd4482b53d57a68feb56cdb991f0b
@ -38,7 +40,7 @@
bright5 = palette.base0E; bright5 = palette.base0E;
bright6 = palette.base0C; bright6 = palette.base0C;
bright7 = palette.base07; bright7 = palette.base07;
}; });
}; };
}; };
} }

View file

@ -1,6 +1,7 @@
{ {
theme = { theme = {
wallpaper = ../../../wallpapers/lucy-edgerunners-wallpaper.jpg; wallpaper = ../../../wallpapers/lucy-edgerunners-wallpaper.jpg;
schemeName = "catppuccin-macchiato";
enable = true; enable = true;
gtk.enable = false; gtk.enable = false;
}; };