z_mirror/dotfiles
git clone https://git.raiguard.me/z_mirror/dotfiles
81df58c
noctalia
1#!/bin/sh 2 3red ="#f7768e" 4green ="#9ece6a" 5yellow ="#e0af68" 6orange ="#ff9e64" 7blue ="#7aa2f7" 8magenta ="#bb9af7" 9cyan ="#7dcfff" 10 11hwmon =$( find /sys/class/drm/card1/device/hwmon -type d -name hwmon[0-9]) 12 13while true ;do 14# CPU info 15cpuusage =$( mpstat 1 1 | awk '/M all/ { printf "%.1f%%", 100 - $13 }' ) 16cputemp =$( sensors | awk ' 17/Package/ { printf "%.0f°C\n", substr($4, 2, length($4) - 3) } 18/Tdie/ { printf "%.0f°C\n", substr($2, 2, length($2) - 2) } 19' | head -1 ) 20if [ -n" $ cputemp " ];then 21cputemp =" $ cputemp " 22fi 23cpu ="<span foreground=' $ magenta '> $ cpuusage $ cputemp </span> " 24 25# RAM info 26used =$( free | awk '/Mem/ { printf "%.2f \n", $3/1024/1024 }' ) 27ram ="<span foreground=' $ cyan '> ${ used } GB</span> " 28 29# Network 30ssid =$( nmcli connection show --active | grep wifi | cut -f 1 -d " " ) 31if [ -n" $ ssid " ];then 32network ="<span foreground=' $ blue '> $ ssid </span> " 33else 34network ="" 35fi 36 37# GPU 38if [" $ HOSTNAME " ="tantal" ];then 39gpubusy =$( cat "/sys/class/drm/card1/device/gpu_busy_percent" ) 40gputemp =$( cat " $ hwmon /temp1_input" ) 41gputemp =$( expr $ gputemp / 1000) 42gpu ="<span foreground=' $ red '> $ gpubusy % $ gputemp °C</span> " 43fi 44 45# Do-not-disturb 46if $( makoctl mode | grep -q "do-not-disturb" ) ;then 47dnd ="<span foreground=' $ orange '>DND</span> " 48fi 49 50# Battery info 51if [" $ HOSTNAME " ="uraya" ];then 52# Pen tablet 53tablet_path =$( upower -d | grep Device: | grep wacom_battery \ 54| awk '{ print $2 }' ) 55if [ -n" $ tablet_path " ];then 56tablet_info =$( upower -i " $ tablet_path " ) 57tablet_color =$ green 58tablet_charge =$( echo " $ tablet_info " | grep percentage \ 59| awk '{ print $2 }' | sed "s/%//" ) 60if [" $ tablet_charge " -lt 21 ];then 61tablet_color =$ red 62fi 63tablet_status =$( echo " $ tablet_info " | grep "power supply" \ 64| awk '/yes/ { print "+" }' ) 65tablet_bat ="<span foreground=' $ tablet_color '>T: $ tablet_status $ tablet_charge %</span> " 66else 67tablet_bat ="" 68fi 69# Laptop 70bat_color =$ green 71bat_status =$( cat /sys/class/power_supply/BAT1/status \ 72| awk '/Charging/ { print "+" }' ) 73bat_charge =$( cat /sys/class/power_supply/BAT1/capacity) 74if [" $ bat_charge " -lt 21 ];then 75bat_color =$ red 76fi 77# Wattage 78bat_wattage =$( echo - | awk "{printf \"%.1f\", \ 79$(( \ 80$( cat /sys/class/power_supply/BAT1/current_now) * \ 81$( cat /sys/class/power_supply/BAT1/voltage_now) \ 82)) / 1000000000000 }" ) 83bat =" $ tablet_bat <span foreground=' $ bat_color '> $ bat_status $ bat_charge % $ bat_wattage W</span> " 84fi 85date =$( date + '%a %b %d' ) 86if [$( date +%Z) !="CEST" ];then 87prague =" $( TZ =Europe/Prague date + '%-H:%M %Z' ) " 88fi 89local =$( date + "%-H:%M %Z" ) 90echo " $ cpu $ ram $ gpu $ dnd $ bat $ network $ date $ prague $ local " 91done