aboutsummaryrefslogtreecommitdiffstats
path: root/modules/desktop/eww/yuck.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/desktop/eww/yuck.nix')
-rw-r--r--modules/desktop/eww/yuck.nix67
1 files changed, 45 insertions, 22 deletions
diff --git a/modules/desktop/eww/yuck.nix b/modules/desktop/eww/yuck.nix
index d61f70a..df688fe 100644
--- a/modules/desktop/eww/yuck.nix
+++ b/modules/desktop/eww/yuck.nix
@@ -6,46 +6,65 @@
}:
{
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
+ config.desktop.niri.package
jq
];
- text = ''
- #!/usr/bin/env bash
- # Outputs JSON array of workspaces for eww bar
- niri msg -j workspaces | jq -c 'sort_by(.idx)'
- '';
+ text = builtins.readFile ./workspaces.sh;
};
+
+ activate-windows =
+ let
+ pythonEnv = pkgs.python3.withPackages (ps: [ ps.pygobject3 ]);
+ in
+ pkgs.stdenv.mkDerivation {
+ pname = "eww-activate-windows";
+ version = "0.1.0";
+ src = ./activate-windows.py;
+ dontUnpack = true;
+ meta.mainProgram = "eww-activate-windows";
+
+ nativeBuildInputs = [
+ pkgs.wrapGAppsHook3
+ pkgs.gobject-introspection
+ ];
+ buildInputs = [ pkgs.gtk3 ];
+
+ installPhase = ''
+ mkdir -p $out/bin
+ install -m755 $src $out/bin/eww-activate-windows
+ patchShebangs $out/bin/eww-activate-windows
+ '';
+
+ # wrapGAppsHook3 wraps every executable in $out/bin automatically,
+ # setting GI_TYPELIB_PATH etc. from buildInputs' closure.
+ preFixup = ''
+ gappsWrapperArgs+=(--prefix PATH : "${pythonEnv}/bin")
+ '';
+ };
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}")
+ (deflisten workspaces :initial "[]" "${lib.getExe workspaces}")
+ (deflisten active-windows :initial "[]" "${lib.getExe activate-windows}")
(defwindow bar
:monitor 0
:geometry (geometry
:x "0px"
:y "0px"
- :width "50px"
+ :width "60px"
:height "100%"
:anchor "top right")
:stacking "fg"
:focusable "none"
- :reserve (struts :distance "50px" :side "right")
+ :reserve (struts :distance "60px" :side "right")
(bar-content))
(defwidget bar-content []
@@ -55,15 +74,19 @@
(windows-widget))))
(defwidget workspaces-widget []
- (box :orientation "v" :space-evenly false :spacing 4 :halign "center" :class "workspaces"
+ (box :orientation "v" :space-evenly false :spacing 4 :halign "fill" :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}")))))
+ (eventbox :onclick "niri msg action focus-workspace ''${ws.idx}"
+ :cursor "pointer"
+ :halign "fill"
+ (box :halign "fill" :class "workspace-btn ''${ws.is_active ? 'active' : '''}"
+ (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)))
+
+ (for w in active-windows
+ (image :class "win-icon" :path "''${w.icon != ''' ? w.icon : '${../../../assets/icons/obs.svg}'}" :image-width 20 :image-height 20))))
'';
};
}