From 77fcc72b483f02aa8db03ab9470fecf6feac6072 Mon Sep 17 00:00:00 2001
From: marduk <mike@luxvera.com>
Date: Sun, 21 Jul 2024 12:16:35 -0400
Subject: [PATCH] add anyrun replaced rofi with anyrun in hyprland TODO: make
 colors dynamic

---
 flake.lock                              | 81 +++++++++++++++++++++----
 flake.nix                               |  6 ++
 modules/home/utility/anyrun/default.nix | 41 +++++++++++++
 modules/home/utility/anyrun/theme.css   | 62 +++++++++++++++++++
 modules/home/wms/hyprland/binds.nix     |  6 +-
 modules/home/wms/hyprland/default.nix   |  1 -
 6 files changed, 183 insertions(+), 14 deletions(-)
 create mode 100644 modules/home/utility/anyrun/default.nix
 create mode 100644 modules/home/utility/anyrun/theme.css

diff --git a/flake.lock b/flake.lock
index e9fd70e..f4fb8ad 100644
--- a/flake.lock
+++ b/flake.lock
@@ -1,5 +1,27 @@
 {
   "nodes": {
+    "anyrun": {
+      "inputs": {
+        "flake-parts": "flake-parts",
+        "nixpkgs": [
+          "nixpkgs"
+        ],
+        "systems": "systems"
+      },
+      "locked": {
+        "lastModified": 1721135360,
+        "narHash": "sha256-ZhSA0e45UxiOAjEVqkym/aULh0Dt+KHJLNda7bjx9UI=",
+        "owner": "anyrun-org",
+        "repo": "anyrun",
+        "rev": "c6101a31a80b51e32e96f6a77616b609770172e0",
+        "type": "github"
+      },
+      "original": {
+        "owner": "anyrun-org",
+        "repo": "anyrun",
+        "type": "github"
+      }
+    },
     "base16-schemes": {
       "flake": false,
       "locked": {
@@ -85,6 +107,27 @@
       }
     },
     "flake-parts": {
+      "inputs": {
+        "nixpkgs-lib": [
+          "anyrun",
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1717285511,
+        "narHash": "sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw=",
+        "owner": "hercules-ci",
+        "repo": "flake-parts",
+        "rev": "2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8",
+        "type": "github"
+      },
+      "original": {
+        "owner": "hercules-ci",
+        "repo": "flake-parts",
+        "type": "github"
+      }
+    },
+    "flake-parts_2": {
       "inputs": {
         "nixpkgs-lib": [
           "nixvim",
@@ -107,7 +150,7 @@
     },
     "flake-utils": {
       "inputs": {
-        "systems": "systems_2"
+        "systems": "systems_3"
       },
       "locked": {
         "lastModified": 1701680307,
@@ -144,7 +187,7 @@
     },
     "flake-utils_2": {
       "inputs": {
-        "systems": "systems_3"
+        "systems": "systems_4"
       },
       "locked": {
         "lastModified": 1694529238,
@@ -162,7 +205,7 @@
     },
     "flake-utils_3": {
       "inputs": {
-        "systems": "systems_4"
+        "systems": "systems_5"
       },
       "locked": {
         "lastModified": 1694529238,
@@ -180,7 +223,7 @@
     },
     "flake-utils_4": {
       "inputs": {
-        "systems": "systems_5"
+        "systems": "systems_6"
       },
       "locked": {
         "lastModified": 1685518550,
@@ -340,7 +383,7 @@
         "hyprutils": "hyprutils",
         "hyprwayland-scanner": "hyprwayland-scanner",
         "nixpkgs": "nixpkgs",
-        "systems": "systems",
+        "systems": "systems_2",
         "xdph": "xdph"
       },
       "locked": {
@@ -688,7 +731,7 @@
       "inputs": {
         "devshell": "devshell",
         "flake-compat": "flake-compat",
-        "flake-parts": "flake-parts",
+        "flake-parts": "flake-parts_2",
         "git-hooks": "git-hooks",
         "home-manager": "home-manager_2",
         "nix-darwin": "nix-darwin",
@@ -730,6 +773,7 @@
     },
     "root": {
       "inputs": {
+        "anyrun": "anyrun",
         "hardware": "hardware",
         "home-manager": "home-manager",
         "hyprland": "hyprland",
@@ -824,6 +868,21 @@
       }
     },
     "systems_2": {
+      "locked": {
+        "lastModified": 1689347949,
+        "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
+        "owner": "nix-systems",
+        "repo": "default-linux",
+        "rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-systems",
+        "repo": "default-linux",
+        "type": "github"
+      }
+    },
+    "systems_3": {
       "locked": {
         "lastModified": 1681028828,
         "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
@@ -838,7 +897,7 @@
         "type": "github"
       }
     },
-    "systems_3": {
+    "systems_4": {
       "locked": {
         "lastModified": 1681028828,
         "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
@@ -853,7 +912,7 @@
         "type": "github"
       }
     },
-    "systems_4": {
+    "systems_5": {
       "locked": {
         "lastModified": 1681028828,
         "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
@@ -868,7 +927,7 @@
         "type": "github"
       }
     },
-    "systems_5": {
+    "systems_6": {
       "locked": {
         "lastModified": 1681028828,
         "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
@@ -883,7 +942,7 @@
         "type": "github"
       }
     },
-    "systems_6": {
+    "systems_7": {
       "locked": {
         "lastModified": 1681028828,
         "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
@@ -921,7 +980,7 @@
     },
     "utils": {
       "inputs": {
-        "systems": "systems_6"
+        "systems": "systems_7"
       },
       "locked": {
         "lastModified": 1710146030,
diff --git a/flake.nix b/flake.nix
index 39bd90d..4d4c407 100644
--- a/flake.nix
+++ b/flake.nix
@@ -38,6 +38,11 @@
       inputs.nixpkgs.follows = "nixpkgs";
     };
 
+    anyrun = {
+      url = "github:anyrun-org/anyrun";
+      inputs.nixpkgs.follows = "nixpkgs";
+    };
+
     hardware.url = "github:nixos/nixos-hardware";
     razer-laptop-control.url = "github:Razer-Linux/razer-laptop-control-no-dkms";
 
@@ -72,6 +77,7 @@
         nixvim.homeManagerModules.nixvim
         spicetify-nix.homeManagerModules.default
         nix-colors.homeManagerModules.default
+        anyrun.homeManagerModules.default
       ];
 
       systems.modules.nixos = with inputs; [ home-manager.nixosModules.home-manager ];
diff --git a/modules/home/utility/anyrun/default.nix b/modules/home/utility/anyrun/default.nix
new file mode 100644
index 0000000..1bd0ce5
--- /dev/null
+++ b/modules/home/utility/anyrun/default.nix
@@ -0,0 +1,41 @@
+{
+  pkgs,
+  lib,
+  config,
+  namespace,
+  inputs,
+  ...
+}:
+let
+  inherit (lib) mkEnableOption mkIf;
+
+  cfg = config.${namespace}.utility.anyrun;
+in
+{
+  options.${namespace}.utility.anyrun = {
+    enable = mkEnableOption "anyrun.";
+  };
+
+  config = mkIf cfg.enable {
+    programs.anyrun = {
+      enable = true;
+      config = {
+        plugins = with inputs.anyrun.packages.${pkgs.system}; [
+          applications
+          # kidex
+          rink
+          symbols
+          shell
+          # dictionary
+          # randr
+        ];
+        width.fraction = 0.2;
+        # x.fraction = 0.1;
+        y.fraction = 0.2;
+        hidePluginInfo = true;
+        closeOnClick = true;
+      };
+      extraCss = builtins.readFile ./theme.css; # TODO: don't use static colors
+    };
+  };
+}
diff --git a/modules/home/utility/anyrun/theme.css b/modules/home/utility/anyrun/theme.css
new file mode 100644
index 0000000..4088ae8
--- /dev/null
+++ b/modules/home/utility/anyrun/theme.css
@@ -0,0 +1,62 @@
+* {
+  all: unset;
+  font-size: 1.2rem;
+}
+
+#window,
+#match,
+#entry,
+#plugins,
+#main {
+  background: transparent;
+}
+
+#match.activatable {
+  border-radius: 8px;
+  margin: 4px 0;
+  padding: 4px;
+  transition: 50ms ease-out;
+}
+#match.activatable:first-child {
+  margin-top: 12px;
+}
+#match.activatable:last-child {
+  margin-bottom: 0;
+}
+
+#match:hover {
+  background: rgba(255, 255, 255, 0.05);
+}
+#match:selected:nth-child(3n+1) {
+  background: rgba(255, 255, 255, 0.1);
+  border-radius: 8px;
+  border: 3px solid #F6C177;
+}
+#match:selected:nth-child(3n+2) {
+  background: rgba(255, 255, 255, 0.1);
+  border-radius: 8px;
+  border: 3px solid #9CCFD8;
+}
+#match:selected:nth-child(3n) {
+  background: rgba(255, 255, 255, 0.1);
+  border-radius: 8px;
+  border: 3px solid #C4A7E7;
+}
+
+#entry {
+  background: rgba(255, 255, 255, 0.05);
+  border: 1px solid rgba(255, 255, 255, 0.1);
+  border-radius: 8px;
+  padding: 4px 8px;
+}
+
+box#main {
+  background: #191724;
+  box-shadow:
+    inset 0 0 0 1px rgba(255, 255, 255, 0.1),
+    0 5px 5px 5px rgba(0, 0, 0, 0.5);
+  border: 3px solid #EB6F92;
+  border-radius: 20px;
+  padding: 12px;
+}
+
diff --git a/modules/home/wms/hyprland/binds.nix b/modules/home/wms/hyprland/binds.nix
index 238364c..b6b1dcd 100644
--- a/modules/home/wms/hyprland/binds.nix
+++ b/modules/home/wms/hyprland/binds.nix
@@ -8,11 +8,14 @@
 }:
 let
   inherit (lib) mkIf;
+  inherit (lib.${namespace}) enabled;
 
   cfg = config.${namespace}.wms.hyprland;
 in
 {
   config = mkIf cfg.enable {
+    dotties.utility.anyrun = enabled;
+
     wayland.windowManager.hyprland = {
       settings = {
         "$mod" = "SUPER";
@@ -58,8 +61,7 @@ in
             "$mod CONTROL_SHIFT, S, exec, grimblast --notify edit screen"
 
             # rofi
-            "$mod, D, exec, pkill rofi || ${pkgs.rofi-wayland}/bin/rofi -show drun"
-            "$mod, Period, exec, pkill rofi || ${pkgs.bemoji}/bin/bemoji"
+            "$mod, D, exec, ${pkgs.anyrun}/bin/anyrun"
 
             # client controls
             "$mod, M, fullscreen, 1"
diff --git a/modules/home/wms/hyprland/default.nix b/modules/home/wms/hyprland/default.nix
index 836e1f1..2b93e96 100644
--- a/modules/home/wms/hyprland/default.nix
+++ b/modules/home/wms/hyprland/default.nix
@@ -34,7 +34,6 @@ in
   imports = lib.snowfall.fs.get-non-default-nix-files ./.;
 
   config = mkIf cfg.enable {
-    dotties.apps.rofi = enabled;
     dotties.utility.mako = enabled;
     dotties.utility.waybar = enabled;
     dotties.services.swww = {