Add waybar

As eww was taking too long, we added a waybar configuration as a stopgap

Most of our inspiration was taken from
https://github.com/Andrey0189/hyprland-rice/tree/main/config/waybar,
with Nix integration from
https://github.com/Minion3665/NixFiles/blob/a124e5f0ac92ec39b22c469d6d85efbac018c28d/modules/waybar.nix

We have loosely rethemed this around the lack of several modules in the
title bar, as well as the need to make both a light and a dark theme,
but we still consider these close enough to the Andrey0189/hyprland-rice
code that we have licensed these files under MIT

We have defaulted this to be enabled when you enable hyprland, but this
may change in the future. To keep it when it does, please explicitly
enable it in your home configuration.

Change-Id: I64ffd1d2c9ebd008760a794f0bb7d1e81d4d3f32
Reviewed-on: https://git.clicks.codes/c/Chimera/NixFiles/+/569
Reviewed-by: Skyler Grey <minion@clicks.codes>
Tested-by: Samuel Shuert <coded@clicks.codes>
diff --git a/homes/x86_64-linux/coded@shorthair/default.nix b/homes/x86_64-linux/coded@shorthair/default.nix
index 827a60d..ed001a1 100644
--- a/homes/x86_64-linux/coded@shorthair/default.nix
+++ b/homes/x86_64-linux/coded@shorthair/default.nix
@@ -20,6 +20,9 @@
 }:
 {
   chimera = {
+    waybar.modules.temperature.hwmonPath = "/sys/class/hwmon/hwmon4/temp1_input";
+    waybar.modules.backlight.enable = true;
+
     shell = {
       zsh.enable = true;
 
@@ -72,7 +75,7 @@
           deArrow.enable = true;
         };
         reactDevTools.enable = true;
-        ublockOrigin.enable = true;
+        adnauseam.enable = true;
       };
       search = {
         enable = true;
diff --git a/homes/x86_64-linux/minion@greylag/default.nix b/homes/x86_64-linux/minion@greylag/default.nix
index 20928c5..e5d31f6 100644
--- a/homes/x86_64-linux/minion@greylag/default.nix
+++ b/homes/x86_64-linux/minion@greylag/default.nix
@@ -58,6 +58,11 @@
   };
 
   chimera = {
+    waybar = {
+      modules.temperature.hwmonPath = "/sys/class/hwmon/hwmon4/temp1_input";
+      modules.laptop.enable = true;
+    };
+
     hyprland.enable = true;
     hyprland.hyprpaper.splash.enable = true;
 
diff --git a/modules/home/hyprland/default.nix b/modules/home/hyprland/default.nix
index a511ddf..f313651 100644
--- a/modules/home/hyprland/default.nix
+++ b/modules/home/hyprland/default.nix
@@ -43,6 +43,8 @@
   };
 
   config = lib.mkIf config.chimera.hyprland.enable {
+    chimera.waybar.enable = lib.mkDefault true;
+
     programs.bash.profileExtra = lib.mkIf config.chimera.shell.bash.enable (lib.mkBefore ''
       if [ -z $WAYLAND_DISPLAY ] && [ "$(tty)" = "/dev/tty1" ]; then
         exec ${pkgs.systemd}/bin/systemd-cat -t hyprland ${pkgs.dbus}/bin/dbus-run-session ${config.wayland.windowManager.hyprland.package}/bin/Hyprland
@@ -93,6 +95,7 @@
           exec-once = [
             "${pkgs.hyprpaper}/bin/hyprpaper"
             "hyprctl setcursor ${config.chimera.theme.cursor.name} ${builtins.toString config.chimera.theme.cursor.size}"
+            "${pkgs.waybar}/bin/waybar"
           ];
 
           monitor = config.chimera.hyprland.monitors ++ [ ",preferred,auto,1" ];
diff --git a/modules/home/waybar/default.nix b/modules/home/waybar/default.nix
new file mode 100644
index 0000000..9f3194c
--- /dev/null
+++ b/modules/home/waybar/default.nix
@@ -0,0 +1,176 @@
+/*
+This file is modified from https://github.com/Andrey0189/hyprland-rice/blob/main/config/waybar/config
+As such you can access it under the following license terms:
+
+MIT License
+
+Copyright (c) 2024 Andrew
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+{ config, lib, pkgs, ... }: {
+  options.chimera.waybar = {
+    enable = lib.mkEnableOption "Enable Waybar";
+    modules = {
+      laptop.enable = lib.mkEnableOption "Enable all laptop modules by default";
+      backlight = {
+        enable = lib.mkOption {
+          type = lib.types.bool;
+          default = config.chimera.waybar.modules.laptop.enable;
+          description = "Enable reading and modifying backlight using light";
+        };
+      };
+      battery = {
+        states = {
+          full = lib.mkOption {
+            type = lib.types.int;
+            default = 98;
+            description = "The power above which your battery will be considered full";
+          };
+          warning = lib.mkOption {
+            type = lib.types.int;
+            default = 30;
+            description = "The power below which your battery will be considered at 'low' levels";
+          };
+          critical = lib.mkOption {
+            type = lib.types.int;
+            default = 15;
+            description = "The power below which your battery will be considered critically low";
+          };
+        };
+        enable = lib.mkOption {
+          type = lib.types.bool;
+          default = config.chimera.waybar.modules.laptop.enable;
+          description = "Enable battery module";
+        };
+      };
+      temperature = {
+        enable = lib.mkOption {
+          type = lib.types.bool;
+          default = config.chimera.waybar.modules.temperature.hwmonPath != null;
+          description = "Enable temperature module";
+        };
+        hwmonPath = lib.mkOption {
+          type = lib.types.nullOr lib.types.str;
+          description = "System CPU hardware temperature path";
+          example = "/sys/class/hwmon/hwmon1/temp1_input";
+          default = null;
+        };
+      };
+    };
+  };
+
+  config = {
+    programs.waybar = lib.mkIf config.chimera.waybar.enable {
+      enable = true;
+      settings = [
+        {
+          layer = "top";
+          position = "top";
+          margin = "9 13 -10 18";
+          modules-left = [ "hyprland/workspaces" "keyboard-state" ];
+          modules-center = ["clock"];
+          modules-right = ["pulseaudio" "custom/mem" "cpu"]
+            ++ (if config.chimera.waybar.modules.temperature.enable then [ "temperature" ] else [])
+            ++ (if config.chimera.waybar.modules.battery.enable then [ "backlight" ] else [])
+            ++ (if config.chimera.waybar.modules.battery.enable then [ "battery" ] else [])
+            ++ [ "tray" ];
+
+          "hyprland/workspaces" = {
+            "disable-scroll" = true;
+          };
+          clock = {
+            "tooltip-format" = "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>";
+            "format" = "{:%a, %d %b, %I:%M %p}";
+          };
+          pulseaudio = {
+            "scroll-step" = 1;
+            "reverse-scrolling" = 1;
+            "format" = "{volume}% {icon} {format_source}";
+            "format-bluetooth" = "{volume}% {icon} {format_source}";
+            "format-bluetooth-muted" = " {icon} {format_source}";
+            "format-muted" = " {format_source}";
+            "format-source" = "{volume}% ";
+            "format-source-muted" = "";
+            "format-icons" = {
+                "headphone" = "";
+                "hands-free" = "";
+                "headset" = "";
+                "phone" = "";
+                "portable" = "";
+                "car" = "";
+                "default" = ["" "" ""];
+            };
+            "on-click" = "${pkgs.pavucontrol}/bin/pavucontrol";
+            "min-length" = 13;
+          };
+          "custom/mem" = {
+            "format" = "{} ɤ";
+            "interval" = 5;
+            "exec" = "free -h | awk '/Mem:/{printf $3}'";
+            "tooltip" = false;
+          };
+          cpu = {
+            "interval" = 2;
+            "format" = "{usage}% ";
+            "min-length" = 6;
+          };
+          temperature = {
+            "thermal-zone" = 2;
+            "hwmon-path" = config.chimera.waybar.modules.temperature.hwmonPath;
+            "critical-threshold" = 80;
+            "format-critical" = "{temperatureC}°C {icon}";
+            "format" = "{temperatureC}°C {icon}";
+            "format-icons" = ["" "" "" "" ""];
+            "tooltip" = false;
+            "interval" = 2;
+          };
+          backlight = lib.mkIf config.chimera.waybar.modules.backlight.enable {
+            "format" = "{percent}% {icon}";
+            "format-icons" = [""];
+            "min-length" = 7;
+          };
+          battery = lib.mkIf config.chimera.waybar.modules.battery.enable {
+            "states" = config.chimera.waybar.modules.battery.states;
+            "format" = "{capacity}% {icon}";
+            "format-charging" = "{capacity}% ";
+            "format-plugged" = "{capacity}% ";
+            "format-alt" = "{time} {icon}";
+            "format-icons" = ["" "" "" "" "" "" "" "" "" ""];
+            "on-update" = "$HOME/.config/waybar/scripts/check_battery.sh";
+          };
+          tray = {
+            "icon-size" = 16;
+            "spacing" = 0;
+          };
+        }
+      ];
+      style = ''
+        @define-color background #${config.chimera.theme.colors.Crust.hex};
+        @define-color active #${config.chimera.theme.colors.Accent.hex};
+        @define-color hover #${config.chimera.theme.colors.Surface2.hex};
+        @define-color text #${config.chimera.theme.colors.Text.hex};
+        @define-color altText #${config.chimera.theme.colors.Base.hex};
+        @define-color critical #${config.chimera.theme.colors.Red.hex};
+        @define-color warning #${config.chimera.theme.colors.Yellow.hex};
+        @define-color charging #${config.chimera.theme.colors.Green.hex};
+      '' + builtins.readFile ./main.css;
+    };
+  };
+}
\ No newline at end of file
diff --git a/modules/home/waybar/main.css b/modules/home/waybar/main.css
new file mode 100644
index 0000000..06048e4
--- /dev/null
+++ b/modules/home/waybar/main.css
@@ -0,0 +1,203 @@
+/*
+This file is modified from https://github.com/Andrey0189/hyprland-rice/blob/main/config/waybar/style.css
+As such you can access it under the following license terms:
+
+MIT License
+
+Copyright (c) 2024 Andrew
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+*/
+
+* {
+    border: none;
+    border-radius: 0;
+    /* `otf-font-awesome` is required to be installed for icons */
+    font-family: FontAwesome, JetBrains Mono Bold, sans-serif;
+    min-height: 20px;
+}
+
+window#waybar {
+    background: transparent;
+}
+
+window#waybar.hidden {
+    opacity: 0.2;
+}
+
+#workspaces {
+    margin-right: 8px;
+    border-radius: 10px;
+    transition: none;
+    background: @background;
+}
+
+#workspaces button {
+    transition: none;
+    color: @text;
+    background: transparent;
+    padding: 5px;
+    font-size: 18px;
+}
+
+#workspaces button.persistent {
+    color: @active;
+    font-size: 12px;
+}
+
+/* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */
+#workspaces button:hover {
+    transition: none;
+    box-shadow: inherit;
+    text-shadow: inherit;
+    border-radius: inherit;
+    color: @text;
+    background: @hover;
+}
+
+#workspaces button.active {
+    background: @active;
+    color: @altText;
+    border-radius: inherit;
+}
+
+#submap {
+    padding-left: 16px;
+    padding-right: 16px;
+    border-radius: 10px;
+    transition: none;
+    color: @text;
+    background: @background;
+}
+
+#clock {
+    padding-left: 16px;
+    padding-right: 16px;
+    border-radius: 10px 10px 10px 10px;
+    transition: none;
+    color: @text;
+    background: @background;
+}
+
+#pulseaudio {
+    margin-right: 8px;
+    padding-left: 16px;
+    padding-right: 16px;
+    border-radius: 10px;
+    transition: none;
+    color: @text;
+    background: @background;
+}
+
+#pulseaudio.muted {
+    background-color: @background;
+    color: @critical;
+}
+
+#custom-mem {
+    margin-right: 8px;
+    padding-left: 16px;
+    padding-right: 16px;
+    border-radius: 10px;
+    transition: none;
+    color: @text;
+    background: @background;
+}
+
+#cpu {
+    margin-right: 8px;
+    padding-left: 16px;
+    padding-right: 16px;
+    border-radius: 10px;
+    transition: none;
+    color: @text;
+    background: @background;
+}
+
+#temperature {
+    margin-right: 8px;
+    padding-left: 16px;
+    padding-right: 16px;
+    border-radius: 10px;
+    transition: none;
+    color: @text;
+    background: @background;
+}
+
+#temperature.critical {
+    background-color: @critical;
+    color: @altText
+}
+
+#backlight {
+    margin-right: 8px;
+    padding-left: 16px;
+    padding-right: 16px;
+    border-radius: 10px;
+    transition: none;
+    color: @text;
+    background: @background;
+}
+
+#battery {
+    margin-right: 8px;
+    padding-left: 16px;
+    padding-right: 16px;
+    border-radius: 10px;
+    transition: none;
+    color: @text;
+    background: @background;
+}
+
+#battery.charging {
+    color: @altText;
+    background-color: @charging;
+}
+
+#battery.warning:not(.charging) {
+    background-color: @warning;
+    color: @altText;
+}
+
+#battery.critical:not(.charging) {
+    background-color: @critical;
+    color: @altText;
+    animation-name: blink;
+    animation-duration: 0.5s;
+    animation-timing-function: linear;
+    animation-iteration-count: infinite;
+    animation-direction: alternate;
+}
+
+#tray {
+    padding-left: 16px;
+    padding-right: 16px;
+    border-radius: 10px;
+    margin-right: 10px;
+    transition: none;
+    color: @text;
+    background: @background;
+}
+
+@keyframes blink {
+    to {
+        background-color: @text;
+        color: #000000;
+    }
+}
\ No newline at end of file
diff --git a/modules/nixos/users/default.nix b/modules/nixos/users/default.nix
index 1e2c63a..564596d 100644
--- a/modules/nixos/users/default.nix
+++ b/modules/nixos/users/default.nix
@@ -18,7 +18,10 @@
 
   users.users.coded = {
     isNormalUser = true;
-    extraGroups = [ "wheel" ];
+    extraGroups = [
+      "wheel"
+      "input"
+    ];
     openssh.authorizedKeys.keys = [
       "sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAILrwKN4dJQ0BiLmjsA/66QHhu06+JyokWtHkLcjhWU79AAAABHNzaDo= coded-yk5c-resident"
     ];