[eww] Adds my Eww config

This commit is contained in:
2025-02-16 13:34:14 -08:00
parent cb5c6518f1
commit e642c86e21
16 changed files with 923 additions and 1 deletions

View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -e
handle_event() {
case $1 in
focusedmon*) active_workspace;;
workspace*) active_workspace;;
esac
}
active_workspace() {
hyprctl activeworkspace -j | jq --compact-output --monochrome-output '{ id, name, monitor, has_windows: (.lastwindowtitle != "") }'
}
# Run it once before any events come in.
active_workspace
# Then listen for events
socat -U - "UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while read -r event; do handle_event "$event"; done

View File

@@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -e
SOURCE='@DEFAULT_AUDIO_SOURCE@'
SINK='@DEFAULT_AUDIO_SINK@'
case $1 in
source)
device=$SOURCE
;;
sink)
device=$SINK
;;
*)
echo "Invalid device: $1"
echo "Valid options are 'source' and 'sink'"
exit 1
;;
esac
print_device_info() {
# The node description seems to be the most useful value here, though different values are available.
# However, we'll strip the "Analog Stereo" part.
description=$(wpctl inspect "$device" | sed -n -e 's/.*node.description = "\(.*\) Analog Stereo"/\1/p')
# The output of a muted device is something like "Volume: 0.55", so we just nab the second field.
volume=$(wpctl get-volume "$device" | awk '/Volume/ { print $2 }')
# The output of a muted device is something like "Volume: 0.55 [MUTED]", so "true" if the third field is present, "false" otherwise.
muted=$(wpctl get-volume "$device" | awk '/Volume/ { print ($3 ? "true" : "false") }')
echo "{ \"description\": \"$description\", \"volume\": $volume, \"muted\": $muted }"
}
print_device_info
pactl --format=json subscribe | grep --line-buffered $1 | while read -r event; do print_device_info; done

View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
nvidia-smi --format=csv,noheader,nounits --query-gpu=utilization.gpu,utilization.memory,temperature.gpu --loop-ms=1000 \
| sed --unbuffered -e 's/.*/[&]/' \
| jq --unbuffered --compact-output '{"gpu": .[0], "memory": .[1], "temp": .[2] }'

View File

@@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -e
handle_event() {
case $1 in
focusedmon*\
|workspace*\
|openwindow*\
|closewindow*) list_workspaces;;
esac
}
list_workspaces() {
focused=`hyprctl activeworkspace -j | jq '.id'`
active=`hyprctl monitors -j | jq 'map(select(.name == "'$monitor'")) | .[0].activeWorkspace.id'`
# Explanation
# 1. Select only workspaces on the current monitor.
# 2. Remove duplicates (might be a bug with split-monitor-workspaces
# 3. Create the output structure
# 4. Select interesting entries, ones that are focused, active or have windows
# 5. Sort
hyprctl workspaces -j | jq --compact-output --monochrome-output "
map( select( .monitor | contains(\"${monitor}\") ) ) |
reduce .[] as \$item ( []; if any( .[]; .id == \$item.id ) then . else . + [\$item] end ) |
map( { id: .id, name, active: (.id == ${active}), focused: (.id == ${focused}), has_windows: (.lastwindowtitle != \"\") } ) |
map( select (.active or .focused or .has_windows)) |
sort_by(.id)
"
}
monitor=$1
# List all workspaces once at the start
list_workspaces
# Then listen for events
socat -U - "UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while read -r event; do handle_event "$event"; done