From db2199c05bee05dc46a066f5c239f76ecca7da0d Mon Sep 17 00:00:00 2001 From: BitHeaven-Official Date: Thu, 2 Mar 2023 14:37:56 +0500 Subject: [PATCH] update scripts --- .local/scripts/status/.0183_0_backlight | 18 ++++++++++++++++ .local/scripts/status/0010_1_network | 28 +++++-------------------- .local/scripts/status/0030_0_cpu | 4 +++- .local/scripts/status/0035_1_cputemp | 24 +++++++++++++++++++++ .local/scripts/status/0040_1_wifi | 2 +- .local/scripts/status/0185_10_bat | 21 ++++++++++--------- 6 files changed, 62 insertions(+), 35 deletions(-) create mode 100755 .local/scripts/status/.0183_0_backlight create mode 100755 .local/scripts/status/0035_1_cputemp diff --git a/.local/scripts/status/.0183_0_backlight b/.local/scripts/status/.0183_0_backlight new file mode 100755 index 0000000..02a4fad --- /dev/null +++ b/.local/scripts/status/.0183_0_backlight @@ -0,0 +1,18 @@ +#!/bin/bash + +DEVICE="amdgpu_bl0" + +COLOR1="#FFF400" +COLOR2="#A39C00" + + +if [ ! -f "$FILE" ] +then + DEVICE="$(ls /sys/class/backlight/ -1 -t | head -1)" +fi + +curr="$(cat /sys/class/backlight/$DEVICE/brightness)" +max="$(cat /sys/class/backlight/$DEVICE/max_brightness)" + +echo "^b$COLOR1^^c$COLOR2^  ^c$COLOR1^^b$COLOR2^ $curr/$max ^d^" + diff --git a/.local/scripts/status/0010_1_network b/.local/scripts/status/0010_1_network index 2b50e49..7c9f399 100755 --- a/.local/scripts/status/0010_1_network +++ b/.local/scripts/status/0010_1_network @@ -1,6 +1,6 @@ #!/bin/bash -DEVICE=wlan0 +DEVICE=wlp2s0 COLOR1="#FF9B00" COLOR2="#A16200" @@ -16,8 +16,7 @@ done if [ $good -eq 0 ] then - echo "Change DEVICE in ~/.local/scripts/0010_1_network" - grep ":" /proc/net/dev | awk -F: '{print $1}' | sed s@\ @@g + echo "0010" exit 1 fi @@ -47,25 +46,8 @@ TXNET_BIT=`echo $line | awk '{print $9}'` echo $RXNET_BIT > $HOME/.local/tmp/.tmp_RXNET_BIT echo $TXNET_BIT > $HOME/.local/tmp/.tmp_TXNET_BIT -if [ $inbound -gt $((1024*1024)) ] -then - inb=$(printf "%.2f MB/s" $(echo "scale=2; $inbound / 1024 / 1024" | bc)) -elif [ $inbound -gt 1024 ] -then - inb=$(printf "%.2f KB/s" $(echo "scale=2; $inbound / 1024" | bc)) -else - inb=$(printf "%i B/s" $inbound) -fi +inb=$(printf "%.0f MB/s" $(echo "scale=2; $inbound / 1024 / 1024" | bc)) -if [ $outbound -gt $((1024*1024)) ] -then - outb=$(printf "%.2f MB/s" $(echo "scale=2; $outbound / 1024 / 1024" | bc)) -elif [ $outbound -gt 1024 ] -then - outb=$(printf "%.2f KB/s" $(echo "scale=2; $outbound / 1024" | bc)) -else - outb=$(printf "%i B/s" $outbound) -fi +outb=$(printf "%.0f MB/s" $(echo "scale=2; $outbound / 1024 / 1024" | bc)) - -echo "^c$COLOR1^^b$COLOR2^ In: $inb ^b$COLOR1^^c$COLOR2^  ^c$COLOR1^^b$COLOR2^ Out: $outb ^d^" +echo "^c$COLOR1^^b$COLOR2^ $inb ^b$COLOR1^^c$COLOR2^  ^c$COLOR1^^b$COLOR2^ $outb ^d^" diff --git a/.local/scripts/status/0030_0_cpu b/.local/scripts/status/0030_0_cpu index 4cea157..718c245 100755 --- a/.local/scripts/status/0030_0_cpu +++ b/.local/scripts/status/0030_0_cpu @@ -3,6 +3,8 @@ COLOR1="#990057" COLOR2="#FF00B2" -usage=$(cat <(grep 'cpu ' /proc/stat) <(sleep 1 && grep 'cpu ' /proc/stat) | awk -v RS="" '{print ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}' | cut -d'.' -f1)"%" +load1="$(grep 'cpu ' /proc/stat)" +load2="$(sleep 1 && grep 'cpu ' /proc/stat)" +usage=$(echo "$load1 \n $load2" | awk -v RS="" '{print ($13-$2+$15-$4)*100/($13-$2+$15-$4+$16-$5)}' | cut -d'.' -f1)"%" echo "^c$COLOR1^^b$COLOR2^  ^b$COLOR1^^c$COLOR2^ $usage ^d^" diff --git a/.local/scripts/status/0035_1_cputemp b/.local/scripts/status/0035_1_cputemp new file mode 100755 index 0000000..3c55ea9 --- /dev/null +++ b/.local/scripts/status/0035_1_cputemp @@ -0,0 +1,24 @@ +#!/bin/bash + +COLOR1="#AE8BF9" +COLOR2="#773DF5" + +cputemp=$(($(cat /sys/class/thermal/thermal_zone0/temp) / 1000)) + +if [ $cputemp -ge 90 ] +then + tempicon="" +elif [ $cputemp -ge 75 ] +then + tempicon="" +elif [ $cputemp -ge 60 ] +then + tempicon="" +elif [ $cputemp -ge 45 ] +then + tempicon="" +else + tempicon="" +fi + +echo "^b$COLOR1^^c$COLOR2^ $tempicon ^c$COLOR1^^b$COLOR2^ $cputemp ^d^" diff --git a/.local/scripts/status/0040_1_wifi b/.local/scripts/status/0040_1_wifi index 17eb124..bf9fb54 100755 --- a/.local/scripts/status/0040_1_wifi +++ b/.local/scripts/status/0040_1_wifi @@ -6,7 +6,7 @@ COLOR2="#005083" power=$(nmcli -f IN-USE,SIGNAL,SSID device wifi | grep "*" | cut -d' ' -f8) name=$(nmcli -f IN-USE,SIGNAL,SSID device wifi | grep "*" | cut -d' ' -f14) -if [[ ! $name ]] +if [ ! $name ] then echo "^b$COLOR1^^c$COLOR2^  ^c$COLOR1^^b$COLOR2^  ^d^" else diff --git a/.local/scripts/status/0185_10_bat b/.local/scripts/status/0185_10_bat index 201e247..e17763a 100755 --- a/.local/scripts/status/0185_10_bat +++ b/.local/scripts/status/0185_10_bat @@ -1,40 +1,41 @@ #!/bin/bash -DEVICE="BAT1" +DEVICE="BAT0" COLOR1="#FF00F4" COLOR2="#83007D" -if [ ! -f "$FILE" ] +if [ ! -f "/sys/class/power_supply/$DEVICE/capacity" ] then - DEVICE="$(ls /sys/class/power_supply/ -1 -t | head -1)" + echo "0185" + exit 1 fi batpercent="$(cat /sys/class/power_supply/$DEVICE/capacity)" -if [[ $((batpercent + 0)) -ge 80 ]] +if [ $batpercent -ge 80 ] then icon="" -elif [[ $((batpercent + 0)) -ge 60 ]] +elif [ $batpercent -ge 60 ] then icon="" -elif [[ $((batpercent + 0)) -ge 40 ]] +elif [ $batpercent -ge 40 ] then icon="" -elif [[ $((batpercent + 0)) -ge 20 ]] +elif [ $batpercent -ge 20 ] then icon="" else icon="" fi -chrg=$(cat /sys/class/power_supply/$DEVICE/status) +chrg="$(cat /sys/class/power_supply/$DEVICE/status)" -if [[ "$chrg" == "Charging" ]] +if [ "$chrg" = "Charging" ] then icon="" -elif [[ "$chrg" == "Full" ]] +elif [ "$chrg" = "Full" ] then icon="" fi