nix-system/bar.nix
2024-08-25 15:54:13 +02:00

293 lines
8.7 KiB
Nix

{ lib, config, pkgs, variant, username, ... }: {
home.packages = with pkgs; [
material-design-icons
jost
ncdu
playerctl
];
systemd.user.services.loopback = {
Unit = {
Description = "Simple audio loopback";
};
Install = {
WantedBy = [ ];
};
Service = {
ExecStart = "${pkgs.writeShellScript "start loopback" ''
${pkgs.pipewire}/bin/pw-loopback
''}";
};
};
programs.waybar = {
enable = true;
# systemd.enable = true;
settings = {
bar = {
"reload_style_on_change" = true;
layer = "top";
position = "bottom";
exclusive = true;
# height = 0;
"on-scroll-up" = "hyprctl dispatch workspace e+1";
"on-scroll-down" = "hyprctl dispatch workspace e-1";
"modules-left" = [
"group/controls"
"hyprland/submap"
];
"modules-center" = [ "hyprland/window" ];
"modules-right" = [
"network"
"custom/nvidia-load"
"custom/nvidia-mem"
"group/disks"
"group/hardware"
"tray"
"clock"
];
"group/controls" = {
orientation = "inherit";
modules = [
"hyprland/workspaces"
"pulseaudio#speaker"
"pulseaudio#microphone"
"custom/loopback"
"idle_inhibitor"
"bluetooth"
"backlight"
"mpris"
];
};
"group/hardware" = {
orientation = "inherit";
modules = [ "cpu" "temperature" "memory" "battery" ];
};
"group/disks" = {
orientation = "inherit";
modules = [ "disk" "disk#2" "disk#3" ];
};
backlight = {
device = "intel_backlight";
format = "{icon}";
"on-click" = "${pkgs.light}/bin/light -S 100";
"on-click-right" = "${pkgs.light}/bin/light -S 1";
"tooltip-format" = "{percent}%";
"format-icons" = [ "󰛩" "󱩎" "󱩏" "󱩐" "󱩑" "󱩒" "󱩓" "󱩔" "󱩕" "󱩖" "󰛨" ];
};
idle_inhibitor = {
format = "{icon}";
"format-icons" = {
activated = "󰈈";
deactivated = "󰈉";
};
};
bluetooth = {
format = "󰂯";
"format-disabled" = "󰂲";
"on-click" = "${pkgs.util-linux}/bin/rfkill toggle bluetooth";
"on-click-right" = "$TERMINAL --class floating -e bluetuith";
"tooltip-format" = "{}";
};
mpris = {
format = "{player_icon} {title}";
"format-paused" = "{status_icon} <i>{title}</i>";
"player-icons" = {
default = "󰐊";
mpv = "󰐍";
spotify = "󰓇";
};
"status-icons" = {
paused = "󰏤";
};
};
disk = {
interval = 1;
format = "󰋊 {free}";
path = "/";
"on-click" = "$TERMINAL --class floating -e ${pkgs.ncdu}/bin/ncdu -x /";
};
"disk#2" = lib.attrsets.optionalAttrs (variant == "default") {
interval = 1;
format = "󰋊 {free}";
path = "/home/ant/disk1";
"on-click" = "$TERMINAL --class floating -e ${pkgs.ncdu}/bin/ncdu -x /home/${username}/disk1";
};
"disk#3" = lib.attrsets.optionalAttrs (variant == "default") {
interval = 1;
format = "󰋊 {free}";
path = "/home/ant/disk2";
"on-click" = "$TERMINAL --class floating -e ${pkgs.ncdu}/bin/ncdu -x /home/${username}/disk2";
};
memory = {
interval = 1;
format = "󰧑 {percentage:2}%";
"tooltip-format" = "{used:0.1f}G/{total:0.1f}G";
states = { low = 70; };
"on-click" = "notify-send \"$(printf \"%-20s %10s\\n\" \"COMMAND\" \"MEMORY USAGE\"; ps axo comm,rss | awk '{mem[$1]+=$2} END {for (cmd in mem) printf \"%-20s %5.2f MiB\\n\", cmd, mem[cmd]/1024}' | sort -k2nr | head -n10)\"";
};
network = {
interval = 1;
format = "󰌙";
"format-disconnected" = "󰌙";
"format-linked" = "󰛵";
"format-ethernet" = "󰓢 {bandwidthDownBytes:>} {bandwidthUpBytes:>}";
"format-wifi" = "󰖩 {bandwidthDownBytes:>} {bandwidthUpBytes:>}";
"on-click" = "wifi-toggle";
"on-right-click" = "$TERMINAL --class floating -e nmtui";
"tooltip-format-ethernet" = "{ipaddr}";
"tooltip-format-wifi" = "{ipaddr}\n{essid}\n{signalStrength}";
};
"hyprland/window" = {
format = "{}";
"on-scroll-up" = "hyprctl dispatch workspace e+1";
"on-scroll-down" = "hyprctl dispatch workspace e-1";
};
"hyprland/workspaces" = {
"on-scroll-up" = "hyprctl dispatch workspace e+1";
"on-scroll-down" = "hyprctl dispatch workspace e-1";
"all-outputs" = true;
"on-click" = "activate";
format = "{icon}";
"format-icons" = {
"1" = "0";
"2" = "1";
"3" = "2";
"4" = "3";
"5" = "4";
"6" = "5";
"7" = "6";
"8" = "7";
"9" = "8";
"10" = "9";
};
};
cpu = {
interval = 1;
format = "󰘚 {usage:2}%";
"max-length" = 10;
"on-click" = "$TERMINAL --class floating -e htop";
};
temperature = {
hwmon-path = "/sys/class/hwmon/hwmon1/temp1_input";
};
battery = {
interval = 30;
states = {
warning = 30;
critical = 15;
};
"format-charging" = "󰂅 {capacity:2}%";
format = "{icon} {capacity:2}%";
"format-icons" = [ "󰂎" "󰁺" "󰁻" "󰁼" "󰁽" "󰁾" "󰁿" "󰂀" "󰂁" "󰂂" "󰁹" ];
tooltip = true;
};
"custom/weather" = {
tooltip = true;
format = "{}";
"restart-interval" = 300;
exec = "~/.config/waybar/scripts/waybar-wttr.py";
"return-type" = "json";
};
tray = {
"icon-size" = 17;
# tooltip = false;
# spacing = 10;
};
clock = {
"min-length" = 10;
interval = 1;
format = "{:%d/%m %H:%M:%S}";
timezones = [ "Europe/Paris" ];
"tooltip-format" = "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>";
actions = {
"on-scroll-up" = "tz_up";
"on-scroll-down" = "tz_down";
};
};
"pulseaudio#speaker" = {
format = "{icon} {volume}%";
tooltip = false;
"format-muted" = "󰖁";
"on-click" = "pamixer -t";
# "on-click-right" = "pamixer -t";
"on-scroll-up" = "pamixer -i 5";
"on-scroll-down" = "pamixer -d 5";
"scroll-step" = 5;
"format-icons" = {
headphone = "󰋋";
"hands-free" = "󰋋";
headset = "󰋋";
phone = "󰏲";
portable = "󰏲";
car = "󰄋";
default = [ "󰕿" "󰖀" "󰕾" ];
};
};
"pulseaudio#microphone" = {
format = "{format_source}";
tooltip = false;
"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;
};
"custom/loopback" = lib.attrsets.optionalAttrs (variant == "default") {
exec = "if systemctl --user is-active --quiet loopback; then echo oui; else echo non; fi";
on-click = "if systemctl --user is-active --quiet loopback; then systemctl --user stop loopback; else systemctl --user start loopback; fi";
format = "TEST {}";
};
"hyprland/submap" = {
format = "(l)ock, (e)xit, (s)uspend, (h)ibernate, (r)eboot, (S)hutdown";
};
"custom/nvidia-load" = {
exec = ".config/waybar/scripts/nvidia-load.py";
interval = 5;
"return-type" = "json";
format = "{}";
tooltip = "{tooltip}";
"on-click" = "$TERMINAL --class floating -e nvtop";
};
"custom/nvidia-mem" = {
exec = ".config/waybar/scripts/nvidia-mem.py";
interval = 5;
"return-type" = "json";
format = "{}";
tooltip = "{tooltip}";
"on-click" = "$TERMINAL --class floating -e nvtop";
};
};
};
style = ./waybar.css;
};
}