Port system-info-WSL.sh to work when systemd is enabled

This commit is contained in:
Kenneth Benzie 2023-05-12 22:18:56 +01:00
parent 2525d437fe
commit d852c46bc8
2 changed files with 5 additions and 11 deletions

View File

@ -20,10 +20,12 @@ else
return 1
fi
powershell="/mnt/c/Windows/System32/WindowsPowerShell/v1.0//powershell.exe"
while true; do
# Assumes OpenHardwareMonitor is running and emitting data to WMI so we can
# 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" \
| sed 's/\r//')
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' | \
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" \
| sed 's/\r//')
if [ "" != "$raw_battery" ]; then
@ -42,6 +44,6 @@ while true; do
fi
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
done

View File

@ -1,8 +0,0 @@
[Unit]
Description=System Info
[Service]
ExecStart=/home/benie/.config/tmux/system-info/system-info-Linux.sh
[Install]
WantedBy=default.target