From 9a6f21b65da927fb064773bd83e92151c50b6823 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Thu, 27 Aug 2026 01:55:13 +0530 Subject: desktop: added some of basic system information in the system section - added date, time, memory used (percent), cpu usage (percent), network status (icons for up or down) --- modules/desktop/eww/yuck.nix | 155 ++++++++++++++++++++++++++----------------- 1 file changed, 94 insertions(+), 61 deletions(-) (limited to 'modules/desktop/eww/yuck.nix') diff --git a/modules/desktop/eww/yuck.nix b/modules/desktop/eww/yuck.nix index d522d9b..03de4bf 100644 --- a/modules/desktop/eww/yuck.nix +++ b/modules/desktop/eww/yuck.nix @@ -8,71 +8,91 @@ config = lib.mkIf config.desktop.enable { programs.eww.yuckConfig = let - workspaces = - let - pythonEnv = pkgs.python3.withPackages (ps: [ ps.pygobject3 ]); - in - pkgs.stdenv.mkDerivation { - pname = "eww-workspaces"; - version = "0.1.0"; - src = ./workspaces.py; - dontUnpack = true; - meta.mainProgram = "eww-workspaces"; - - nativeBuildInputs = [ - pkgs.wrapGAppsHook3 - pkgs.gobject-introspection - ]; - buildInputs = [ pkgs.gtk3 ]; - - installPhase = '' - mkdir -p $out/bin - install -m755 $src $out/bin/eww-workspaces - patchShebangs $out/bin/eww-workspaces - ''; - - # wrapGAppsHook3 wraps every executable in $out/bin automatically, - # setting GI_TYPELIB_PATH etc. from buildInputs' closure. - preFixup = '' - gappsWrapperArgs+=(--prefix PATH : "${pythonEnv}/bin") - ''; - }; - - 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") - ''; - }; + pythonEnv = pkgs.python3.withPackages (ps: [ ps.pygobject3 ]); + system-stats = pkgs.stdenv.mkDerivation { + pname = "eww-system-stats"; + version = "0.1.0"; + src = ./system-stats.py; + dontUnpack = true; + meta.mainProgram = "eww-system-stats"; + + nativeBuildInputs = [ + pkgs.wrapGAppsHook3 + pkgs.gobject-introspection + ]; + buildInputs = [ pkgs.gtk3 ]; + + installPhase = '' + mkdir -p $out/bin + install -m755 $src $out/bin/eww-system-stats + patchShebangs $out/bin/eww-system-stats + ''; + + # wrapGAppsHook3 wraps every executable in $out/bin automatically, + # setting GI_TYPELIB_PATH etc. from buildInputs' closure. + preFixup = '' + gappsWrapperArgs+=(--prefix PATH : "${pythonEnv}/bin") + ''; + }; + + workspaces = pkgs.stdenv.mkDerivation { + pname = "eww-workspaces"; + version = "0.1.0"; + src = ./workspaces.py; + dontUnpack = true; + meta.mainProgram = "eww-workspaces"; + + nativeBuildInputs = [ + pkgs.wrapGAppsHook3 + pkgs.gobject-introspection + ]; + buildInputs = [ pkgs.gtk3 ]; + + installPhase = '' + mkdir -p $out/bin + install -m755 $src $out/bin/eww-workspaces + patchShebangs $out/bin/eww-workspaces + ''; + + # wrapGAppsHook3 wraps every executable in $out/bin automatically, + # setting GI_TYPELIB_PATH etc. from buildInputs' closure. + preFixup = '' + gappsWrapperArgs+=(--prefix PATH : "${pythonEnv}/bin") + ''; + }; + + activate-windows = 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'") (deflisten workspaces :initial "[]" "${lib.getExe workspaces}") (deflisten active-windows :initial "[]" "${lib.getExe activate-windows}") + (deflisten system_stats :initial "{\"cpu\":0,\"ram\":0,\"net\":\"down\"}" "${lib.getExe system-stats}") (defwindow bar :monitor 0 @@ -123,8 +143,21 @@ (defwidget system-widget [] (box :orientation "v" :space-evenly false :spacing 6 :halign "fill" :class "system" - (label :class "system-item" :text time) - (label :class "system-item" :text date))) + (box :orientation "v" :class "system-item" :space-evenly false :spacing 4 + (label :class "system-icon" :text "''${system_stats.net == "up" ? "󰤨 " : "󰤭 "}") + (label :class "system-label" :text "")) + (box :orientation "v" :class "system-item" :space-evenly false :spacing 4 + (label :class "system-icon" :text " ") + (label :class "system-label" :text "''${system_stats.cpu}%")) + (box :orientation "v" :class "system-item" :space-evenly false :spacing 4 + (label :class "system-icon" :text " ") + (label :class "system-label" :text "''${system_stats.ram}%")) + (box :orientation "v" :class "system-item" :space-evenly false :spacing 4 + (label :class "system-icon" :text "󰥔 ") + (label :class "system-label small" :text time)) + (box :orientation "v" :class "system-item" :space-evenly false :spacing 4 + (label :class "system-icon" :text "") + (label :class "system-label small" :text date)))) ''; }; } -- cgit v1.2.3