sway status update

This commit is contained in:
Ludwig Lehnert 2024-03-02 13:40:32 +01:00
parent a99ca359ce
commit 6858cdb490
2 changed files with 19 additions and 2 deletions

View File

@ -193,7 +193,7 @@ bar {
# When the status_command prints a new line to stdout, swaybar updates. # When the status_command prints a new line to stdout, swaybar updates.
# The default just shows the current date and time. # The default just shows the current date and time.
status_command while ~/.config/sway/status.sh; do sleep 1; done status_command while ~/.config/sway/status.sh; do sleep 0.15; done
font "Ubuntu Mono Regular 14" font "Ubuntu Mono Regular 14"
status_padding 8 status_padding 8

View File

@ -1,9 +1,26 @@
#!/bin/sh #!/bin/sh
if [[ $(pactl get-sink-mute "@DEFAULT_SINK@") == *"yes" ]]; then
volume="Mute"
else
volume=$(pactl get-sink-volume "@DEFAULT_SINK@" | grep -Po '\d+%' | head -n 1)
fi
mem=$(free --mega | tail -2 | awk '{print s+=$3}' | tail -1 | awk '{printf "%.2f GB", $1/1000}')
cpu=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {printf "%.2f%", usage}')
bat_level=$(cat /sys/class/power_supply/BAT*/capacity) bat_level=$(cat /sys/class/power_supply/BAT*/capacity)
bat_state=$(cat /sys/class/power_supply/BAT*/status) bat_state=$(cat /sys/class/power_supply/BAT*/status)
date=$(date +'%d.%m.%Y %H:%M:%S') date=$(date +'%d.%m.%Y %H:%M:%S')
echo "$bat_level%" $bat_state "|" $date "" status="Audio $volume | CPU $cpu | RAM $mem | $bat_level% $bat_state | $date"
wifi=$(nmcli -t -f name,type connection show --active | grep wireless | cut -d\: -f1)
if [[ -n $wifi ]]; then
status="$wifi | $status"
fi
echo $status