separate out battery frontend
This commit is contained in:
		
							parent
							
								
									2cb44c6fd1
								
							
						
					
					
						commit
						2446198d70
					
				
							
								
								
									
										21
									
								
								bin/battery
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								bin/battery
									
									
									
									
									
								
							@ -1,18 +1,11 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
# adapted from other script i wrote, also in the public domain
 | 
			
		||||
if [ "$(uname)" = "Linux" ]; then
 | 
			
		||||
	# this is a dirty hack.
 | 
			
		||||
	# acpi | awk '{print $4}' will print the battery percentage,
 | 
			
		||||
	# and s/,$// strips the trailing comma.
 | 
			
		||||
	printf "%s\n" "$(acpi | awk '{print $4}' | sed 's/,$//')"
 | 
			
		||||
elif [ "$(uname)" = "NetBSD" ]; then
 | 
			
		||||
	printf "%s\n" "$(envstat -s acpibat0:charge \
 | 
			
		||||
		| sed 1,2d \
 | 
			
		||||
		| cut -d ':' -f 2 \
 | 
			
		||||
		| awk '{print $1}' \
 | 
			
		||||
		| cut -d '.' -f 1)"
 | 
			
		||||
else
 | 
			
		||||
# battery -> battery.linux battery.netbsd etc
 | 
			
		||||
subprogram="$0"."$(uname | lowercase)"
 | 
			
		||||
 | 
			
		||||
if ! command -v "$subprogram" >/dev/null 2>&1 && ! test -e "$subprogram"; then
 | 
			
		||||
	printf "%s: unsupported system\n" "$(uname)" 1>&2
 | 
			
		||||
	exit 1
 | 
			
		||||
	exit 70 # sysexits(3) EX_SOFTWARE
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
"$subprogram" | exit 70 # sysexits(3) EX_SOFTWARE
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										6
									
								
								bin/battery.linux
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										6
									
								
								bin/battery.linux
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,6 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
# this is a dirty hack.
 | 
			
		||||
# acpi | awk '{print $4}' will print the battery percentage,
 | 
			
		||||
# and s/,$// strips the trailing comma.
 | 
			
		||||
acpi | awk '{print $4}' | sed 's/,$//'
 | 
			
		||||
							
								
								
									
										7
									
								
								bin/battery.netbsd
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										7
									
								
								bin/battery.netbsd
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,7 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
envstat -s acpibat0:charge \
 | 
			
		||||
	| sed 1,2d \
 | 
			
		||||
	| cut -d ':' -f 2 \
 | 
			
		||||
	| awk '{print $1}' \
 | 
			
		||||
	| cut -d '.' -f 1
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user