Port system-info-WSL.sh to work when systemd is enabled
This commit is contained in:
parent
2525d437fe
commit
d852c46bc8
@ -20,10 +20,12 @@ else
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
powershell="/mnt/c/Windows/System32/WindowsPowerShell/v1.0//powershell.exe"
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
# Assumes OpenHardwareMonitor is running and emitting data to WMI so we can
|
# Assumes OpenHardwareMonitor is running and emitting data to WMI so we can
|
||||||
# access it via the Windows hosts powershell.exe.
|
# access it via the Windows hosts powershell.exe.
|
||||||
raw_cpu_temp=$(powershell.exe -NoProfile \
|
raw_cpu_temp=$($powershell -NoProfile \
|
||||||
"(Get-WmiObject -Namespace \"root/OpenHardwareMonitor\" -Query 'select Value from Sensor WHERE Identifier LIKE \"$cpu_temp_sensor\"').Value" \
|
"(Get-WmiObject -Namespace \"root/OpenHardwareMonitor\" -Query 'select Value from Sensor WHERE Identifier LIKE \"$cpu_temp_sensor\"').Value" \
|
||||||
| sed 's/\r//')
|
| sed 's/\r//')
|
||||||
cpu_temp=$(printf "%.1f°C" "$raw_cpu_temp")
|
cpu_temp=$(printf "%.1f°C" "$raw_cpu_temp")
|
||||||
@ -32,7 +34,7 @@ while true; do
|
|||||||
jq '.sysstat.hosts[0].statistics[0]["cpu-load"][1:]|.[].idle' | \
|
jq '.sysstat.hosts[0].statistics[0]["cpu-load"][1:]|.[].idle' | \
|
||||||
awk '$idle ~ /[-.0-9]*/ { printf "%s", substr("█▇▆▅▄▃▂▁ ", int($idle / 11), 1) }'`"
|
awk '$idle ~ /[-.0-9]*/ { printf "%s", substr("█▇▆▅▄▃▂▁ ", int($idle / 11), 1) }'`"
|
||||||
|
|
||||||
raw_battery=$(powershell.exe -NoProfile \
|
raw_battery=$($powershell -NoProfile \
|
||||||
"(Get-WmiObject win32_battery).EstimatedChargeRemaining" \
|
"(Get-WmiObject win32_battery).EstimatedChargeRemaining" \
|
||||||
| sed 's/\r//')
|
| sed 's/\r//')
|
||||||
if [ "" != "$raw_battery" ]; then
|
if [ "" != "$raw_battery" ]; then
|
||||||
@ -42,6 +44,6 @@ while true; do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$cpu_temp$cpu_load$battery" > $cache_file
|
echo "$cpu_temp$cpu_load$battery" > $cache_file
|
||||||
# echo -e "HTTP/1.1 200 OK\n\n$cpu_temp $cpu_load" | nc -l -k -p 8080 -q 1;
|
# echo "$(locale)" > $cache_file
|
||||||
sleep 2
|
sleep 2
|
||||||
done
|
done
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
[Unit]
|
|
||||||
Description=System Info
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
ExecStart=/home/benie/.config/tmux/system-info/system-info-Linux.sh
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=default.target
|
|
Loading…
x
Reference in New Issue
Block a user