Kieran's opinionated (and probably slightly dumb) nix config

feat: add waybar configs

Changed files
+389 -2
home-manager
moonlark
+8 -1
home-manager/dots/hyprland.conf
···
# See https://wiki.hyprland.org/Configuring/Monitors/
-
monitor=,preferred,auto,1
+
monitor = ,preferred,auto,1
+
monitor = ,addreserved,52,0,0,0
xwayland {
force_zero_scaling = true
···
# Execute your favorite apps at launch
exec-once = sunpaper -d
exec-once = wluma
+
exec-once = waybar
exec-once=[workspace 8 silent] slack
exec-once=[workspace 9 silent] spotify
···
# Example windowrule v2
# windowrulev2 = float,class:^(kitty)$,title:^(kitty)$
# See https://wiki.hyprland.org/Configuring/Window-Rules/ for more
+
+
# Layer Rules
+
layerrule = animation fade,waybar
+
layerrule = blur,waybar
+
layerrule = ignorezero,waybar
# See https://wiki.hyprland.org/Configuring/Keywords/ for more
+3 -1
home-manager/home.nix
···
inputs.catppuccin.homeManagerModules.catppuccin
./hyprland.nix
+
+
./waybar.nix
];
nixpkgs = {
···
style_user = "green";
style_root = "red";
format = "[󱄅 $user]($style) ";
-
disabled = false;
+
disabled = false;
show_always = true;
};
+377
home-manager/waybar.nix
···
+
{
+
outputs,
+
config,
+
lib,
+
pkgs,
+
inputs,
+
...
+
}: let
+
commonDeps = with pkgs; [coreutils gnugrep systemd];
+
# Function to simplify making waybar outputs
+
mkScript = {
+
name ? "script",
+
deps ? [],
+
script ? "",
+
}:
+
lib.getExe (pkgs.writeShellApplication {
+
inherit name;
+
text = script;
+
runtimeInputs = commonDeps ++ deps;
+
});
+
# Specialized for JSON outputs
+
mkScriptJson = {
+
name ? "script",
+
deps ? [],
+
pre ? "",
+
text ? "",
+
tooltip ? "",
+
alt ? "",
+
class ? "",
+
percentage ? "",
+
}:
+
mkScript {
+
inherit name;
+
deps = [pkgs.jq] ++ deps;
+
script = ''
+
${pre}
+
jq -cn \
+
--arg text "${text}" \
+
--arg tooltip "${tooltip}" \
+
--arg alt "${alt}" \
+
--arg class "${class}" \
+
--arg percentage "${percentage}" \
+
'{text:$text,tooltip:$tooltip,alt:$alt,class:$class,percentage:$percentage}'
+
'';
+
};
+
+
swayCfg = config.wayland.windowManager.sway;
+
hyprlandCfg = config.wayland.windowManager.hyprland;
+
in {
+
# Let it try to start a few more times
+
systemd.user.services.waybar = {
+
Unit.StartLimitBurst = 30;
+
};
+
programs.waybar = {
+
enable = true;
+
package = pkgs.waybar.overrideAttrs (oa: {
+
mesonFlags = (oa.mesonFlags or []) ++ ["-Dexperimental=true"];
+
});
+
systemd.enable = true;
+
settings = {
+
primary = {
+
exclusive = false;
+
passthrough = false;
+
height = 40;
+
margin = "6";
+
position = "top";
+
modules-left =
+
["custom/menu"]
+
++ (lib.optionals swayCfg.enable [
+
"sway/workspaces"
+
"sway/mode"
+
])
+
++ (lib.optionals hyprlandCfg.enable [
+
"hyprland/workspaces"
+
"hyprland/submap"
+
])
+
++ [
+
"custom/currentplayer"
+
"custom/player"
+
];
+
+
modules-center = [
+
"cpu"
+
"memory"
+
"clock"
+
"pulseaudio"
+
"battery"
+
"custom/unread-mail"
+
];
+
+
modules-right = [
+
# "custom/gammastep" TODO: currently broken for some reason
+
"custom/rfkill"
+
"network"
+
"tray"
+
"custom/hostname"
+
];
+
+
clock = {
+
interval = 1;
+
format = "{:%d/%m %H:%M:%S}";
+
format-alt = "{:%Y-%m-%d %H:%M:%S %z}";
+
on-click-left = "mode";
+
tooltip-format = ''
+
<big>{:%Y %B}</big>
+
<tt><small>{calendar}</small></tt>'';
+
};
+
+
cpu = {
+
format = " {usage}%";
+
};
+
+
memory = {
+
format = " {}%";
+
interval = 5;
+
};
+
+
pulseaudio = {
+
format = "{icon} {volume}%";
+
format-muted = " 0%";
+
format-icons = {
+
headphone = "󰋋 ";
+
headset = "󰋎 ";
+
portable = " ";
+
default = [
+
" "
+
" "
+
" "
+
];
+
};
+
on-click = lib.getExe pkgs.pavucontrol;
+
};
+
+
idle_inhibitor = {
+
format = "{icon}";
+
format-icons = {
+
activated = "󰒳";
+
deactivated = "󰒲";
+
};
+
};
+
+
battery = {
+
interval = 10;
+
format-icons = [
+
"󰁺"
+
"󰁻"
+
"󰁼"
+
"󰁽"
+
"󰁾"
+
"󰁿"
+
"󰂀"
+
"󰂁"
+
"󰂂"
+
"󰁹"
+
];
+
format = "{icon} {capacity}%";
+
format-charging = "󰂄 {capacity}%";
+
onclick = "";
+
};
+
+
"sway/window" = {
+
max-length = 20;
+
};
+
+
network = {
+
interval = 3;
+
format-wifi = " {essid}";
+
format-ethernet = "󰈁 Connected";
+
format-disconnected = "󱐤 ";
+
tooltip-format = ''
+
{ifname}
+
{ipaddr}/{cidr}
+
Up: {bandwidthUpBits}
+
Down: {bandwidthDownBits}'';
+
};
+
+
"custom/menu" = {
+
interval = 1;
+
return-type = "json";
+
exec = mkScriptJson {
+
deps = lib.optional hyprlandCfg.enable hyprlandCfg.package;
+
text = " ";
+
tooltip = ''$(grep PRETTY_NAME /etc/os-release | cut -d '"' -f2)'';
+
class = let
+
isFullScreen =
+
if hyprlandCfg.enable
+
then "hyprctl activewindow -j | jq -e '.fullscreen' &>/dev/null"
+
else "false";
+
in "$(if ${isFullScreen}; then echo fullscreen; fi)";
+
};
+
};
+
+
"custom/hostname" = {
+
exec = mkScript {script = ''echo "$USER@$HOSTNAME"'';};
+
on-click = mkScript {script = "systemctl --user restart waybar";};
+
};
+
+
"custom/unread-mail" = {
+
interval = 5;
+
return-type = "json";
+
exec = mkScriptJson {
+
deps = [pkgs.findutils pkgs.procps];
+
pre = ''
+
count=$(find ~/Mail/*/Inbox/new -type f | wc -l)
+
if pgrep mbsync &>/dev/null; then
+
status="syncing"
+
else
+
if [ "$count" == "0" ]; then
+
status="read"
+
else
+
status="unread"
+
fi
+
fi
+
'';
+
text = "$count";
+
alt = "$status";
+
};
+
format = "{icon} ({})";
+
format-icons = {
+
"read" = "󰇯";
+
"unread" = "󰇮";
+
"syncing" = "󰁪";
+
};
+
};
+
+
"custom/currentplayer" = {
+
interval = 2;
+
return-type = "json";
+
exec = mkScriptJson {
+
deps = [pkgs.playerctl];
+
pre = ''
+
player="$(playerctl status -f "{{playerName}}" 2>/dev/null || echo "No player active" | cut -d '.' -f1)"
+
count="$(playerctl -l 2>/dev/null | wc -l)"
+
if ((count > 1)); then
+
more=" +$((count - 1))"
+
else
+
more=""
+
fi
+
'';
+
alt = "$player";
+
tooltip = "$player ($count available)";
+
text = "$more";
+
};
+
format = "{icon}{}";
+
format-icons = {
+
"No player active" = " ";
+
"Celluloid" = "󰎁 ";
+
"spotify" = "󰓇 ";
+
"ncspot" = "󰓇 ";
+
"qutebrowser" = "󰖟 ";
+
"firefox" = " ";
+
"discord" = " 󰙯 ";
+
"sublimemusic" = " ";
+
"kdeconnect" = "󰄡 ";
+
"chromium" = " ";
+
};
+
};
+
+
"custom/player" = {
+
exec-if = mkScript {
+
deps = [pkgs.playerctl];
+
script = "playerctl status 2>/dev/null";
+
};
+
exec = let
+
format = ''{"text": "{{title}} - {{artist}}", "alt": "{{status}}", "tooltip": "{{title}} - {{artist}} ({{album}})"}'';
+
in
+
mkScript {
+
deps = [pkgs.playerctl];
+
script = "playerctl metadata --format '${format}' 2>/dev/null";
+
};
+
return-type = "json";
+
interval = 2;
+
max-length = 30;
+
format = "{icon} {}";
+
format-icons = {
+
"Playing" = "󰐊";
+
"Paused" = "󰏤 ";
+
"Stopped" = "󰓛";
+
};
+
on-click = mkScript {
+
deps = [pkgs.playerctl];
+
script = "playerctl play-pause";
+
};
+
};
+
};
+
};
+
# Cheatsheet:
+
# x -> all sides
+
# x y -> vertical, horizontal
+
# x y z -> top, horizontal, bottom
+
# w x y z -> top, right, bottom, left
+
style = let
+
inherit (inputs.nix-colors.lib.conversions) hexToRGBString;
+
inherit (config.colorscheme) colors;
+
toRGBA = color: opacity: "rgba(${hexToRGBString "," (lib.removePrefix "#" color)},${opacity})";
+
in
+
/*
+
css
+
*/
+
''
+
* {
+
font-family: Fira Sans, FiraCode Nerd Font;
+
font-size: 12pt;
+
padding: 0;
+
margin: 0 0.4em;
+
}
+
+
window#waybar {
+
padding: 0;
+
border-radius: 0.5em;
+
background-color: shade(@surface0, 0.7);
+
color: @surface2
+
}
+
.modules-left {
+
margin-left: -0.65em;
+
}
+
.modules-right {
+
margin-right: -0.65em;
+
}
+
+
#workspaces button {
+
background-color: @surface0;
+
color: @surface1;
+
padding-left: 0.4em;
+
padding-right: 0.4em;
+
margin-top: 0.15em;
+
margin-bottom: 0.15em;
+
}
+
#workspaces button.hidden {
+
background-color: @surface0;
+
color: @surface2;
+
}
+
#workspaces button.focused,
+
#workspaces button.active {
+
background-color: @blue;
+
color: @green;
+
}
+
+
#clock {
+
padding-right: 1em;
+
padding-left: 1em;
+
border-radius: 0.5em;
+
}
+
+
#custom-menu {
+
background-color: @surface3;
+
color: @blue;
+
padding-right: 1.5em;
+
padding-left: 1em;
+
margin-right: 0;
+
border-radius: 0.5em;
+
}
+
#custom-menu.fullscreen {
+
background-color: @blue;
+
color: @green;
+
}
+
#custom-hostname {
+
background-color: @surface3;
+
color: @blue;
+
padding-right: 1em;
+
padding-left: 1em;
+
margin-left: 0;
+
border-radius: 0.5em;
+
}
+
#custom-currentplayer {
+
padding-right: 0;
+
}
+
#tray {
+
color: @surface1;
+
}
+
#custom-gpu, #cpu, #memory {
+
margin-left: 0.05em;
+
margin-right: 0.55em;
+
}
+
'';
+
};
+
}
+1
moonlark/configuration.nix
···
fonts.packages = with pkgs; [
nerdfonts
+
fira
];
environment.sessionVariables = {