11#! /bin/bash
22
3- # ## full version (not on login, otherwise you can't log when OpenGL/Vulkan are out of order)
4- if test " $1 " = " --full" ; then
5- FULL_DISPLAY=1
6- else
7- FULL_DISPLAY=0
8- fi
9- # ##
3+ # #### Options selection #####
104
11- if test -z " ${DISPLAY} " ; then
12- export DISPLAY=$( getLocalXDisplay)
13- fi
5+ # ## full version (not on login, otherwise you can't log when OpenGL/Vulkan are out of order)
6+ FULL_DISPLAY=false
7+ OSD_DISPLAY=false
8+ TEMP_DEVICES=false
9+
10+ for i in " $@ " ; do
11+ i=${i,,}
12+ [ ${i} == " --full" ] && FULL_DISPLAY=true
13+ [ ${i} == " --short" ] && OSD_DISPLAY=true
14+ [ ${i} == " --temp" ] && TEMP_DEVICES=true
15+ [ ${i} == " --help" ] && { echo " $( basename $0 ) --full --short --temp --help" ; exit 0; }
16+ done
1417
18+ # ##### Functions #######
1519getCpu () {
1620 test -e " ${1} /cpufreq/scaling_max_freq" || return 0
1721
@@ -22,6 +26,30 @@ getCpu() {
2226 cat " ${CPU} /cpufreq/scaling_max_freq"
2327}
2428
29+ # ##
30+
31+ # export Display
32+ if test -z " ${DISPLAY} " ; then
33+ export DISPLAY=$( getLocalXDisplay || echo :0.0)
34+ fi
35+
36+
37+ # get temperature or sensors list by --temp arg
38+ # Unit: millidegree Celsius
39+ USER_TEMP=/userdata/system/user_temp.txt
40+ if ${TEMP_DEVICES} ; then
41+ printf " %s\t%s\t%s\n" " >Name" " |T m°C" " ||Device Path"
42+ while read TEMPS; do
43+ printf " %s\t%s\t%s\n" $( cat $( dirname $TEMPS ) /name) $( cat " $TEMPS " ) ${TEMPS}
44+ done < <( find /sys/class/hwmon/hwmon* /temp* _input /sys/devices/virtual/thermal/thermal_zone* /temp 2> /dev/null)
45+ echo ; echo " To pick a sensor manually, copy the 'Device Path' to '${USER_TEMP} '"
46+ exit 0
47+ fi
48+ # check if user setted a sensor device manually
49+ test -s ${USER_TEMP} && TEMPE=$( cat $( < $_ ) 2> /dev/null) || TEMPE=$( cat /sys/class/hwmon/hwmon* /temp* _input /sys/devices/virtual/thermal/thermal_zone* /temp 2> /dev/null)
50+ TEMPE=$( printf " %s\n" ${TEMPE} | sort -rn | head -1 | sed -e s+" [0-9][0-9][0-9]$" ++)
51+
52+
2553# Detect battery
2654BATTERY_DIR=$( ls -d /sys/class/power_supply/* {BAT,bat}* 2> /dev/null | head -1)
2755BATT=$( cat ${BATTERY_DIR} /uevent 2> /dev/null | grep -E " ^POWER_SUPPLY_CAPACITY=" | sed -e s+' ^POWER_SUPPLY_CAPACITY=' ++ | sort -rn | head -1)
@@ -60,7 +88,7 @@ if [ -n "${BATTERY_DIR}" ]; then
6088fi
6189
6290# ## short version (for osd)
63- if test " $1 " = " --short " ; then
91+ if ${OSD_DISPLAY} ; then
6492 DT=$( date +%H:%M)
6593 if test -n " ${BATT} " ; then
6694 echo " Battery: ${BATT} %${BATTREMAINING} - ${DT} "
@@ -132,9 +160,7 @@ if ! [ -z "$CPU_TDP" ]; then
132160 echo " Ryzen Mobile TDP: ${MAX_TDP} W"
133161fi
134162
135- # temperature
136- # Unit: millidegree Celsius
137- TEMPE=$( cat /sys/devices/virtual/thermal/thermal_zone* /temp /sys/class/hwmon/hwmon* /temp* _input 2> /dev/null | sort -rn | head -1 | sed -e s+" [0-9][0-9][0-9]$" ++)
163+ # output temperature if available
138164if test -n " ${TEMPE} " ; then
139165 echo " Temperature: ${TEMPE} °C"
140166fi
193219 done
194220fi
195221
196- if [[ " ${FULL_DISPLAY} " != 0 ]] ; then
222+ if ${FULL_DISPLAY} ; then
197223 # OPENGL
198224 if test " ${V_BOARD} " = " x86" -o " ${V_BOARD} " = " x86_64" ; then
199225 V_OPENGLVERSION=$( DISPLAY=$( getLocalXDisplay) glxinfo 2> /dev/null | grep -E ' ^OpenGL core profile version string:' | sed -e s+' ^OpenGL core profile version string:[ ]*' ++)
@@ -234,15 +260,15 @@ else
234260 fi
235261fi
236262
237- if [[ " ${FULL_DISPLAY} " != 0 ]] ; then
263+ if ${FULL_DISPLAY} ; then
238264 MACADDR=$( ip a | grep -b1 " $PREFSRC " | awk ' /link\/ether/ {print $3}' | sed ' s/:/-/g' )
239265 if [ -n " $MACADDR " ]; then
240266 echo " Corresponding MAC Address: $MACADDR "
241267 fi
242268fi
243269
244270# Boot information
245- if [[ " ${FULL_DISPLAY} " != 0 ]] ; then
271+ if ${FULL_DISPLAY} ; then
246272 if [ -d /sys/firmware/efi ]; then
247273 echo " UEFI Boot: Yes"
248274 if [ -x /usr/bin/mokutil ]; then
0 commit comments