From dd76ef7e28a15b095de6afe61a825281f90df1be Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Wed, 26 Aug 2026 16:33:16 +0530 Subject: desktop: showing currently active windows in eww - successfully showing the icons for the currently active windows running in the current workspace --- modules/desktop/eww/yuck.nix | 67 +++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 22 deletions(-) (limited to 'modules/desktop/eww/yuck.nix') 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 = '' - - - - ''; - 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)))) ''; }; } -- cgit v1.2.3