dotfiles/home/dot_config/sway/scripts/executable_status.sh.tmpl

50 lines
1.9 KiB
Cheetah

# The Sway configuration file in ~/.config/sway/config calls this script.
# You should see changes to the status bar after saving this script.
# Uptime
uptime_formatted=$(uptime | awk -F'( |,|:)+' '{d=h=m=0; if ($7=="min") m=$6; else {if ($7~/^day/) {d=$6;h=$8;m=$9} else {h=$6;m=$7}}} {print d+0,"days,",h+0,"hours,",m+0,"minutes"}')
# Date
date_formatted=$(date "+%a %F %H:%M")
# Kernel Version
linux_version=$(uname -r)
# Gamemode status
status=$(gamemoded -s)
if [ "$status" == "gamemode is inactive" ]; then
gamemode=🧊
else
gamemode=🔥
fi
# Volume
sink=$(pactl list short sinks | grep 'RUNNING\|IDLE' | awk '{print $1}')
#sink=$( pactl list short sinks | sed -e 's,^\([0-9][0-9]*\)[^0-9].*,\1,' | head -n 2 | tail -n 1)
volume=$( pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( $sink + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' )
mute=$(pactl list sinks | grep '^[[:space:]]Mute:' | head -n $(( $sink + 1 )) | tail -n 1 | awk '{print $2}')
if [ "$mute" == "yes" ]; then
volume_color='#f92672'
else
volume_color='#ffffff'
fi
#bluetooth=$(bluetoothctl devices | cut -f2 -d' ' | while read uuid; do bluetoothctl info $uuid; done | grep -e "Name\|Connected: yes" | grep -B1 "yes" | head -n 1 | cut -d\ -f2-)
bluetooth="🫐"
# Network usage
r1=`cat /sys/class/net/{{ .network_interface }}/statistics/rx_bytes`
t1=`cat /sys/class/net/{{ .network_interface }}/statistics/tx_bytes`
sleep 1
r2=`cat /sys/class/net/{{ .network_interface }}/statistics/rx_bytes`
t2=`cat /sys/class/net/{{ .network_interface }}/statistics/tx_bytes`
tx=`expr $t2 - $t1`
rx=`expr $r2 - $r1`
txmb=$(echo "scale = 1; $tx / 1280000" | bc | awk '{printf "%05.1f\n", $0}')
rxmb=$(echo "scale = 1; $rx / 1280000" | bc | awk '{printf "%05.1f\n", $0}')
#<span foreground='#c16b26'>lel</span>
echo -e "👍 $txmb 👎 $rxmb | ⬆️ $uptime_formatted | 🔉<span foreground='$volume_color'>$volume%</span> | $gamemode | 🐧 $linux_version | $date_formatted "