diff --git a/flake.lock b/flake.lock index 967a634..3cebd52 100644 --- a/flake.lock +++ b/flake.lock @@ -332,22 +332,6 @@ "type": "github" } }, - "nixpkgs-next": { - "locked": { - "lastModified": 1711646189, - "narHash": "sha256-+fnMLzJhiLAY/2ACsWPnLkstUpR0PKEVjlsCWH2aFGg=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "5d44454602e6964b5e582edc81098aac06f8ecbe", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "staging-next", - "repo": "nixpkgs", - "type": "github" - } - }, "nixpkgs-stable": { "locked": { "lastModified": 1711124224, @@ -461,7 +445,6 @@ "home-manager": "home-manager", "hyprland": "hyprland", "nixpkgs": "nixpkgs_3", - "nixpkgs-next": "nixpkgs-next", "nixpkgs-stable": "nixpkgs-stable", "nixpkgsForIosevka": "nixpkgsForIosevka", "pre-commit-hooks": "pre-commit-hooks", diff --git a/flake.nix b/flake.nix index dbbd588..339a67f 100644 --- a/flake.nix +++ b/flake.nix @@ -4,7 +4,7 @@ nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-23.11"; - nixpkgs-next.url = "github:nixos/nixpkgs/staging-next"; + # nixpkgs-next.url = "github:nixos/nixpkgs/staging-next"; # I have this as a separate input so I don't rebuild the font every time I # want to upgrade nixpkgs @@ -48,7 +48,7 @@ outputs = { self, nixpkgs, - nixpkgs-next, + # nixpkgs-next, nixpkgsForIosevka, home-manager, hardware, @@ -147,7 +147,7 @@ }) (import ./nixos)) // { # TODO: stabilize "appliance"-type hosts on stable nixpkgs ASAP to avoid breakages - beefcake = nixpkgs-next.lib.nixosSystem { + beefcake = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = { inherit inputs outputs api-lyte-dev hardware; diff --git a/modules/home-manager/eww/eww.scss b/modules/home-manager/eww/eww.scss index 145eba6..9902fbc 100644 --- a/modules/home-manager/eww/eww.scss +++ b/modules/home-manager/eww/eww.scss @@ -93,6 +93,13 @@ $rosewater: #f5e0dc; color: $text; } +.workspace.occupied.active, +.workspace.active { + color: $base; + background-color: $subtext1; +} + +.workspace.occupied.focused.active, .workspace.occupied.focused, .workspace.focused { color: $base; diff --git a/modules/home-manager/eww/eww.yuck b/modules/home-manager/eww/eww.yuck index 21e99de..139c3ea 100644 --- a/modules/home-manager/eww/eww.yuck +++ b/modules/home-manager/eww/eww.yuck @@ -49,6 +49,7 @@ ) {" ${round(EWW_CPU["avg"], 0)}%"} {" ${round(EWW_RAM["used_mem_perc"], 0)}%"} + ; TODO: have these "widgets" be omitted entirely instead of just empty strings {(showBrightness == "true") ? (" ${brightness}%") : ""} {(showBattery == "true") ? ("󱊣 ${EWW_BATTERY["BAT1"]["capacity"]}% (${batteryTime})") : ""} (box :orientation "h" :space-evenly false :halign "start" :valign "center" (workspaces)) diff --git a/modules/home-manager/eww/scripts/hypr-workspaces.bash b/modules/home-manager/eww/scripts/hypr-workspaces.bash index 5baa1aa..3829c24 100755 --- a/modules/home-manager/eww/scripts/hypr-workspaces.bash +++ b/modules/home-manager/eww/scripts/hypr-workspaces.bash @@ -1,49 +1,52 @@ #!/usr/bin/env bash +# TODO: we're mixing bash arrays and not-arrays - get it together + #define icons for workspaces 1-9 ic=(1 2 3 4 5 6 7 8 9) -#initial check for occupied workspaces -for num in $(hyprctl workspaces | grep ID | sed 's/()/(1)/g' | awk 'NR>1{print $1}' RS='(' FS=')'); do - export o"$num"=" occupied" -done - -#initial check for focused workspace -for num in $(hyprctl monitors | grep active | sed 's/()/(1)/g' | awk 'NR>1{print $1}' RS='(' FS=')'); do - export f"$num"=" focused" - export fnum=f"$num" -done +occ() { export o"$1"="occupied"; } +unocc() { unset -v o"$1"; } + +active() { export a"$1"="active"; } +unactive() { unset -v a"$1"; } + +focus() { export f"$1"="focused"; } +unfocus() { unset -v f"$1"; } workspaces() { - if [[ ${1:0:9} == "workspace" ]]; then - # set focused workspace - unset -v "$fnum" - num=${1:11} - export f"$num"=" focused" - export fnum=f"$num" - elif [[ ${1:0:15} == "createworkspace" ]]; then - # set occupied workspace - num=${1:17} - export o"$num"=" occupied" - export f"$num"=" focused" - elif [[ ${1:0:16} == "destroyworkspace" ]]; then - # unset occupied workspace - num=${1:18} - unset -v o"$num" f"$num" - fi + for num in 1 2 3 4 5 6 7 8 9; do + unfocus $num + unactive $num + unocc $num + done + + # TODO: avoid recomputing these each time and actually listen to the events? + mons_json=$(hyprctl monitors -j) + for num in $(hyprctl workspaces -j | jq -r '.[] | select(.windows > 0) | .id'); do + occ "$num" + done + + for num in $(echo "$mons_json" | jq -r '.[].activeWorkspace.id'); do + active "$num" + done + + for num in $(echo "$mons_json" | jq -r '.[] | select(.focused) | .activeWorkspace.id'); do + focus "$num" + done # render eww widget echo "(eventbox :onscroll \"echo {} | sed -e 's/up/-1/g' -e 's/down/+1/g' | xargs hyprctl dispatch workspace\" \ (box :class \"workspaces\" :orientation \"h\" :spacing 0 :space-evenly \"true\" \ - (button :onclick \"hyprctl dispatch workspace 1\" :onrightclick \"hyprctl dispatch workspace 1\" :class \"workspace$o1$f1\" \"${ic[0]}\") \ - (button :onclick \"hyprctl dispatch workspace 2\" :onrightclick \"hyprctl dispatch workspace 2\" :class \"workspace$o2$f2\" \"${ic[1]}\") \ - (button :onclick \"hyprctl dispatch workspace 3\" :onrightclick \"hyprctl dispatch workspace 3\" :class \"workspace$o3$f3\" \"${ic[2]}\") \ - (button :onclick \"hyprctl dispatch workspace 4\" :onrightclick \"hyprctl dispatch workspace 4\" :class \"workspace$o4$f4\" \"${ic[3]}\") \ - (button :onclick \"hyprctl dispatch workspace 5\" :onrightclick \"hyprctl dispatch workspace 5\" :class \"workspace$o5$f5\" \"${ic[4]}\") \ - (button :onclick \"hyprctl dispatch workspace 6\" :onrightclick \"hyprctl dispatch workspace 6\" :class \"workspace$o6$f6\" \"${ic[5]}\") \ - (button :onclick \"hyprctl dispatch workspace 7\" :onrightclick \"hyprctl dispatch workspace 7\" :class \"workspace$o7$f7\" \"${ic[6]}\") \ - (button :onclick \"hyprctl dispatch workspace 8\" :onrightclick \"hyprctl dispatch workspace 8\" :class \"workspace$o8$f8\" \"${ic[7]}\") \ - (button :onclick \"hyprctl dispatch workspace 9\" :onrightclick \"hyprctl dispatch workspace 9\" :class \"workspace$o9$f9\" \"${ic[8]}\") \ + (button :onclick \"hyprctl dispatch workspace 1\" :onrightclick \"hyprctl dispatch workspace 1\" :class \"workspace $a1 $o1 $f1\" \"${ic[0]}\") \ + (button :onclick \"hyprctl dispatch workspace 2\" :onrightclick \"hyprctl dispatch workspace 2\" :class \"workspace $a2 $o2 $f2\" \"${ic[1]}\") \ + (button :onclick \"hyprctl dispatch workspace 3\" :onrightclick \"hyprctl dispatch workspace 3\" :class \"workspace $a3 $o3 $f3\" \"${ic[2]}\") \ + (button :onclick \"hyprctl dispatch workspace 4\" :onrightclick \"hyprctl dispatch workspace 4\" :class \"workspace $a4 $o4 $f4\" \"${ic[3]}\") \ + (button :onclick \"hyprctl dispatch workspace 5\" :onrightclick \"hyprctl dispatch workspace 5\" :class \"workspace $a5 $o5 $f5\" \"${ic[4]}\") \ + (button :onclick \"hyprctl dispatch workspace 6\" :onrightclick \"hyprctl dispatch workspace 6\" :class \"workspace $a6 $o6 $f6\" \"${ic[5]}\") \ + (button :onclick \"hyprctl dispatch workspace 7\" :onrightclick \"hyprctl dispatch workspace 7\" :class \"workspace $a7 $o7 $f7\" \"${ic[6]}\") \ + (button :onclick \"hyprctl dispatch workspace 8\" :onrightclick \"hyprctl dispatch workspace 8\" :class \"workspace $a8 $o8 $f8\" \"${ic[7]}\") \ + (button :onclick \"hyprctl dispatch workspace 9\" :onrightclick \"hyprctl dispatch workspace 9\" :class \"workspace $a9 $o9 $f9\" \"${ic[8]}\") \ ) \ )" } @@ -52,6 +55,10 @@ workspaces() { workspaces # listen to events and re-render -socat - UNIX-CONNECT:/tmp/hypr/"${HYPRLAND_INSTANCE_SIGNATURE}"/.socket2.sock | while read -r event; do - workspaces "$event" +while true; do + # TODO: not sure why this socat | read invocation seems to stop? + socat - "UNIX-CONNECT:/tmp/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while read -r line; do + workspaces "$line" + done done +echo '(box "DONE")' diff --git a/modules/nixos/ewwbar.nix b/modules/nixos/ewwbar.nix index 500ef10..eba6869 100644 --- a/modules/nixos/ewwbar.nix +++ b/modules/nixos/ewwbar.nix @@ -1,3 +1,3 @@ {pkgs, ...}: { - environment.systemPackages = with pkgs; [eww upower]; + environment.systemPackages = with pkgs; [eww upower jq]; }