From 84ee3b6b12634ccc2751fc41fe1e069be9749f86 Mon Sep 17 00:00:00 2001 From: 4Lost Date: Sat, 30 Aug 2025 18:37:22 +0200 Subject: [PATCH] rework eww - still wip --- flake.nix | 2 - home/programs/eww/default.nix | 2 +- home/programs/eww/src/bar.yuck | 121 ++++++------------ home/programs/eww/src/scripts/ristate.sh | 8 ++ home/programs/eww/src/scripts/ristate_read.sh | 32 +++++ home/programs/eww/src/scripts/river_log.sh | 6 - home/programs/eww/src/scripts/xmonad_logs.sh | 21 --- home/programs/river/default.nix | 2 +- home/programs/river/src/startEww.sh | 1 + home/programs/zsh.nix | 2 +- 10 files changed, 84 insertions(+), 113 deletions(-) create mode 100755 home/programs/eww/src/scripts/ristate.sh create mode 100755 home/programs/eww/src/scripts/ristate_read.sh delete mode 100755 home/programs/eww/src/scripts/river_log.sh delete mode 100755 home/programs/eww/src/scripts/xmonad_logs.sh diff --git a/flake.nix b/flake.nix index 2188951..8a220f8 100644 --- a/flake.nix +++ b/flake.nix @@ -30,7 +30,6 @@ home-manager.nixosModules.home-manager { home-manager = { - useGlobalPkgs = true; useUserPackages = true; extraSpecialArgs = { inherit inputs; }; users.elias = import ./home/default-laptop.nix; @@ -51,7 +50,6 @@ home-manager.nixosModules.home-manager { home-manager = { - useGlobalPkgs = true; useUserPackages = true; extraSpecialArgs = { inherit inputs; }; users.elias = import ./home/default-desktop.nix; diff --git a/home/programs/eww/default.nix b/home/programs/eww/default.nix index aaf9c8a..9c6fe3f 100644 --- a/home/programs/eww/default.nix +++ b/home/programs/eww/default.nix @@ -1,7 +1,7 @@ { pkgs, ... }: { - home.packages = with pkgs; [ eww ]; + home.packages = with pkgs; [ eww jq ]; xdg.configFile."eww" = { recursive = true; diff --git a/home/programs/eww/src/bar.yuck b/home/programs/eww/src/bar.yuck index e55a84e..a9c1941 100644 --- a/home/programs/eww/src/bar.yuck +++ b/home/programs/eww/src/bar.yuck @@ -18,11 +18,11 @@ :orientation "horizontal" :space-evenly false :class "bar" - ;;(widgetWorkspaces) - ;;(widgetLogSeperator) - ;;(widgetLayouts) - ;;(widgetLogSeperator) - ;;(widgetWindows) + (widgetWorkspaces) + (widgetLogSeperator) + (widgetLayouts) + (widgetLogSeperator) + (widgetWindows) (box :hexpand true) (idle_inhibitor) (widSep) @@ -199,88 +199,47 @@ -;; /-- XMonad Logs | Old --> +;; /-- River State --> -(defvar ws1 "ws-empty") -(defvar ws2 "ws-empty") -(defvar ws3 "ws-empty") -(defvar ws4 "ws-empty") -(defvar ws5 "ws-empty") -(defvar ws6 "ws-empty") -(defvar ws7 "ws-empty") -(defvar ws8 "ws-empty") -(defvar ws9 "ws-empty") -(defvar layouts "") -(defpoll windows - :interval "1s" - :initial "-" - `sh ~/.config/eww/scripts/xmonad_logs.sh`) + (defvar ws1 "ws-empty") + (defvar ws2 "ws-empty") + (defvar ws3 "ws-empty") + (defvar ws4 "ws-empty") + (defvar ws5 "ws-empty") + (defvar ws6 "ws-empty") + (defvar ws7 "ws-empty") + (defvar ws8 "ws-empty") + (defvar ws9 "ws-empty") + + (defvar layouts "") + (defpoll windows + :interval "1s" + :initial "-" + `sh ~/.config/eww/scripts/ristate_read.sh`) (defwidget widgetWorkspaces [] (box :orientation "horizontal" :class "workspace-buttons" - (button - :onclick "wmctrl -s 0" - :class "workspace-button ${ws1}" - (label - :text "1")) - (label - :text " ") - (button - :onclick "wmctrl -s 1" - :class "workspace-button ${ws2}" - (label - :text "2")) - (label - :text " ") - (button - :onclick "wmctrl -s 2" - :class "workspace-button ${ws3}" - (label - :text "3")) - (label - :text " ") - (button - :onclick "wmctrl -s 3" - :class "workspace-button ${ws4}" - (label - :text "4")) - (label - :text " ") - (button - :onclick "wmctrl -s 4" - :class "workspace-button ${ws5}" - (label - :text "5")) - (label - :text " ") - (button - :onclick "wmctrl -s 5" - :class "workspace-button ${ws6}" - (label - :text "6")) - (label - :text " ") - (button - :onclick "wmctrl -s 6" - :class "workspace-button ${ws7}" - (label - :text "7")) - (label - :text " ") - (button - :onclick "wmctrl -s 7" - :class "workspace-button ${ws8}" - (label - :text "8")) - (label - :text " ") - (button - :onclick "wmctrl -s 8" - :class "workspace-button ${ws9}" - (label - :text "9")))) + + (button :onclick "riverctl set-focused-tags 1" :class "workspace-button ${ws1}" (label :text "1")) + (label :text " ") + (button :onclick "riverctl set-focused-tags 2" :class "workspace-button ${ws2}" (label :text "2")) + (label :text " ") + (button :onclick "riverctl set-focused-tags 3" :class "workspace-button ${ws3}" (label :text "3")) + (label :text " ") + (button :onclick "riverctl set-focused-tags 4" :class "workspace-button ${ws4}" (label :text "4")) + (label :text " ") + (button :onclick "riverctl set-focused-tags 5" :class "workspace-button ${ws5}" (label :text "5")) + (label :text " ") + (button :onclick "riverctl set-focused-tags 6" :class "workspace-button ${ws6}" (label :text "6")) + (label :text " ") + (button :onclick "riverctl set-focused-tags 7" :class "workspace-button ${ws7}" (label :text "7")) + (label :text " ") + (button :onclick "riverctl set-focused-tags 8" :class "workspace-button ${ws8}" (label :text "8")) + (label :text " ") + (button :onclick "riverctl set-focused-tags 9" :class "workspace-button ${ws9}" (label :text "9")) + )) (defwidget widgetWindows [] (label diff --git a/home/programs/eww/src/scripts/ristate.sh b/home/programs/eww/src/scripts/ristate.sh new file mode 100755 index 0000000..4251f0e --- /dev/null +++ b/home/programs/eww/src/scripts/ristate.sh @@ -0,0 +1,8 @@ +TEMP_FILE="/tmp/river-eww-status" + +while true; do + ristate -t >"$TEMP_FILE.tmp" + ristate -w >>"$TEMP_FILE.tmp" + mv "$TEMP_FILE.tmp" "$TEMP_FILE" + sleep 1 +done diff --git a/home/programs/eww/src/scripts/ristate_read.sh b/home/programs/eww/src/scripts/ristate_read.sh new file mode 100755 index 0000000..9db811f --- /dev/null +++ b/home/programs/eww/src/scripts/ristate_read.sh @@ -0,0 +1,32 @@ +TEMP_FILE="/tmp/river-eww-status" + +# Read last two lines (layout/tags and focused window) +json=$(tail -n2 "$TEMP_FILE" | head -n1) +win_json=$(tail -n1 "$TEMP_FILE") + +# Extract layout +layout=$(echo "$json" | jq -r '.layout // ""') + +# Extract focused window title +windows=$(echo "$win_json" | jq -r '.title // ""') + +# Extract focused tags as array +mapfile -t focused_tags < <(echo "$json" | jq -r '.tags.BOE // [] | .[]') + +# Update workspace classes +for i in $(seq 1 9); do + class="ws-empty" + for tag in "${focused_tags[@]}"; do + if [[ "$tag" == "$i" ]]; then + class="ws-current" + break + fi + done + eww update ws$i="$class" +done + +# Update layout +eww update layouts="$layout" + +# Output focused window for widget +echo "$windows" diff --git a/home/programs/eww/src/scripts/river_log.sh b/home/programs/eww/src/scripts/river_log.sh deleted file mode 100755 index 9f6de7c..0000000 --- a/home/programs/eww/src/scripts/river_log.sh +++ /dev/null @@ -1,6 +0,0 @@ -socat - UNIX-CONNECT:"$XDG_RUNTIME_DIR"/river/status | while read -r line; do - workspace=$(echo "$line" | jq -r '.workspace') - layout=$(echo "$line" | jq -r '.layout') - title=$(echo "$line" | jq -r '.title') - echo "WS: $workspace | Layout: $layout | $title" -done diff --git a/home/programs/eww/src/scripts/xmonad_logs.sh b/home/programs/eww/src/scripts/xmonad_logs.sh deleted file mode 100755 index 663ee37..0000000 --- a/home/programs/eww/src/scripts/xmonad_logs.sh +++ /dev/null @@ -1,21 +0,0 @@ -line=$(cat /tmp/xmonad-eww-log) -IFS='|' read -r workspaces layouts windows <<<"$line" -# Workspaces -workspaceArray=($workspaces) -i=0 -for ws in "${workspaceArray[@]}"; do - i=$((i + 1)) - if [[ "$ws" == [\[]* ]]; then - eww update ws$i="ws-current" - elif [[ "$ws" == [\(]* ]]; then - eww update ws$i="ws-visible" - elif [[ "$ws" == [\{]* ]]; then - eww update ws$i="ws-hidden" - else - eww update ws$i="ws-empty" - fi -done -# Layouts -eww update layouts="${layouts}" -# Windows -echo "${windows}" diff --git a/home/programs/river/default.nix b/home/programs/river/default.nix index 7688764..e347dd3 100644 --- a/home/programs/river/default.nix +++ b/home/programs/river/default.nix @@ -8,7 +8,7 @@ grim wl-clipboard rivercarro - # river-status + ristate ]; xdg.configFile."helperscripts" = { recursive = true; diff --git a/home/programs/river/src/startEww.sh b/home/programs/river/src/startEww.sh index 0532bf2..f845950 100755 --- a/home/programs/river/src/startEww.sh +++ b/home/programs/river/src/startEww.sh @@ -2,6 +2,7 @@ hostname=$(hostname) if [[ "$hostname" == "eliasLaptop" ]]; then eww open bar --screen eDP-1 + /home/elias/.config/eww/scripts/ristate.sh elif [[ "$hostname" == "eliasDesktop" ]]; then echo "This is another PC!" else diff --git a/home/programs/zsh.nix b/home/programs/zsh.nix index 9d3b5bb..bcced2a 100644 --- a/home/programs/zsh.nix +++ b/home/programs/zsh.nix @@ -11,7 +11,7 @@ programs.zsh = { enable = true; - dotDir = ".config/zsh"; + dotDir = "${config.xdg.configHome}/zsh"; shellAliases = { update = "sudo nixos-rebuild switch"; conWG = "ssh elias@logout.nonagon.dev -p 6969";