summaryrefslogtreecommitdiff
path: root/polybar-temp-autofix.sh
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2024-06-26 23:21:56 +0800
committerlittleblack111 <littleblack11111@gmail.com>2024-06-26 23:21:56 +0800
commitbe2213feb06bcba11fe71241c30d10f89f4b44f1 (patch)
treee4e1b28f1379c98b3427a8948606d45b0be46943 /polybar-temp-autofix.sh
parentea79ffef6e18f74fd995d665a46b84abc5299c52 (diff)
implified the script using wildcard instead of doing it manually
Diffstat (limited to 'polybar-temp-autofix.sh')
-rwxr-xr-xpolybar-temp-autofix.sh50
1 files changed, 12 insertions, 38 deletions
diff --git a/polybar-temp-autofix.sh b/polybar-temp-autofix.sh
index 642b458..cdf552c 100755
--- a/polybar-temp-autofix.sh
+++ b/polybar-temp-autofix.sh
@@ -1,44 +1,18 @@
-#!/usr/bin/bash
-if [[ -e /sys/devices/platform/coretemp.0/hwmon/hwmon5 && $(grep -i "hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon4/temp1_input" /home/system/.config/polybar/modules.ini) ]]; then
- printf "fixing hwmon4 to hwmon5\n"
- sed -i 's#hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon4/temp1_input#hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon5/temp1_input#g' /home/system/.config/polybar/modules.ini
+#!/bin/bash
+
+if [[ -e /sys/devices/platform/coretemp.0/hwmon/hwmon4 ]]; then
+ printf "fixing hwmon* to hwmon4\n"
+ sed -i 's#hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon.*/temp1_input#hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon4/temp1_input#g' $HOME/.config/polybar/modules.ini
exit 0
-elif [[ -e /sys/devices/platform/coretemp.0/hwmon/hwmon4 && $(grep -i "hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon5/temp1_input" /home/system/.config/polybar/modules.ini) ]]; then
- printf "fixing hwmon5 to hwmon4\n"
- sed -i 's#hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon5/temp1_input#hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon4/temp1_input#g' /home/system/.config/polybar/modules.ini
+elif [[ -e /sys/devices/platform/coretemp.0/hwmon/hwmon3 ]]; then
+ printf "fixing hwmon* to hwmon3\n"
+ sed -i 's#hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon.*/temp1_input#hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp1_input#g' $HOME/.config/polybar/modules.ini
exit 0
-elif [[ -e /sys/devices/platform/coretemp.0/hwmon/hwmon3 && $(grep -i "hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon4/temp1_input" /home/system/.config/polybar/modules.ini) ]]; then
- printf "fixing hwmon4 to hwmon3\n"
- sed -i 's#hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon4/temp1_input#hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp1_input#g' /home/system/.config/polybar/modules.ini
- exit 0
-elif [[ -e /sys/devices/platform/coretemp.0/hwmon/hwmon3 && $(grep -i "hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon5/temp1_input" /home/system/.config/polybar/modules.ini) ]]; then
- printf "fixing hwmon5 to hwmon3\n"
- sed -i 's#hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon5/temp1_input#hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp1_input#g' /home/system/.config/polybar/modules.ini
- exit 0
-elif [[ -e /sys/devices/platform/coretemp.0/hwmon/hwmon3 && $(grep -i "hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon6/temp1_input" /home/system/.config/polybar/modules.ini) ]]; then
- printf "fixing hwmon6 to hwmon3\n"
- sed -i 's#hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon6/temp1_input#hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp1_input#g' /home/system/.config/polybar/modules.ini
- exit 0
-elif [[ -e /sys/devices/platform/coretemp.0/hwmon/hwmon3 && $(grep -i "hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon7/temp1_input" /home/system/.config/polybar/modules.ini) ]]; then
- printf "fixing hwmon7 to hwmon3\n"
- sed -i 's#hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon7/temp1_input#hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp1_input#g' /home/system/.config/polybar/modules.ini
- exit 0
-elif [[ -e /sys/devices/platform/coretemp.0/hwmon/hwmon5 && $(grep -i "hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon5/temp1_input" /home/system/.config/polybar/modules.ini) ]]; then
- printf "hwmon5 is already set\n"
- exit 0
-elif [[ -e /sys/devices/platform/coretemp.0/hwmon/hwmon4 && $(grep -i "hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon4/temp1_input" /home/system/.config/polybar/modules.ini) ]]; then
- printf "hwmon4 is already set\n"
- exit 0
-elif [[ -e /sys/devices/platform/coretemp.0/hwmon/hwmon3 && $(grep -i "hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon3/temp1_input" /home/system/.config/polybar/modules.ini) ]]; then
- printf "hwmon3 is already set\n"
- exit 0
-elif [[ -e /sys/devices/platform/coretemp.0/hwmon/hwmon6 && $(grep -i "hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon6/temp1_input" /home/system/.config/polybar/modules.ini) ]]; then
- printf "hwmon6 is already set\n"
- exit 0
-elif [[ -e /sys/devices/platform/coretemp.0/hwmon/hwmon7 && $(grep -i "hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon7/temp1_input" /home/system/.config/polybar/modules.ini) ]]; then
- printf "hwmon7 is already set\n"
+elif [[ -e /sys/devices/platform/coretemp.0/hwmon/hwmon5 ]]; then
+ printf "fixing hwmon* to hwmon5\n"
+ sed -i 's#hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon.*/temp1_input#hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon5/temp1_input#g' $HOME/.config/polybar/modules.ini
exit 0
else
- printf "ERROR had occured\n"
+ printf "ERROR had occurred\n"
exit 1
fi