configs/sway/status.sh
sway/status.shRaw
1# sway config at ~/.config/sway/config calls this script, through line:
2# status_command while ~/.config/sway/status.sh; do sleep 1; done
3# Changes should be applied when saving this script, if not, use
4# "killall swaybar" and $mod+Shift+c to reload the configuration.
5
6uptime_formatted=$(uptime | cut -d ',' -f1 | cut -d ' ' -f4,5)
7
8temp_raw=$(cat /sys/class/thermal/thermal_zone0/temp)
9temp=$(($temp_raw / 1000))
10
11volume=$(pactl get-sink-volume @DEFAULT_SINK@ | awk '{print $5}')
12muted=$(pactl get-sink-mute @DEFAULT_SINK@ | awk '{print $2}')
13# if [ "$MUTED" = "yes" ]; then // TODO
14# echo "π Muted"
15# else
16# echo "π $VOLUME"
17# fi
18
19battery_status=$(cat /sys/class/power_supply/BAT0/status) # "Full", "Discharging", or "Charging"
20battery_capacity=$(cat /sys/class/power_supply/BAT0/capacity) # %
21
22# date and time format: Tue 2025-08-19 22:37
23datetime=$(date "+%a %F %H:%M:%S")
24
25interface=$(ip route get 8.8.8.8 | awk -F'dev ' 'NR==1{split($2,a," ");print a[1]}')
26ip=$(ip addr show dev $interface | grep 'inet ' | awk '{print $2}' | cut -d'/' -f1)
27wifi_name=$(nmcli -g GENERAL.CONNECTION dev show "$interface")
28
29
30
31avail_space=$(df -h / | awk 'NR==2 {print $4}')
32
33
34
35
36# π π» π‘ π β‘ π \| π§ π π
37echo $avail_space \| $tempΒ°C \| $uptime_formatted \| vol: $volume $muted \| $battery_status $battery_capacity% \| $wifi_name \| $interface $ip \| $datetime