about summary refs log tree commit diff stats
path: root/modules/by-name/i3/i3bar-river/module.nix
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--modules/by-name/i3/i3bar-river/module.nix197
1 files changed, 197 insertions, 0 deletions
diff --git a/modules/by-name/i3/i3bar-river/module.nix b/modules/by-name/i3/i3bar-river/module.nix
new file mode 100644
index 00000000..b32ec6a5
--- /dev/null
+++ b/modules/by-name/i3/i3bar-river/module.nix
@@ -0,0 +1,197 @@
+{
+  config,
+  lib,
+  pkgs,
+  ...
+}: let
+  cfg = config.soispha.programs.i3bar-river;
+
+  toColor = color:
+    if builtins.isString color
+    then lib.trivial.fromHexString color
+    else color;
+
+  substractColor = color_a: color_b: let
+    saturatingSub = a: b:
+      if a < b
+      then 0
+      else a - b;
+  in {
+    red = saturatingSub color_a.red color_b.red;
+    green = saturatingSub color_a.green color_b.green;
+    blue = saturatingSub color_a.blue color_b.blue;
+    alpha = saturatingSub color_a.alpha color_b.alpha;
+    inherit (color_a) __toString;
+  };
+
+  colorOption = red: green: blue: alpha:
+    lib.mkOption {
+      type = lib.types.submodule {
+        options = {
+          red = lib.mkOption {
+            type = lib.types.ints.between 0 255;
+            description = "The amount of red in this color";
+            default = toColor red;
+          };
+          green = lib.mkOption {
+            type = lib.types.ints.between 0 255;
+            description = "The amount of green in this color";
+            default = toColor green;
+          };
+          blue = lib.mkOption {
+            type = lib.types.ints.between 0 255;
+            description = "The amount of blue in this color";
+            default = toColor blue;
+          };
+          alpha = lib.mkOption {
+            type = lib.types.ints.between 0 255;
+            description = "The amount of alpha in this color";
+            default = toColor alpha;
+          };
+
+          __toString = lib.mkOption {
+            internal = true;
+
+            default = self: let
+              tH = num: let
+                converted = lib.trivial.toHexString num;
+              in
+                if builtins.stringLength converted == 1
+                then "0${converted}"
+                else assert (builtins.stringLength converted) == 2; converted;
+
+              output = "#${tH self.red}${tH self.green}${tH self.blue}${tH self.alpha}";
+            in
+              output;
+
+            description = "Convert this type to a string before use";
+          };
+        };
+      };
+
+      default = {
+        red = toColor red;
+        green = toColor green;
+        blue = toColor blue;
+        alpha = toColor alpha;
+      };
+
+      description = "The specific color to use for this name.";
+    };
+in {
+  options.soispha.programs.i3bar-river = {
+    enable = lib.mkEnableOption "i3bar-river";
+
+    package = lib.mkPackageOption pkgs "i3bar-river-patched" {};
+
+    colors = {
+      none = colorOption 00 00 00 00;
+
+      white = colorOption "ff" "ff" "ff" "ff";
+
+      blue = colorOption "99" "d1" "db" "ff";
+      green = colorOption "a6" "e3" "a1" "dd";
+      lavendar = colorOption "b4" "be" "fe" "dd";
+      mauve = colorOption "cb" "a6" "f7" "dd";
+      normal = colorOption "c6" "ce" "ef" "ff";
+      peach = colorOption "fa" "b3" "87" "dd";
+      sapphire = colorOption "74" "c7" "ec" "dd";
+      teal = colorOption "94" "e2" "d5" "dd";
+
+      light_gray = colorOption "58" "5b" "70" "ff";
+      gray = colorOption "45" "47" "5a" "ff";
+      dark_gray = colorOption "30" "34" "46" "ff";
+      bright_red = colorOption "e7" "82" "84" "ff";
+
+      vivid_burgundy = colorOption "9f" "1d" "35" "ff";
+
+      unfocused_offset = colorOption "33" "33" "33" "00";
+    };
+  };
+
+  config = lib.mkIf cfg.enable {
+    soispha.programs.river.init.backgroundStart = [cfg.package];
+
+    home-manager.users.soispha = {
+      programs.i3bar-river = {
+        enable = true;
+        inherit (cfg) package;
+
+        settings = {
+          theme = {
+            palette = {
+              # Colors
+              background = toString cfg.colors.none;
+              color = toString cfg.colors.white; # Only used, if blocks do not specify one
+              separator = toString cfg.colors.vivid_burgundy;
+
+              # Tag is set (but not focused or urgent)
+              tag_fg = toString cfg.colors.white;
+              tag_bg = toString cfg.colors.light_gray;
+
+              tag_urgent_fg = toString cfg.colors.white;
+              tag_urgent_bg = toString cfg.colors.bright_red;
+
+              tag_focused_fg = toString cfg.colors.white;
+              tag_focused_bg = toString cfg.colors.teal;
+
+              tag_inactive_fg = toString cfg.colors.white;
+              tag_inactive_bg = toString cfg.colors.none;
+
+              # Shop options
+              blend = true; # whether tags/blocks colors should blend with bar's background
+              hide_inactive_tags = false;
+              show_layout_name = false;
+              show_mode = true;
+              show_tags = true;
+            };
+
+            unfocused_palette = {
+              hide_inactive_tags = true;
+
+              color = toString (substractColor cfg.colors.white cfg.colors.unfocused_offset);
+              separator = toString (substractColor cfg.colors.vivid_burgundy cfg.colors.unfocused_offset);
+
+              tag_fg = toString (substractColor cfg.colors.white cfg.colors.unfocused_offset);
+              tag_bg = toString (substractColor cfg.colors.light_gray cfg.colors.unfocused_offset);
+
+              tag_urgent_fg = toString (substractColor cfg.colors.white cfg.colors.unfocused_offset);
+              tag_urgent_bg = toString (substractColor cfg.colors.bright_red cfg.colors.unfocused_offset);
+
+              tag_focused_fg = toString (substractColor cfg.colors.white cfg.colors.unfocused_offset);
+              tag_focused_bg = toString cfg.colors.vivid_burgundy;
+
+              tag_inactive_fg = toString (substractColor cfg.colors.white cfg.colors.unfocused_offset);
+              tag_inactive_bg = toString (substractColor cfg.colors.none cfg.colors.unfocused_offset);
+            };
+          };
+
+          # The font and various sizes
+          font = "SauceCodePro Nerd Font Mono:pixelsize=26";
+          height = 24;
+          margin_top = 10;
+          margin_bottom = 0;
+          margin_left = 0;
+          margin_right = 0;
+          separator_width = 0;
+          tags_r = 10.0;
+          tags_padding = 10.0;
+          tags_margin = 5.0;
+          blocks_r = 6.0;
+          blocks_overlap = 0.0;
+
+          # Misc
+          position = "top"; # either "top" or "bottom"
+          layer = "overlay"; # one of "top", "overlay", "bottom" or "background"
+          invert_touchpad_scrolling = true;
+          start_hidden = false; # whether the bar is initially in the 'hidden' state
+
+          # WM-specific options
+          wm.river = {
+            max_tag = 9; # Show only the first nine tags
+          };
+        };
+      };
+    };
+  };
+}