mirror of
				https://gitlab.com/ceda_ei/wish
				synced 2025-10-31 02:30:06 +01:00 
			
		
		
		
	Add error handling to battery.
This commit is contained in:
		| @@ -16,12 +16,17 @@ function wish_battery_set_colors() { | |||||||
|  |  | ||||||
| function wish_battery_main() { | function wish_battery_main() { | ||||||
| 	local path=/sys/class/power_supply/$WISH_BATTERY_ID | 	local path=/sys/class/power_supply/$WISH_BATTERY_ID | ||||||
| 	local battery=$(($(cat $path/charge_now) * 100 / $(cat $path/charge_full)))% | 	local battery | ||||||
|  | 	if [[ -f $path/charge_now ]]; then | ||||||
|  | 		battery=$(($(cat $path/charge_now) * 100 / $(cat $path/charge_full)))% | ||||||
| 		if [[ $(cat $path/status) == "Charging" ]] || | 		if [[ $(cat $path/status) == "Charging" ]] || | ||||||
| 			[[ $(cat $path/status) == "Full" ]]; then | 			[[ $(cat $path/status) == "Full" ]]; then | ||||||
| 			battery="$WISH_BATTERY_CHARGING $battery" | 			battery="$WISH_BATTERY_CHARGING $battery" | ||||||
| 		else | 		else | ||||||
| 			battery="$WISH_BATTERY_DISCHARGING $battery" | 			battery="$WISH_BATTERY_DISCHARGING $battery" | ||||||
| 		fi | 		fi | ||||||
|  | 	else | ||||||
|  | 		battery="$WISH_BATTERY_ID not found" | ||||||
|  | 	fi | ||||||
| 	wish_append $WISH_BATTERY_BG $WISH_BATTERY_FG " $battery " | 	wish_append $WISH_BATTERY_BG $WISH_BATTERY_FG " $battery " | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user