Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(waybar): Template CSS #192

Merged
merged 2 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 0 additions & 88 deletions modules/waybar/center.css

This file was deleted.

88 changes: 88 additions & 0 deletions modules/waybar/colors.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
place: ''
window .modules-${place} #workspaces button {
background-color: @base07;
color: @base00;
}
.modules-${place} #wireplumber,
.modules-${place} #pulseaudio,
.modules-${place} #sndio {
background-color: @base09;
color: @base00;
}
.modules-${place} #workspaces button.focused,
.modules-${place} #workspaces button.active {
background: @base03;
}
.modules-${place} #workspaces button.urgent {
background-color: @base08;
}
.modules-${place} #wireplumber.muted,
.modules-${place} #pulseaudio.muted,
.modules-${place} #sndio.muted {
background-color: @base0C;
}
.modules-${place} #upower,
.modules-${place} #battery {
background-color: @base0D;
color: @base00;
}
.modules-${place} #upower.charging,
.modules-${place} #battery.Charging {
background-color: @base0E;
}
.modules-${place} #network {
background-color: @base0B;
color: @base00;
}
.modules-${place} #network.disconnected {
background-color: @base0C;
}
.modules-${place} #user {
background-color: @base0F;
color: @base00;
}
.modules-${place} #clock {
background-color: @base03;
color: @base00;
}
.modules-${place} #backlight {
background-color: @base0E;
color: @base00;
}
.modules-${place} #cpu {
background-color: @base0B;
color: @base00;
}
.modules-${place} #disk {
background-color: @base02;
color: @base00;
}
.modules-${place} #idle_inhibitor {
background-color: @base06;
color: @base00;
}
.modules-${place} #temperature {
background-color: @base07;
color: @base00;
}
.modules-${place} #mpd {
background-color: @base02;
color: @base00;
}
.modules-${place} #language {
background-color: @base02;
color: @base00;
}
.modules-${place} #keyboard-state {
background-color: @base03;
color: @base00;
}
.modules-${place} #memory {
background-color: @base09;
color: @base00;
}
.modules-${place} #window {
background-color: @base0C;
color: @base00;
}
''
104 changes: 45 additions & 59 deletions modules/waybar/hm.nix
Original file line number Diff line number Diff line change
@@ -1,76 +1,62 @@
{ config, lib, ... }:
with config.lib.stylix.colors.withHashtag;
with config.stylix.fonts;

let
colorlessModules = place: ''
.modules-${place} #workspaces button {
border-bottom: 3px solid transparent;
}
.modules-${place} #workspaces button.focused,
.modules-${place} #workspaces button.active {
border-bottom: 3px solid @base05;
}
'';
in
{
options.stylix.targets.waybar = {
enable = config.lib.stylix.mkEnableTarget "Waybar" true;
enableLeftBackColors = lib.mkOption {
type = lib.types.bool;
default = false;
description = lib.mdDoc "enables background colors on the left side of the bar";
};
enableCenterBackColors = lib.mkOption {
type = lib.types.bool;
default = false;
description = lib.mdDoc "enables background colors on the center of the bar";
};
enableRightBackColors = lib.mkOption {
type = lib.types.bool;
default = false;
description = lib.mdDoc "enables background colors on the right side of the bar";
};
enable = config.lib.stylix.mkEnableTarget "Waybar" true;
enableLeftBackColors = lib.mkOption {
type = lib.types.bool;
default = false;
description = lib.mdDoc "enables background colors on the left side of the bar";
};
enableCenterBackColors = lib.mkOption {
type = lib.types.bool;
default = false;
description = lib.mdDoc "enables background colors on the center of the bar";
};
enableRightBackColors = lib.mkOption {
type = lib.types.bool;
default = false;
description = lib.mdDoc "enables background colors on the right side of the bar";
};
};

config = lib.mkIf config.stylix.targets.waybar.enable {
programs.waybar.style = ''
@define-color base00 ${base00}; @define-color base01 ${base01}; @define-color base02 ${base02}; @define-color base03 ${base03};
@define-color base04 ${base04}; @define-color base05 ${base05}; @define-color base06 ${base06}; @define-color base07 ${base07};
@define-color base00 ${base00}; @define-color base01 ${base01}; @define-color base02 ${base02}; @define-color base03 ${base03};
@define-color base04 ${base04}; @define-color base05 ${base05}; @define-color base06 ${base06}; @define-color base07 ${base07};

@define-color base08 ${base08}; @define-color base09 ${base09}; @define-color base0A ${base0A}; @define-color base0B ${base0B};
@define-color base0C ${base0C}; @define-color base0D ${base0D}; @define-color base0E ${base0E}; @define-color base0F ${base0F};
@define-color base08 ${base08}; @define-color base09 ${base09}; @define-color base0A ${base0A}; @define-color base0B ${base0B};
@define-color base0C ${base0C}; @define-color base0D ${base0D}; @define-color base0E ${base0E}; @define-color base0F ${base0F};

* {
font-family: ${sansSerif.name};
font-size: ${builtins.toString sizes.desktop}pt;
}
* {
font-family: ${sansSerif.name};
font-size: ${builtins.toString sizes.desktop}pt;
}

window#waybar, tooltip {
background: alpha(@base00, ${with config.stylix.opacity; builtins.toString desktop});
color: @base05;
}
window#waybar, tooltip {
background: alpha(@base00, ${with config.stylix.opacity; builtins.toString desktop});
color: @base05;
}

tooltip {
border-color: @base0D;
}
tooltip {
border-color: @base0D;
}
''
+ (builtins.readFile ./base.css)
+ (if config.stylix.targets.waybar.enableLeftBackColors then builtins.readFile ./left.css else ''
.modules-left #workspaces button {
border-bottom: 3px solid transparent;
}
.modules-left #workspaces button.focused,
.modules-left #workspaces button.active {
border-bottom: 3px solid @base05;
}
'')
+ (if config.stylix.targets.waybar.enableCenterBackColors then builtins.readFile ./center.css else ''
.modules-center #workspaces button {
border-bottom: 3px solid transparent;
}
.modules-center #workspaces button.focused,
.modules-center #workspaces button.active {
border-bottom: 3px solid @base05;
}
'')
+ (if config.stylix.targets.waybar.enableRightBackColors then builtins.readFile ./right.css else ''
.modules-right #workspaces button {
border-bottom: 3px solid transparent;
}
.modules-right #workspaces button.focused,
.modules-right #workspaces button.active {
border-bottom: 3px solid @base05;
}
'');
+ (if config.stylix.targets.waybar.enableLeftBackColors then (import ./colors.nix "left") else colorlessModules "left")
+ (if config.stylix.targets.waybar.enableCenterBackColors then (import ./colors.nix "center") else colorlessModules "center")
+ (if config.stylix.targets.waybar.enableRightBackColors then (import ./colors.nix "right") else colorlessModules "right");
};
}
86 changes: 0 additions & 86 deletions modules/waybar/left.css

This file was deleted.

Loading