nixos/home/hyprland/waybar/default.nix

247 lines
6.2 KiB
Nix
Raw Normal View History

2024-04-22 20:34:14 +00:00
{ pkgs, lib, osConfig, ... }:
2024-04-21 09:46:33 +00:00
let
flakestat = pkgs.writeShellApplication {
name = "flakestat";
runtimeInputs = with pkgs; [
git
jq
];
text = builtins.readFile ./flakestat.sh;
};
2024-04-26 10:45:55 +00:00
arrhist = pkgs.stdenv.mkDerivation {
name = "arrhist";
propagatedBuildInputs = [
(pkgs.python3.withPackages (pythonPackages: with pythonPackages; [
requests
]))
];
src = ./arrhist.py;
dontUnpack = true;
installPhase = "install -Dm755 ${./arrhist.py} $out/bin/arrhist";
};
withArrhist = if (osConfig.system.name == "gunter") then true else false;
withBattery = if (osConfig.system.name == "magicman") then true else false;
2024-04-21 09:46:33 +00:00
in
{
2024-04-26 10:45:55 +00:00
sops.secrets."sonarr_base_url" = { };
sops.secrets."sonarr_api_key" = { };
sops.secrets."radarr_base_url" = { };
sops.secrets."radarr_api_key" = { };
2024-03-06 08:23:51 +00:00
xdg.configFile."waybar/macchiato.css" = {
source = pkgs.fetchFromGitHub
{
owner = "catppuccin";
repo = "waybar";
rev = "f74ab1eecf2dcaf22569b396eed53b2b2fbe8aff";
sha256 = "WLJMA2X20E5PCPg0ZPtSop0bfmu+pLImP9t8A8V4QK8=";
2024-05-29 22:01:21 +00:00
} + "/themes/macchiato.css";
2024-03-06 08:23:51 +00:00
};
2024-02-27 20:13:42 +00:00
programs.waybar = {
enable = true;
systemd = {
enable = false; # disable it,autostart it in hyprland conf
target = "graphical-session.target";
};
style = ''
2024-05-29 22:01:21 +00:00
@import "macchiato.css";
2024-02-27 20:13:42 +00:00
* {
2024-05-29 22:01:21 +00:00
border: none;
font-family: "JetbrainsMono Nerd Font";
font-size: 15px;
2024-02-27 20:13:42 +00:00
transition-property: background-color;
transition-duration: 0.5s;
2024-05-29 22:01:21 +00:00
color: @text;
2024-05-31 10:53:58 +00:00
border-radius: 10px;
min-height: 10px;
2024-02-27 20:13:42 +00:00
}
2024-05-29 22:01:21 +00:00
window#waybar {
2024-05-31 10:53:58 +00:00
background-color: @surface2;
border-radius: 0px;
2024-05-29 22:01:21 +00:00
}
window#waybar.hidden {
opacity: 0.2;
}
#window {
margin-top: 6px;
padding-left: 10px;
padding-right: 10px;
2024-05-31 10:53:58 +00:00
border-radius: 0px;
2024-05-29 22:01:21 +00:00
transition: none;
color: transparent;
2024-05-31 10:53:58 +00:00
background-color: @surface2;
2024-05-29 22:01:21 +00:00
}
2024-02-27 20:13:42 +00:00
@keyframes blink_red {
to {
2024-05-29 22:01:21 +00:00
background-color: @red;
2024-02-27 20:13:42 +00:00
}
}
.warning,
.critical,
.urgent {
animation-name: blink_red;
animation-duration: 1s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
#workspaces {
2024-05-29 22:01:21 +00:00
padding-left: 12px;
padding-right: 12px;
background-color: @base;
2024-02-27 20:13:42 +00:00
}
#workspaces button {
2024-05-29 22:01:21 +00:00
padding-left: 12px;
padding-right: 12px;
2024-02-27 20:13:42 +00:00
}
#workspaces button.active {
2024-05-31 10:53:58 +00:00
background-color: @surface2;
2024-02-27 20:13:42 +00:00
}
#workspaces button.urgent {
2024-05-29 22:01:21 +00:00
color: alpha(@red, 0.4);
2024-02-27 20:13:42 +00:00
}
#workspaces button:hover {
2024-05-29 22:01:21 +00:00
background-color: @surface2;
2024-02-27 20:13:42 +00:00
}
tooltip {
2024-05-29 22:01:21 +00:00
background-color: @base;
2024-02-27 20:13:42 +00:00
}
tooltip label {
2024-05-29 22:01:21 +00:00
color: @text;
2024-02-27 20:13:42 +00:00
}
#custom-launcher {
2024-05-29 22:01:21 +00:00
font-size: 15px;
padding-left: 5px;
padding-right: 12px;
background-color: @base;
}
.modules-right {
background-color: @base;
2024-05-31 10:53:58 +00:00
border-radius: 10px 0px 0px 10px;
}
.modules-left {
background-color: @base;
border-radius: 0px 10px 10px 0px;
2024-02-27 20:13:42 +00:00
}
#mode,
#clock,
#memory,
#temperature,
#cpu,
#mpd,
#custom-wall,
#temperature,
#backlight,
#pulseaudio,
#network,
#battery,
#custom-powermenu,
2024-04-21 09:46:33 +00:00
#custom-flakestat,
2024-05-29 22:01:21 +00:00
#custom-arrhist {
padding-left: 12px;
padding-right: 12px;
2024-02-27 20:13:42 +00:00
}
#battery.charging,
#battery.full,
#battery.discharging {
2024-05-29 22:01:21 +00:00
color: @maroon;
2024-02-27 20:13:42 +00:00
}
#battery.critical:not(.charging) {
2024-05-29 22:01:21 +00:00
color: @red;
2024-02-27 20:13:42 +00:00
}
'';
2024-04-26 10:45:55 +00:00
settings = [
({
"layer" = "top";
"position" = "top";
2024-05-29 22:01:21 +00:00
modules-left = [ "custom/flakestat" ];
modules-center = [ "hyprland/workspaces" ];
2024-04-26 10:45:55 +00:00
modules-right =
[
(lib.mkIf (withArrhist) "custom/arrhist")
"pulseaudio"
"pulseaudio#microphone"
"memory"
"cpu"
(lib.mkIf (withBattery) "battery")
2024-05-29 22:01:21 +00:00
"clock"
2024-05-31 10:53:58 +00:00
"tray"
2024-04-26 10:45:55 +00:00
];
"hyprland/workspaces" = {
"format" = "{name}";
"on-click" = "activate";
"on-scroll-up" = "hyprctl dispatch workspace e+1";
"on-scroll-down" = "hyprctl dispatch workspace e-1";
};
"pulseaudio" = {
"scroll-step" = 5;
"format" = "{icon} {volume}%";
"format-muted" = "";
"format-icons" = { "default" = [ "" "" "" ]; };
"on-click" = "pamixer -t";
};
"pulseaudio#microphone" = {
"format" = "{format_source}";
"format-source" = " {volume}%";
"format-source-muted" = "";
"on-click" = "pamixer --default-source -t";
"on-scroll-up" = "pamixer --default-source -i 5";
"on-scroll-down" = "pamixer --default-source -d 5";
"scroll-step" = 5;
"on-click-right" = "pavucontrol";
};
"clock" = {
"interval" = 1;
"format" = "{:%H:%M %A %b %d}";
"tooltip" = true;
2024-04-21 09:46:33 +00:00
};
2024-04-26 10:45:55 +00:00
"memory" = {
"interval" = 3;
"format" = " {percentage}%";
"states" = { "warning" = 85; };
};
"cpu" = {
"interval" = 3;
"format" = " {usage}%";
};
"tray" = {
"icon-size" = 15;
"spacing" = 6;
};
"battery" = {
"interval" = 60;
"states" = {
"warning" = 20;
"critical" = 5;
};
"format" = "{icon} {capacity}%";
"format-icons" = [
""
""
""
""
""
];
};
"custom/flakestat" = {
"exec" = "${flakestat}/bin/flakestat";
2024-04-29 09:51:25 +00:00
"format" = " {}";
"return-type" = "json";
2024-04-26 10:45:55 +00:00
"interval" = 600;
};
} // lib.optionalAttrs (withArrhist) {
"custom/arrhist" = {
"exec" = "${arrhist}/bin/arrhist";
"return-type" = "json";
2024-04-29 09:51:25 +00:00
"interval" = 600;
2024-04-26 10:45:55 +00:00
};
})
];
2024-02-27 20:13:42 +00:00
};
}