This commit is contained in:
2025-05-03 01:16:02 +02:00
parent 4364cc2d16
commit 0f9f16c8b6
31 changed files with 529 additions and 296 deletions

View File

@@ -0,0 +1,14 @@
bat=$(cat /sys/class/power_supply/BAT0/capacity)
stat=$(cat /sys/class/power_supply/BAT0/status)
class="batteryFull"
if [[ $stat == "Charging" ]]; then
class="batteryCharging"
elif [[ $bat -le 10 ]]; then
class="batteryEmpty"
elif [[ $bat -le 80 ]]; then
class="batteryHalf"
fi
echo "$class"

View File

@@ -0,0 +1,16 @@
bat=$(cat /sys/class/power_supply/BAT0/capacity)
stat=$(cat /sys/class/power_supply/BAT0/status)
icon=""
if [[ $stat == "Charging" ]]; then
icon=""
elif [[ $bat -le 10 ]]; then
icon=""
elif [[ $bat -le 50 ]]; then
icon=""
elif [[ $bat -le 80 ]]; then
icon=""
fi
echo "$icon"

View File

@@ -0,0 +1,2 @@
bat=$(cat /sys/class/power_supply/BAT0/capacity)
echo "$bat"

View File

@@ -0,0 +1,5 @@
cpu_idle=$(top -bn1 | awk '/Cpu\(s\)/ {print $8}')
cpu_used=$(awk "BEGIN {print 100 - $cpu_idle}")
# Print only the numeric result
printf "%.0f\n" "$cpu_used"

View File

@@ -0,0 +1,6 @@
mem_info=$(free | grep Mem)
used=$(echo "$mem_info" | awk '{print $3}')
total=$(echo "$mem_info" | awk '{print $2}')
mem_used=$(awk "BEGIN {print int($used/$total * 100)}")
echo "$mem_used"

View File

@@ -0,0 +1,5 @@
if pactl get-source-mute @DEFAULT_SOURCE@ | grep -q "yes"; then
echo "micOff"
else
echo "micOn"
fi

View File

@@ -0,0 +1,5 @@
if pactl get-source-mute @DEFAULT_SOURCE@ | grep -q "yes"; then
echo "󰍭" # muted
else
echo "󰍬" # unmuted
fi

View File

@@ -0,0 +1,11 @@
# You can change this if your interface is named differently (e.g., eth0, enp3s0)
INTERFACE=$(ip route get 1.1.1.1 | awk '{print $5; exit}')
RX_PREV=$(cat /sys/class/net/$INTERFACE/statistics/rx_bytes)
sleep 1
RX_CUR=$(cat /sys/class/net/$INTERFACE/statistics/rx_bytes)
# Calculate download/upload in KiB/s
RX_RATE=$(((RX_CUR - RX_PREV) / 1024))
# Output formatted for Eww
echo "${RX_RATE}"

View File

@@ -0,0 +1,8 @@
# You can change this if your interface is named differently (e.g., eth0, enp3s0)
INTERFACE=$(ip route get 1.1.1.1 | awk '{print $5; exit}')
TX_PREV=$(cat /sys/class/net/$INTERFACE/statistics/tx_bytes)
sleep 1
TX_CUR=$(cat /sys/class/net/$INTERFACE/statistics/tx_bytes)
TX_RATE=$(((TX_CUR - TX_PREV) / 1024))
echo "${TX_RATE}"

View File

@@ -0,0 +1,8 @@
mute=$(pactl get-sink-mute @DEFAULT_SINK@ | awk '{print $2}')
volume=$(pactl get-sink-volume @DEFAULT_SINK@ | awk '{print $5}' | tr -d '%')
if [[ "$mute" == "yes" ]]; then
echo "speakerOff" # muted icon
else
echo "speakerOn" # high volume
fi

View File

@@ -0,0 +1,10 @@
mute=$(pactl get-sink-mute @DEFAULT_SINK@ | awk '{print $2}')
volume=$(pactl get-sink-volume @DEFAULT_SINK@ | awk '{print $5}' | tr -d '%')
if [[ "$mute" == "yes" ]]; then
echo "" # muted icon
elif [[ "$volume" -le 100 ]]; then
echo "" # low volume
else
echo "" # high volume
fi

View File

@@ -0,0 +1,4 @@
volume=$(pactl get-sink-volume @DEFAULT_SINK@ | awk '{print $5}' | tr -d '%')
half_volume=$((volume / 2))
echo "$half_volume"

View File

@@ -1,4 +0,0 @@
tail -F /tmp/xmonad-eww-log | while read -r line; do
clean_line=$(echo "$line" | sed -E 's/<[^>]+>//g')
eww update xmonad_log="$clean_line"
done

View File

@@ -0,0 +1,19 @@
line=$(cat /tmp/xmonad-eww-log)
IFS='|' read -r workspaces 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
# Windows
echo "${windows}"