mirror of
				https://github.com/tiyn/dotfiles.git
				synced 2025-10-30 12:01:16 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			61 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			61 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/bin/sh
 | |
| 
 | |
| acpi=$(acpi -b)
 | |
| 
 | |
| if [ "$acpi" = "" ]; then
 | |
|     echo ""
 | |
|     return
 | |
| fi
 | |
| 
 | |
| total=$(echo $acpi | sed 's/.*:\ //')
 | |
| 
 | |
| status="$(echo $total | cut -d',' -f1)"
 | |
| capacity="$(echo $total | cut -d',' -f2 | sed 's/%//')"
 | |
| 
 | |
| if [ "$status" = "Discharging" ] && [ $capacity -le 15 ] ; then
 | |
|         notify-send -u critical "Battery" "Below 15%"
 | |
| fi
 | |
| 
 | |
| if [ $capacity -gt 40 ]
 | |
| then
 | |
|     color="^b#282828^^c#dfdfdf^"
 | |
| elif [ $capacity -gt 20 ]
 | |
| then
 | |
|     color="^b#282828^^c#ffff00^"
 | |
| else
 | |
|     color="^b#282828^^c#ff0000^"
 | |
| fi
 | |
| 
 | |
| case "$status" in
 | |
|     "Discharging")
 | |
|         if [ $capacity -gt 75 ]
 | |
|         then
 | |
|             icon=""
 | |
|         elif [ $capacity -gt 60 ]
 | |
|         then
 | |
|             icon=""
 | |
|         elif [ $capacity -gt 40 ]
 | |
|         then
 | |
|             icon=""
 | |
|         elif [ $capacity -gt 20 ]
 | |
|         then
 | |
|             icon=""
 | |
|         else
 | |
|             icon=""
 | |
|         fi
 | |
|         ;;
 | |
|     "Not charging")
 | |
|         icon="";;
 | |
|     "Charging")
 | |
|         icon="";;
 | |
|     "Unknown")
 | |
|         icon="";;
 | |
|     "Full")
 | |
|         icon="⚡";;
 | |
| esac
 | |
| 
 | |
| capacity=$(echo "$capacity" | sed -e 's/$//')
 | |
| capacity=$(printf %3s $capacity | tr ' ' ' ')
 | |
| 
 | |
| echo "$color $icon ^d^"
 |