aboutsummaryrefslogtreecommitdiffstats
path: root/modules/desktop/eww
diff options
context:
space:
mode:
Diffstat (limited to 'modules/desktop/eww')
-rw-r--r--modules/desktop/eww/default.nix27
-rw-r--r--modules/desktop/eww/eww.scss.mustache56
-rw-r--r--modules/desktop/eww/scss.nix7
-rw-r--r--modules/desktop/eww/yuck.nix69
4 files changed, 159 insertions, 0 deletions
diff --git a/modules/desktop/eww/default.nix b/modules/desktop/eww/default.nix
new file mode 100644
index 0000000..e22f8c6
--- /dev/null
+++ b/modules/desktop/eww/default.nix
@@ -0,0 +1,27 @@
+{
+ config,
+ lib,
+ ...
+}:
+{
+ imports = [
+ ./yuck.nix
+ ];
+
+ options.desktop.eww = {
+ package = lib.mkOption {
+ type = lib.types.package;
+ readOnly = true;
+ default = config.programs.eww.package;
+ description = "The eww package to use.";
+ };
+ };
+
+ config = {
+ programs.eww = {
+ enable = true;
+ systemd.enable = true;
+ scssConfig = builtins.readFile (import ./scss.nix { inherit config; });
+ };
+ };
+}
diff --git a/modules/desktop/eww/eww.scss.mustache b/modules/desktop/eww/eww.scss.mustache
new file mode 100644
index 0000000..a791633
--- /dev/null
+++ b/modules/desktop/eww/eww.scss.mustache
@@ -0,0 +1,56 @@
+* {
+ font-family: "Fira Code Nerd Font";
+ font-size: 18px;
+ min-height: 0;
+}
+
+window#eww-bar {
+ background: transparent;
+}
+
+.bar-container {
+ background: #{{base00}};
+ border: 1px solid #{{base07}};
+ padding: 5px 0;
+ margin: 5px;
+}
+
+.workspaces {
+ background: transparent;
+ padding: 0;
+ margin: 0;
+}
+
+.workspaces button {
+ background-image: none;
+ box-shadow: none;
+ text-shadow: none;
+ outline: none;
+ border: none;
+ padding: 5px 10px;
+ color: #{{base07}};
+ border: 1px solid #{{base07}};
+ border-color: #{{base07}};
+ border-radius: 0;
+ min-width: 0;
+ min-height: 0;
+ margin: 0 5px;
+ font-size: 24px;
+ background: transparent;
+}
+
+.workspaces button:hover {
+ background: #{{base00}};
+ border: 1px solid #{{base07}};
+ box-shadow: none;
+}
+
+.workspaces button:active {
+ background-image: none;
+ box-shadow: none;
+}
+
+.workspaces button:hover {
+ background: #{{base00}};
+ border-color: #{{base07}};
+}
diff --git a/modules/desktop/eww/scss.nix b/modules/desktop/eww/scss.nix
new file mode 100644
index 0000000..b535c3a
--- /dev/null
+++ b/modules/desktop/eww/scss.nix
@@ -0,0 +1,7 @@
+{
+ config,
+ ...
+}:
+config.scheme {
+ template = builtins.readFile ./eww.scss.mustache;
+}
diff --git a/modules/desktop/eww/yuck.nix b/modules/desktop/eww/yuck.nix
new file mode 100644
index 0000000..d61f70a
--- /dev/null
+++ b/modules/desktop/eww/yuck.nix
@@ -0,0 +1,69 @@
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
+{
+ config = lib.mkIf config.desktop.enable {
+ home.file.".config/eww/icons/fallback.svg".text = ''
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
+ <rect x="2" y="2" width="20" height="20" rx="3" fill="none" stroke="#c8ccd4" stroke-width="2"/>
+ </svg>
+ '';
+
+ programs.eww.yuckConfig =
+ let
+ workspaces = pkgs.writeShellApplication {
+ name = "eww-workspaces";
+ # This automatically adds these packages to the script's PATH
+ runtimeInputs = with pkgs; [
+ niri
+ jq
+ ];
+
+ text = ''
+ #!/usr/bin/env bash
+ # Outputs JSON array of workspaces for eww bar
+ niri msg -j workspaces | jq -c 'sort_by(.idx)'
+ '';
+ };
+ in
+ ''
+ (defpoll time :interval "10s" "date '+%H:%M'")
+ (defpoll date :interval "60s" "date '+%d/%m'")
+ (defpoll workspaces :interval "1s" :initial "[]" "${lib.getExe workspaces}")
+ (defpoll active-windows :interval "1s" "${lib.getExe config.scripts.eww-active-windows.package}")
+
+ (defwindow bar
+ :monitor 0
+ :geometry (geometry
+ :x "0px"
+ :y "0px"
+ :width "50px"
+ :height "100%"
+ :anchor "top right")
+ :stacking "fg"
+ :focusable "none"
+ :reserve (struts :distance "50px" :side "right")
+ (bar-content))
+
+ (defwidget bar-content []
+ (box :orientation "v" :space-evenly false :class "bar-container"
+ (box :orientation "v" :space-evenly false :valign "start" :class "top-section"
+ (workspaces-widget)
+ (windows-widget))))
+
+ (defwidget workspaces-widget []
+ (box :orientation "v" :space-evenly false :spacing 4 :halign "center" :class "workspaces"
+ (for ws in workspaces
+ (button :class {ws.is_active ? "ws-active" : "ws-inactive"}
+ :onclick "niri msg action focus-workspace ''${ws.idx}"
+ (label :text "''${ws.idx}")))))
+
+ (defwidget windows-widget []
+ (box :orientation "v" :space-evenly false :spacing 4 :halign "center" :class "windows"
+ (image :class "win-icon" :path "/tmp/test-icon.svg" :image-width 20 :image-height 20)))
+ '';
+ };
+}