diff --git a/sway-config b/sway-config index a519348..23be42b 100644 --- a/sway-config +++ b/sway-config @@ -193,7 +193,7 @@ bar { # When the status_command prints a new line to stdout, swaybar updates. # 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" status_padding 8 diff --git a/sway-status.sh b/sway-status.sh index 5e4e214..faf1313 100755 --- a/sway-status.sh +++ b/sway-status.sh @@ -1,9 +1,26 @@ #!/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_state=$(cat /sys/class/power_supply/BAT*/status) 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