Regenerated
This commit is contained in:
+322
-314
File diff suppressed because it is too large
Load Diff
+34
-26
@@ -3029,36 +3029,44 @@ These are config files for waybar
|
||||
#+BEGIN_SRC sh :tangle generated/.config/waybar/scripts/hyprscroll-overflow.sh :noweb yes :mkdirp yes :eval never
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
# Fallback output
|
||||
# Fallback JSON (hidden)
|
||||
fallback='{"text":" ","class":"hidden"}'
|
||||
# Get active workspace
|
||||
active_ws=$(hyprctl activeworkspace -j 2>/dev/null | jq -r '.id' 2>/dev/null) || {
|
||||
echo "$fallback"
|
||||
exit 0
|
||||
# Get active workspace ID
|
||||
active_ws=$(hyprctl activeworkspace -j 2>/dev/null | jq -r '.id') || {
|
||||
echo "$fallback"
|
||||
exit 0
|
||||
}
|
||||
# Get workspace info
|
||||
ws=$(hyprctl workspaces -j 2>/dev/null | jq ".[] | select(.id==$active_ws)" 2>/dev/null) || {
|
||||
echo "$fallback"
|
||||
exit 0
|
||||
# Get all clients on the active workspace
|
||||
clients=$(hyprctl clients -j 2>/dev/null | jq "[.[] | select(.workspace.id==$active_ws)]") || {
|
||||
echo "$fallback"
|
||||
exit 0
|
||||
}
|
||||
# Layout
|
||||
layout=$(echo "$ws" | jq -r '.layout // "unknown"' 2>/dev/null)
|
||||
# Clients
|
||||
clients=$(hyprctl clients -j 2>/dev/null | jq "[.[] | select(.workspace.id==$active_ws)]" 2>/dev/null) || {
|
||||
echo "$fallback"
|
||||
exit 0
|
||||
}
|
||||
count=$(echo "$clients" | jq 'length' 2>/dev/null)
|
||||
# In scrolling layout, only 1 is visible
|
||||
visible=1
|
||||
# Conditions
|
||||
if [[ "$layout" != "scrolling" ]] || (( count <= visible )); then
|
||||
echo "$fallback"
|
||||
exit 0
|
||||
# Count total windows
|
||||
count=$(echo "$clients" | jq 'length')
|
||||
# Get monitor geometry for active workspace
|
||||
monitor=$(hyprctl monitors -j 2>/dev/null | jq -r ".[] | select(.activeWorkspace==$active_ws)")
|
||||
if [[ -z "$monitor" ]]; then
|
||||
echo "$fallback"
|
||||
exit 0
|
||||
fi
|
||||
# Tooltip (safe escaping)
|
||||
tooltip=$(echo "$clients" | jq -r '.[].title' 2>/dev/null | sed ':a;N;$!ba;s/\n/\\n/g')
|
||||
# Final output
|
||||
mon_width=$(echo "$monitor" | jq '.width')
|
||||
mon_height=$(echo "$monitor" | jq '.height')
|
||||
# Calculate number of windows that are actually visible on screen
|
||||
# Assume a window is visible if its top-left corner is inside monitor bounds
|
||||
visible_count=$(echo "$clients" | jq --argjson mw "$mon_width" --argjson mh "$mon_height" '
|
||||
map(select(
|
||||
.at[0] >= 0 and .at[0] < $mw and
|
||||
.at[1] >= 0 and .at[1] < $mh
|
||||
)) | length
|
||||
')
|
||||
# Show fallback if all windows are already visible
|
||||
if (( count <= visible_count )); then
|
||||
echo "$fallback"
|
||||
exit 0
|
||||
fi
|
||||
# Build tooltip from window titles (escaped)
|
||||
tooltip=$(echo "$clients" | jq -r '.[].title' | sed ':a;N;$!ba;s/\n/\\n/g')
|
||||
# Output JSON for Waybar
|
||||
echo "{\"text\":\"★ $count\",\"tooltip\":\"$tooltip\",\"class\":\"overflow\"}"
|
||||
#+END_SRC
|
||||
|
||||
|
||||
@@ -1,33 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
# Fallback output
|
||||
# Fallback JSON (hidden)
|
||||
fallback='{"text":" ","class":"hidden"}'
|
||||
# Get active workspace
|
||||
active_ws=$(hyprctl activeworkspace -j 2>/dev/null | jq -r '.id' 2>/dev/null) || {
|
||||
echo "$fallback"
|
||||
exit 0
|
||||
# Get active workspace ID
|
||||
active_ws=$(hyprctl activeworkspace -j 2>/dev/null | jq -r '.id') || {
|
||||
echo "$fallback"
|
||||
exit 0
|
||||
}
|
||||
# Get workspace info
|
||||
ws=$(hyprctl workspaces -j 2>/dev/null | jq ".[] | select(.id==$active_ws)" 2>/dev/null) || {
|
||||
echo "$fallback"
|
||||
exit 0
|
||||
# Get all clients on the active workspace
|
||||
clients=$(hyprctl clients -j 2>/dev/null | jq "[.[] | select(.workspace.id==$active_ws)]") || {
|
||||
echo "$fallback"
|
||||
exit 0
|
||||
}
|
||||
# Layout
|
||||
layout=$(echo "$ws" | jq -r '.layout // "unknown"' 2>/dev/null)
|
||||
# Clients
|
||||
clients=$(hyprctl clients -j 2>/dev/null | jq "[.[] | select(.workspace.id==$active_ws)]" 2>/dev/null) || {
|
||||
echo "$fallback"
|
||||
exit 0
|
||||
}
|
||||
count=$(echo "$clients" | jq 'length' 2>/dev/null)
|
||||
# In scrolling layout, only 1 is visible
|
||||
visible=1
|
||||
# Conditions
|
||||
if [[ "$layout" != "scrolling" ]] || (( count <= visible )); then
|
||||
echo "$fallback"
|
||||
exit 0
|
||||
# Count total windows
|
||||
count=$(echo "$clients" | jq 'length')
|
||||
# Get monitor geometry for active workspace
|
||||
monitor=$(hyprctl monitors -j 2>/dev/null | jq -r ".[] | select(.activeWorkspace==$active_ws)")
|
||||
if [[ -z "$monitor" ]]; then
|
||||
echo "$fallback"
|
||||
exit 0
|
||||
fi
|
||||
# Tooltip (safe escaping)
|
||||
tooltip=$(echo "$clients" | jq -r '.[].title' 2>/dev/null | sed ':a;N;$!ba;s/\n/\\n/g')
|
||||
# Final output
|
||||
mon_width=$(echo "$monitor" | jq '.width')
|
||||
mon_height=$(echo "$monitor" | jq '.height')
|
||||
# Calculate number of windows that are actually visible on screen
|
||||
# Assume a window is visible if its top-left corner is inside monitor bounds
|
||||
visible_count=$(echo "$clients" | jq --argjson mw "$mon_width" --argjson mh "$mon_height" '
|
||||
map(select(
|
||||
.at[0] >= 0 and .at[0] < $mw and
|
||||
.at[1] >= 0 and .at[1] < $mh
|
||||
)) | length
|
||||
')
|
||||
# Show fallback if all windows are already visible
|
||||
if (( count <= visible_count )); then
|
||||
echo "$fallback"
|
||||
exit 0
|
||||
fi
|
||||
# Build tooltip from window titles (escaped)
|
||||
tooltip=$(echo "$clients" | jq -r '.[].title' | sed ':a;N;$!ba;s/\n/\\n/g')
|
||||
# Output JSON for Waybar
|
||||
echo "{\"text\":\"★ $count\",\"tooltip\":\"$tooltip\",\"class\":\"overflow\"}"
|
||||
|
||||
Reference in New Issue
Block a user