summaryrefslogtreecommitdiff
path: root/hosts/ali/desktop-environment/window-manager.nix
blob: f777e3cd1b631463408c4913de761a726f3565fd (plain)
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
{pkgs, ...}: {
  services.xserver.windowManager.dwm.enable = true;

  # Show battery and clock in status bar. This is a background daemon which
  # updates the root window, which DWM uses for status.
  systemd.user.services.dwm-battery = {
    description = "Battery status update";
    partOf = ["graphical-session.target"];
    wantedBy = ["graphical-session.target"];

    serviceConfig.ExecStart = pkgs.writeShellScript "dwm-battery" ''
      while true; do
        echo -n "$(date +%H:%M) - ";

        # See: https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-power
        case "$(cat /sys/class/power_supply/BAT1/status)" in
          Charging)       echo -n "🔋 " ;;
          Discharging)    echo -n "🪫 " ;;
          "Not charging") echo -n "🪫 " ;;
          Full)           echo -n "🔋 " ;;
          Unknown)        echo -n "? " ;;
          ""|*)           echo -n "?? " ;;
        esac

        echo -n "$(cat /sys/class/power_supply/BAT1/capacity)%"

        echo
        sleep 5
      done | ${pkgs.dwm-setstatus}/bin/dwm-setstatus
    '';
  };

  environment.systemPackages = with pkgs; [
    st
    dmenu
  ];
}