sea
June 1, 2020, 3:39pm
21
Lol you're right.
I havent looked that closely at the script anymore - because it seems to work
But, if i adjust the code, it wont work as expected.
[~/prjs/SWARM] 0 $ DATA_RAW=$(LC_ALL=C acpi)
[~/prjs/SWARM] 0 $ echo "$DATA_RAW" | awk -v IFS="," '{print $3}' | tr -d ','
Discharging
[~/prjs/SWARM] 0 $ echo "$DATA_RAW" | awk -v FS="," '{print $3}' | tr -d ','
discharging at zero rate - will never fully discharge.
I think the issue here is the DATA_RAW input, which has no further ',' after 'discharging', so using the proper FS, will make the the 3rd field 'too long' as it wont limit it to words anymore.
Thus actualy removing the requirement for FS=", " alltogether!
Why did I add that FS though....
1 Like
swoe
June 3, 2020, 12:16am
22
Wrote several scripts over the past week or so & I've finally got one that works.. Here's the code....
#!/usr/bin/env bash
set -x
while true
do
export DISPLAY=:0.0
battery=$(acpi -b | grep -P -o '[0-9]+(?=%)')
echo $battery
if [[ $battery -eq 100 ]]; then
notify-send -i "/usr/share/icons/Arc-X-P/panel/22/battery-full-charged.svg" "Battery Charged" "Level: ${battery}%"
elif [[ $battery -le 22 ]]; then
yad --no-buttons --center --borders=22 --timeout=22 --title="BATTERY LOW. PLEASE PLUG IN CHARGER...." --image /home/furycd001/Terminal/Selena\ Gomez/batterylow.jpg
fi
sleep 2m
done
1 Like
system
Closed
August 2, 2020, 12:20am
23
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.