programs/waybar: simplify styling and move generateGtkColors to lib

This commit is contained in:
Anthony Rodriguez 2024-11-26 15:38:03 +01:00
parent 59adcecd10
commit 20bbc9736c
Signed by: nezia
GPG key ID: EE3BE97C040A86CE
4 changed files with 105 additions and 114 deletions

View file

@ -1,16 +1,22 @@
{ {
pkgs, pkgs,
lib, lib,
lib',
osConfig, osConfig,
config, config,
... ...
}: let }: let
inherit (lib) getExe mkMerge mkIf; inherit (lib) getExe mkMerge mkIf optionalString;
inherit (lib') generateGtkColors;
inherit (osConfig.theme.scheme) palette;
inherit (builtins) readFile;
in { in {
imports = [./style.nix];
programs.waybar = { programs.waybar = {
enable = true; enable = true;
systemd.enable = true; systemd.enable = true;
style =
optionalString osConfig.theme.enable generateGtkColors lib palette
+ readFile ./style.css;
settings = { settings = {
mainBar = mkMerge [ mainBar = mkMerge [
{ {

View file

@ -0,0 +1,91 @@
* {
/* `otf-font-awesome` is required to be installed for icons */
border: none;
border-radius: 0px;
min-height: 0;
}
window#waybar {
border-radius: 2em;
font-family: "Symbols Nerd Font", Inter, sans-serif;
font-size: 16px;
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;
}
#workspaces,
.modules-right box {
background: @base02;
padding: 0.15em 0.25em;
border-radius: 1em;
margin: 0 0.25em;
}
#workspaces {
padding: 0;
background: @base02;
}
#workspaces button:nth-child(1) {
border-top-left-radius: 1em;
border-bottom-left-radius: 1em;
}
#workspaces button:nth-last-child(1) {
border-top-right-radius: 1em;
border-bottom-right-radius: 1em;
}
#workspaces button {
padding: 0 0.5em;
background-color: transparent;
}
#workspaces button:hover {
background: rgba(255, 255, 255, 0.1);
box-shadow: none;
}
#workspaces button.active {
background: @base0E;
color: @base02;
}
#workspaces button.urgent {
background: @base08;
}
#window {
margin-left: 1em;
}
.modules-left,
.modules-right {
margin: 0.4em 0.5em;
}
#battery,
#clock,
#network,
#pulseaudio,
#tray,
#power-profiles-daemon {
padding: 0 0.5em;
}
.modules-left,
.modules-right {
margin: 0.4em 0.5em;
}
#custom-power {
padding: 0 1.2em;
color: @base08;
}
#custom-notification {
padding: 0 1.2em;
}

View file

@ -1,111 +0,0 @@
{
lib,
osConfig,
...
}: let
inherit (osConfig.theme.scheme) palette;
inherit (lib) mapAttrsToList concatLines optionalString;
generateGtkColors = palette: (concatLines
(mapAttrsToList
(name: color: "@define-color ${name} ${color};")
palette));
in {
programs.waybar.style =
optionalString osConfig.theme.enable generateGtkColors palette
+ ''
* {
/* `otf-font-awesome` is required to be installed for icons */
border: none;
border-radius: 0px;
min-height: 0;
}
window#waybar {
border-radius: 2em;
font-family: "Symbols Nerd Font", Inter, sans-serif;
font-size: 16px;
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;
}
#workspaces,
.modules-right box {
background: @base02;
padding: 0.15em 0.25em;
border-radius: 1em;
margin: 0 0.25em;
}
#workspaces {
padding: 0;
background: @base02;
}
#workspaces button:nth-child(1) {
border-top-left-radius: 1em;
border-bottom-left-radius: 1em;
}
#workspaces button:nth-last-child(1) {
border-top-right-radius: 1em;
border-bottom-right-radius: 1em;
}
#workspaces button {
padding: 0 0.5em;
background-color: transparent;
}
#workspaces button:hover {
background: rgba(255, 255, 255, 0.1);
box-shadow: none;
}
#workspaces button.active {
background: @base0E;
color: @base02;
}
#workspaces button.urgent {
background: @base08;
}
#window {
margin-left: 1em;
}
.modules-left,
.modules-right {
margin: 0.4em 0.5em;
}
#battery,
#clock,
#network,
#pulseaudio,
#tray,
#power-profiles-daemon
{
padding: 0 0.5em;
}
.modules-left,
.modules-right {
margin: 0.4em 0.5em;
}
#custom-power {
padding: 0 1.2em;
color: @base08;
}
#custom-notification {
padding: 0 1.2em;
}
'';
}

View file

@ -50,6 +50,11 @@ let
'' ''
magick ${path} -gaussian-blur 0x12 "$out" magick ${path} -gaussian-blur 0x12 "$out"
''; '';
generateGtkColors = lib: palette: (lib.concatLines
(lib.mapAttrsToList
(name: color: "@define-color ${name} ${color};")
palette));
in { in {
inherit blurImage rgba; inherit blurImage generateGtkColors rgba;
} }