distribution/packages/jelos/sources/scripts/jelos-info

122 lines
3.2 KiB
Text
Raw Normal View History

2022-02-05 14:23:32 +00:00
#!/bin/bash
2022-02-17 23:47:10 +00:00
source /etc/profile
2022-02-05 14:23:32 +00:00
### short version (for osd)
if test "$1" = "--short"
then
BATT=$(cat /sys/class/power_supply/{BAT,bat}*/uevent 2>/dev/null | grep -E "^POWER_SUPPLY_CAPACITY=" | sed -e s+'^POWER_SUPPLY_CAPACITY='++ | sort -rn | head -1)
DT=$(date +%H:%M)
if test -n "${BATT}"
then
echo "Battery: ${BATT}% - ${DT}"
else
echo "${DT}"
fi
exit 0
fi
###
V_CPUNB=$(grep -E $'^processor\t:' /proc/cpuinfo | wc -l)
2022-02-05 14:23:32 +00:00
V_CPUMODEL1=$(grep -E $'^model name\t:' /proc/cpuinfo | head -1 | sed -e s+'^model name\t: '++)
V_SYSTEM=$(uname -rs)
V_ARCH=$(uname -m)
[[ "$V_CPUMODEL1" ]] || V_CPUMODEL1="${HW_CPU}"
# battery
BATT=$(cat /sys/class/power_supply/{BAT,bat}*/uevent 2>/dev/null | grep -E "^POWER_SUPPLY_CAPACITY=" | sed -e s+'^POWER_SUPPLY_CAPACITY='++ | sort -rn | head -1)
# PAD Battery
for PADBAT in /sys/class/power_supply/*/device/uevent
do
# HID devices only
PADNAME=$(grep -E '^HID_NAME=' "${PADBAT}" | sed -e s+'^HID_NAME='++)
if test -n "${PADNAME}"
then
# parent of parent / uevent
BATTUEVENT=$(dirname "${PADBAT}")
BATTUEVENT=$(dirname "${BATTUEVENT}")/uevent
BATT=$(grep -E "^POWER_SUPPLY_CAPACITY=" "${BATTUEVENT}" | sed -e s+'^POWER_SUPPLY_CAPACITY='++ | sort -rn | head -1)
echo "${PADNAME}: ${BATT}%"
fi
done
declare -a CF MF
2022-02-07 01:35:15 +00:00
CNTR=0
for CPUFREQ in /sys/devices/system/cpu/cpufreq/*
do
2022-09-01 21:17:36 +00:00
if [[ "${CPUFREQ}" =~ boost ]]
then
continue
fi
2022-02-07 01:35:15 +00:00
if [ "${CNTR}" -eq 0 ]
then
2022-02-07 03:07:43 +00:00
CF+=("CURRENT FREQUENCY:")
MF+=("MAXIMUM FREQUENCY:")
2022-02-07 01:35:15 +00:00
fi
2022-09-01 21:17:36 +00:00
RELCPUS=$(cat ${CPUFREQ}/related_cpus)
if [ "${#RELCPUS}" -gt 1 ]
then
FIELD="$(cat ${CPUFREQ}/related_cpus 2>/dev/null | awk '{print $1"-"$NF}')"
else
FIELD="$(cat ${CPUFREQ}/related_cpus)"
fi
CF+=("CORES ${FIELD}: $(( $(cat ${CPUFREQ}/scaling_cur_freq | sort | tail -n 1) / 1000))MHz")
MF+=("CORES ${FIELD}: $(( $(cat ${CPUFREQ}/scaling_max_freq | sort | tail -n 1) / 1000))MHz")
2022-02-07 01:35:15 +00:00
CNTR=$(( CNTR + 1 ))
done
2022-02-05 14:23:32 +00:00
# temperature
# Unit: millidegree Celsius
TEMPE=$(cat /sys/devices/virtual/thermal/thermal_zone*/temp 2>/dev/null | sort -rn | head -1 | sed -e s+"[0-9][0-9][0-9]$"++)
2022-02-09 01:27:20 +00:00
echo "SYSTEM INFORMATION:"
2022-02-07 03:07:43 +00:00
echo "OPERATING SYSTEM: ${OS_NAME}"
2022-02-09 01:27:20 +00:00
echo "VERSION: ${OS_VERSION}"
echo "BUILD ID: ${BUILD_ID:0:7} (${BUILD_BRANCH})"
2022-07-11 23:35:08 +00:00
echo "KERNEL: ${V_SYSTEM} ($(uname -m))"
2022-02-09 01:27:20 +00:00
echo "DISK SPACE:"
echo "/storage: $(df -h /storage | awk '/dev/ {print $3"/"$2" ("$5")"}')"
echo "/storage/roms: $(df -h /storage/roms | awk '/dev/ {print $3"/"$2" ("$5")"}')"
2022-02-07 03:07:43 +00:00
if test -n "${BATT}"
then
2022-07-11 23:35:08 +00:00
echo "BATTERY INFORMATION:"
2022-02-07 03:07:43 +00:00
echo "BATTERY REMAINING: ${BATT}%"
2022-09-01 21:17:36 +00:00
BATPATH="/sys/class/power_supply/$(ls /sys/class/power_supply/ | grep -i bat | tail -n 1)"
if [ -e "${BATPATH}/health" ]
2022-02-09 01:27:20 +00:00
then
2022-09-01 21:17:36 +00:00
echo "BATTERY HEALTH: $(cat ${BATPATH}/health)"
2022-02-09 01:27:20 +00:00
fi
2022-09-01 21:17:36 +00:00
if [ -e "${BATPATH}/status" ]
2022-02-09 01:27:20 +00:00
then
2022-09-01 21:17:36 +00:00
echo "BATTERY STATE: $(cat ${BATPATH}/status)"
2022-02-09 01:27:20 +00:00
fi
2022-02-07 03:07:43 +00:00
fi
2022-02-09 01:27:20 +00:00
echo "CPU INFORMATION:"
echo "CPU: ${V_CPUMODEL1} (${V_CPUNB} Cores)"
2022-02-07 01:35:15 +00:00
if test -n "${TEMPE}"
then
echo "CPU TEMPERATURE: ${TEMPE}°"
fi
2022-02-17 23:47:10 +00:00
if [ "${DEVICE_HAS_FAN}" = "true" ]
then
FANSPEED=$(cat ${DEVICE_PWM_FAN})
if [ "${FANSPEED}" = "0" ]
then
FANSPEED="OFF"
else
FANSPEED="${FANSPEED} RPM"
fi
echo "CPU FAN: ${FANSPEED}"
fi
for C in "${CF[@]}"
do
echo ${C}
done
for M in "${MF[@]}"
do
echo ${M}
done