#!/bin/bash delay() { timeout 2 socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | while read -r line; do if [[ ${line%>>*} == "monitor"* ]]; then return fi done generate } generate() { unset id name horizontal vertical scale activeWorkspace i=0 while read -r k n h v s a t; do id[$i]="$k" name[$i]="$n" horizontal[$i]="$h" vertical[$i]="$v" scale[$i]="$s" activeWorkspace[$i]="$a" if [[ $(($t%2)) == 1 ]]; then temp=${vertical[$i]} vertical[$i]=${horizontal[$i]} horizontal[$i]=$temp fi ((i=i+1)) done < <(hyprctl monitors -j | jq -r '.[]|"\(.id) \(.name) \(.width) \(.height) \(.scale) \(.activeWorkspace.id) \(.transform)"') if [[ $i > 1 ]]; then displayMonitorID=true else displayMonitorID=false fi echo -n "" > $XDG_CONFIG_HOME/eww/bar.yuck for ((i = 0; i < ${#id[@]}; i++)); do scale_value=$(echo "${scale[$i]}" | bc -l) new_width_float=$(echo "(${horizontal[$i]} / ${scale_value}) -10" | bc) new_height_float=$(echo "${vertical[$i]} / ${scale_value} * 0.03" | bc) new_width=$(echo "$new_width_float / 1" | bc) new_height=$(echo "$new_height_float / 1" | bc) monitorID=$(xrandr --listactivemonitors | grep +${name[$i]} | awk '{sub(/.$/,"",$1); print $1}') echo " (defwindow bar${id[$i]} :monitor \"${monitorID}\" :class \"bar\" :geometry (geometry :x \"0%\" :y \"5px\" :width \"${new_width}px\" :height \"25px\" :anchor \"top center\") :stacking \"fg\" :exclusive true (bar${id[$i]})) (defwidget monitor${id[$i]} [] (box :visible ${displayMonitorID} (label :width \"15\" :text \"$((id[$i]+1))\") (seperator))) (defwidget workspaces${id[$i]} [] (box :space-evenly false :spacing 3 (for workspace in workspaces (eventbox :onclick \`/home/willifan/.config/scripts/workspaces.sh \${workspace.ID}\` :class {workspace.activeID == \"${monitorID}\" ? \"activeWorkspace\" : \"smallBox\"} :valign \"center\" :halign \"center\" :height 20 :width 20 (box :halign \"center\" :space-evenly false (smallSpacer) (label :class {workspace.occupied == true ? \"\" : \"unoccupiedWorkspace\"} :width 16 :text \"\${workspace.ID}\") (imageDPI :visible \"\${workspace.occupied}\" :image \"\${workspace.clients[0].icon}\" :size \"16\") (smallSpacer)))))) (defwidget start${id[$i]} [] (box :orientation \"h\" :space-evenly false :halign \"start\" (space) (monitor${id[$i]}) (workspaces${id[$i]}))) (defwidget bar${id[$i]} [] (centerbox :orientation \"h\" (start${id[$i]}) (center) (end))) " >> $XDG_CONFIG_HOME/eww/bar.yuck done eww close-all eww reload for i in "${!id[@]}"; do windows="${windows}bar${id[$i]} " done echo $windows eww open-many $windows } generate socat -u UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE"/.socket2.sock - | while read -r line; do if [[ ${line%>>*} == "monitor"* ]]; then delay & fi done #(for monitor in monitors # (defwindow bar2 # :monitor "${monitor.id}" # :geometry (geometry # :x "0%" # :y "5px" # :width "${(monitor.width / monitor.scale )-10}px" # :height "${monitor.height / monitor.scale * 0.03}%" # :anchor "top cemter") # :stacking "fg" # :exclusive true # (bar))) #(defwidget workspaces${id[$i]} [] # (box # (for workspace in workspaces # (eventbox # :onclick `/home/willifan/.config/scripts/workspaces.sh ${workspace.num}` # (label # :width "15" # :class {workspace.active == 1 ? "activeWorkspace" : workspace.occupied == 0 ? "unoccupiedWorkspace" : ""} # ;;:visible {workspace.occupied == 1 ? "true" : "false"} # :text "${workspace.num}"))))) #(defwidget start${id[$i]} [] # (box # :orientation "h" # :space-evenly false # :halign "start" # (space) # (workspaces${id[$i]}))) #(defwidget bar${id[$i]} [] # (centerbox :orientation "h" # (start${id[$i]}) # (center) # (end)))