about summary refs log tree commit diff
path: root/home/wm/waybar/default.nix
blob: 717d4c0da18e4faf835292f6f62203b4580394b3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{ config, lib, pkgs, ... }:
let
  isEnabled = config.my.home.wm.windowManager == "sway";
  waybarSystemd =
    pkgs.runCommandLocal "waybar-systemd"
      { nativeBuildInputs = [ pkgs.makeWrapper ]; }
      ''
        makeWrapper ${./waybar-systemd.sh} $out/bin/waybar-systemd
      '';
in
{
  config = lib.mkIf isEnabled {
    programs.waybar = {
      enable = true;
      systemd = { enable = true; };

      settings = [{
        layer = "bottom";
        height = 25;
        position = "top";
        margin-top = 0;
        margin-left = 0;
        margin-right = 0;
        margin-bottom = 0;
        modules-left = [ "sway/workspaces" "sway/mode" ];
        modules-right = [ "custom/systemd" "pulseaudio" "network" "battery" "clock" "tray" ];
        "sway/workspaces" = { format = "{name}"; };
        "sway/mode" = { format = "{}"; };
        tray = { spacing = 10; };
        clock = { format = "{: %a %b %d %R}"; };
        battery = {
          states = {
            warning = 30;
            critical = 15;
          };
          format = "ac:{capacity}%";
          tooltip = true;
          tooltip-format = "{timeTo} ({capacity}%)";
        };
        "custom/systemd" = {
          exec = "${waybarSystemd}/bin/waybar-systemd";
          return-type = "json";
          interval = 10;
        };
        pulseaudio = {
          format = "vol:{volume}%";
          format-bluetooth = "bt:{volume}%";
          format-bluetooth-muted = "bt:{volume}%";
          format-muted = "vol:{volume}%";
          on-click = "pavucontrol";
        };
        "network" = {
          format-wifi = "{essid}:{signalStrength}%";
          format-ethernet = "{ipaddr}/{cidr}";
          format-linked = "{ifname} (No IP)";
          format-disconnected = "network unavailable";
          format-alt = "{ifname}: {ipaddr}/{cidr}";
          tooltip = false;
        };
      }];
      style = (builtins.readFile ./style.css);
    };
  };
}