bin

bin
git clone git://git.zepp.club/bin.git
Log | Files | Refs | README | LICENSE

sysm (809B)


      1 #!/bin/sh
      2 
      3 weather(){
      4   printf "weather %s\n" $(curl -s wttr.in/?format="%t") 
      5 }
      6 
      7 cpu_temp(){
      8     case $(uname -s) in 
      9         "Linux") 
     10             while IFS= read -r a; do
     11                 printf "cpu %.2sºC\n" "$a"
     12             done < "/sys/class/thermal/thermal_zone0/temp"
     13             ;;
     14 
     15         "OpenBSD") 
     16             while read -r a; do
     17                 oi=${a%%degC}
     18                 printf "cpu %.2sºC\n" "$a"
     19             done <<-EOF 
     20 $(sysctl -n hw.sensors.cpu0.temp0)
     21 EOF
     22     esac
     23 }
     24 
     25 gpu_temp(){
     26     case $(uname -s) in 
     27         "Linux") 
     28             while IFS= read -r a
     29             do
     30                 printf "gpu %.2sºC\n" "$a"
     31             done < "/sys/class/drm/card0/device/hwmon/hwmon0/temp1_input"
     32             ;;
     33 
     34         *)
     35     esac
     36 }
     37 
     38 main(){
     39     weather
     40     cpu_temp
     41     gpu_temp
     42 }
     43 
     44 main