distribution/packages/jelos/sources/scripts/jelos-info
2022-02-05 09:23:32 -05:00

77 lines
2.1 KiB
Bash
Executable file

#!/bin/bash
source /etc/os-release
### 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
###
### Fix this
V_OS=${NAME}
TEST=$(ldd /usr/bin/emulationstation | grep 64)
if [ $? == 0 ]
then
V_OSARCH="aarch64"
else
V_OSARCH="arm"
fi
V_CPUNB=$(grep -E $'^processor\t:' /proc/cpuinfo | wc -l)
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}"
V_CPUFREQ=$(( $(cat /sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq) / 1000 ))
V_CPUMAXFREQ=$(( $(cat /sys/devices/system/cpu/cpufreq/policy0/cpuinfo_max_freq) / 1000 ))
# 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
# 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]$"++)
echo "OPERATING SYSTEM: ${V_OS}"
echo "CPU: ${V_CPUMODEL1} (${V_CPUNB} Cores)"
if test -n "${TEMPE}"
then
echo "CPU TEMPERATURE: ${TEMPE}°"
fi
echo "CURRENT FREQUENCY: ${V_CPUFREQ}MHz"
echo "MAXIMUM FREQUENCY: ${V_CPUMAXFREQ}MHz"
echo "KERNEL: ${V_SYSTEM} (${V_ARCH})"
echo "OS ARCHITECTURE: ${V_OSARCH}"
echo "OS BUILD ID: ${BUILD_ID:0:7}"
if test -n "${BATT}"
then
echo "BATTERY: ${BATT}%"
fi