From 4635e538dd22c82d6051252bf4a533828cbebad3 Mon Sep 17 00:00:00 2001
From: Matei Adriel <rafaeladriel11@gmail.com>
Date: Wed, 11 May 2022 20:08:21 +0300
Subject: [PATCH] feat: nice looking rofi

---
 dotfiles/kmonad/keymap.kbd            |  3 ++-
 modules/applications/default.nix      |  2 +-
 modules/applications/rofi.nix         | 17 -----------------
 modules/applications/rofi/default.nix | 23 +++++++++++++++++++++++
 modules/applications/rofi/pre.rasi    |  5 +++++
 modules/applications/xmonad/Main.hs   |  3 ++-
 modules/themes/catppuccin/default.nix |  8 ++++----
 modules/themes/catppuccin/rofi.rasi   | 12 ++++++++++++
 modules/themes/themes.nix             |  6 +++---
 9 files changed, 52 insertions(+), 27 deletions(-)
 delete mode 100644 modules/applications/rofi.nix
 create mode 100644 modules/applications/rofi/default.nix
 create mode 100644 modules/applications/rofi/pre.rasi
 create mode 100644 modules/themes/catppuccin/rofi.rasi

diff --git a/dotfiles/kmonad/keymap.kbd b/dotfiles/kmonad/keymap.kbd
index 20e383e..8188bda 100644
--- a/dotfiles/kmonad/keymap.kbd
+++ b/dotfiles/kmonad/keymap.kbd
@@ -77,6 +77,7 @@
   mov  (layer-toggle movement)
   mathExtra (layer-toggle math-extra)
   sft (tap-macro lsft (layer-toggle shiftedQwerty)) ;; make this work differently based on the next key pressed
+  j (tap-macro 7 lsft)
 )
 
 ;; more "special" stuff
@@ -97,7 +98,7 @@
 
 (deflayer qwerty
   esc  f1   f2   f3   f4   f5   f6   f7   f8   f9   f10  f11  f12  del
-  grv  1    2    3    4    5    6    7    8    9    0    -    =    bspc
+  grv  1    2    3    4    5    6    @j   8    9    0    -    =    bspc
   tab  q    w    e    r    t    y    u    i    o    p    [    ]    \
   @mth a    s    d    f    g    h    j    k    l    ;    '    ret
   @sft z    x    c    v    b    n    m    ,    .    /    rsft
diff --git a/modules/applications/default.nix b/modules/applications/default.nix
index 4f20e20..aa5af52 100644
--- a/modules/applications/default.nix
+++ b/modules/applications/default.nix
@@ -4,6 +4,7 @@
     ./shells
     # ./wakatime
     ./xmonad
+    ./rofi
     # ./xmodmap
 
     # ./wine.nix
@@ -14,7 +15,6 @@
     ./locale.nix
     # ./memes.nix
     ./alacritty.nix
-    ./rofi.nix
     ./postgres.nix
     ./neovim.nix
     ./tmux.nix
diff --git a/modules/applications/rofi.nix b/modules/applications/rofi.nix
deleted file mode 100644
index 21760c7..0000000
--- a/modules/applications/rofi.nix
+++ /dev/null
@@ -1,17 +0,0 @@
-{ pkgs, ... }:
-let
-  theme = pkgs.myThemes.current;
-in
-{
-  home-manager.users.adrielus.programs.rofi = {
-    enable = true;
-    font = "Source Code Pro 16";
-    location = "center";
-    # padding = 10;
-    # lines = 7;
-    # fullscreen = false;
-    cycle = true;
-    theme = theme.rofi.theme;
-    extraConfig = theme.rofi.config;
-  };
-}
diff --git a/modules/applications/rofi/default.nix b/modules/applications/rofi/default.nix
new file mode 100644
index 0000000..557acce
--- /dev/null
+++ b/modules/applications/rofi/default.nix
@@ -0,0 +1,23 @@
+{ pkgs, lib, ... }:
+let
+  theme = pkgs.myThemes.current;
+  rofi = pkgs.rofi.override
+    {
+      plugins = with pkgs;[
+        rofi-power-menu
+        rofi-calc
+        rofi-emoji
+      ];
+    };
+in
+{
+  home-manager.users.adrielus = {
+    home.packages = [ rofi ];
+    home.file.".local/share/rofi/themes/${theme.name}.rasi".text = builtins.readFile theme.rofi.theme;
+
+    xdg.configFile."rofi/config.rasi".text = ''
+      @import "${./pre.rasi}"
+      ${theme.rofi.config}
+    '';
+  };
+}
diff --git a/modules/applications/rofi/pre.rasi b/modules/applications/rofi/pre.rasi
new file mode 100644
index 0000000..73a23f8
--- /dev/null
+++ b/modules/applications/rofi/pre.rasi
@@ -0,0 +1,5 @@
+configuration {
+  location: 0;
+  cycle: true;
+  font: "Source Code Pro 16";
+}
diff --git a/modules/applications/xmonad/Main.hs b/modules/applications/xmonad/Main.hs
index 42df757..b5d0136 100644
--- a/modules/applications/xmonad/Main.hs
+++ b/modules/applications/xmonad/Main.hs
@@ -79,7 +79,8 @@ main =
 
     -- TODO: find a way to bind all the program-opening-keybindings to a single sub-map
     keymap =
-      [ ("M-p", spawn "rofi -show run"),
+      [ ("M-p", spawn "rofi -show drun"),
+        ("M-w", spawn "rofi -show window"),
         ("M-g", spawn myBrowser),
         ("M-d", spawn "Discord"),
         ("M-v", spawn "alacritty -e vimclip"),
diff --git a/modules/themes/catppuccin/default.nix b/modules/themes/catppuccin/default.nix
index 74c9ed4..180a5db 100644
--- a/modules/themes/catppuccin/default.nix
+++ b/modules/themes/catppuccin/default.nix
@@ -28,8 +28,10 @@ in
   gtk.path = null;
   xresources = builtins.readFile "${foreign.xresources}/Xresources";
   rofi = {
-    theme = "purple";
-    config = { };
+    theme = "${foreign.rofi}/.local/share/rofi/themes/catppuccin.rasi";
+    config = ''
+      @import "${foreign.rofi}/.config/rofi/config.rasi"
+      @import "${./rofi.rasi}"'';
   };
   alacritty.settings = {
     import = [ "${foreign.alacritty}/catppuccin.yml" ];
@@ -37,8 +39,6 @@ in
       padding = {
         x = 0;
         y = 0;
-        # x = 8;
-        # y = 8;
       };
 
       gtk_theme_variant = "dark";
diff --git a/modules/themes/catppuccin/rofi.rasi b/modules/themes/catppuccin/rofi.rasi
new file mode 100644
index 0000000..67b27bf
--- /dev/null
+++ b/modules/themes/catppuccin/rofi.rasi
@@ -0,0 +1,12 @@
+window {
+  height: 50%;
+  width: 50%;
+}
+
+listview {
+  columns: 1;
+}
+
+element selected {
+  background-color: #373759; 
+}
diff --git a/modules/themes/themes.nix b/modules/themes/themes.nix
index 3f619ff..fc94a48 100644
--- a/modules/themes/themes.nix
+++ b/modules/themes/themes.nix
@@ -10,9 +10,9 @@ lib.lists.map (theme: pkgs.callPackage theme { }) [
     # wallpaper = "os/nix-black-4k.png";
     # wallpaper = "landscapes/forrest.png";
     # wallpaper = "landscapes/salty_mountains.png";
-    # wallpaper = "misc/rainbow.png";
-    wallpaper.foreign = ./wallpapers/eye.png;
-    transparency = 0.8;
+    wallpaper = "misc/rainbow.png";
+    # wallpaper.foreign = ./wallpapers/eye.png;
+    transparency = 0.93;
   })
   (githubVariant {
     variant = "light";