free data(1) from test(1)
This commit is contained in:
		
							parent
							
								
									14045fdc92
								
							
						
					
					
						commit
						370857104a
					
				
							
								
								
									
										45
									
								
								data/data
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								data/data
									
									
									
									
									
								
							@ -19,16 +19,8 @@ DELIMITER=" || "
 | 
			
		||||
# not an integer)
 | 
			
		||||
INTERVAL=1
 | 
			
		||||
 | 
			
		||||
# this URL will have in plain text the public IP address from which it was
 | 
			
		||||
# accessed
 | 
			
		||||
#PUBLIC_IP_FETCH_URL="http://ifconfig.io/"
 | 
			
		||||
#PUBLIC_IP_FETCH_URL="https://ifconfig.io"
 | 
			
		||||
#PUBLIC_IP_FETCH_URL="http://icanhazip.com"
 | 
			
		||||
PUBLIC_IP_FETCH_URL="https://icanhazip.com"
 | 
			
		||||
PUBLIC_IP6_FETCH_URL="$PUBLIC_IP_FETCH_URL"
 | 
			
		||||
 | 
			
		||||
get_cpu_temp() {
 | 
			
		||||
	if [ "$(uname)" = "Linux" ]; then
 | 
			
		||||
	if streq "$(uname)" "Linux"; then
 | 
			
		||||
		RETVAL=""
 | 
			
		||||
		# iterate over files, adjust, print out "%dC "
 | 
			
		||||
		for file in $CPU_TEMP_FILES;
 | 
			
		||||
@ -40,7 +32,7 @@ get_cpu_temp() {
 | 
			
		||||
		printf "%b" "$RETVAL" \
 | 
			
		||||
			| python -c "from sys import stdin; print(stdin.read().rstrip() + '\n')"
 | 
			
		||||
		return
 | 
			
		||||
	elif [ "$(uname)" = "NetBSD" ]; then
 | 
			
		||||
	elif streq "$(uname)" "NetBSD"; then
 | 
			
		||||
		printf "%bC" "$(envstat -s coretemp0:'cpu0 temperature' \
 | 
			
		||||
			| sed 1,2d \
 | 
			
		||||
			| cut -d ':' -f 2 \
 | 
			
		||||
@ -55,19 +47,19 @@ get_cpu_temp() {
 | 
			
		||||
get_current_desktop() {
 | 
			
		||||
	LASTDESKTOP="$DESKTOP"
 | 
			
		||||
	case "$WM" in
 | 
			
		||||
	(bspwm) 
 | 
			
		||||
	bspwm) 
 | 
			
		||||
		DESKTOP="$(bspc query -D -d focused --names 2>/dev/null)" ;;
 | 
			
		||||
		
 | 
			
		||||
	esac || DESKTOP=""
 | 
			
		||||
	printf "[%s] " "$DESKTOP"
 | 
			
		||||
	if test -n "$LASTDESKTOP" && ! test -n "$DESKTOP"; then
 | 
			
		||||
	if str isvalue "$LASTDESKTOP" && ! str isvalue "$DESKTOP"; then
 | 
			
		||||
		# X is kill
 | 
			
		||||
		exit 0
 | 
			
		||||
	fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
get_memory_usage() {
 | 
			
		||||
	if [ "$(uname)" = "Linux" ]; then
 | 
			
		||||
	if streq "$(uname)" "Linux"; then
 | 
			
		||||
		printf "%b" \
 | 
			
		||||
			"$(free | head -n 2 | tail -n 1 \
 | 
			
		||||
				| awk '{print $3 " used / " $2 " total"}')"
 | 
			
		||||
@ -75,24 +67,7 @@ get_memory_usage() {
 | 
			
		||||
	fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
get_public_ip() {
 | 
			
		||||
	PUBLIC_IP4="$(curl -4 --connect-timeout 5 "$PUBLIC_IP_FETCH_URL" --no-progress-meter 2>/dev/null \
 | 
			
		||||
		|| printf "-1")"
 | 
			
		||||
	PUBLIC_IP6="$(curl -6 --connect-timeout 5 "$PUBLIC_IP6_FETCH_URL" --no-progress-meter 2>/dev/null \
 | 
			
		||||
		|| printf "-1")"
 | 
			
		||||
	if [ "$PUBLIC_IP4" = "-1" ] && [ "$PUBLIC_IP6" = "-1" ]; then
 | 
			
		||||
		printf "[error fetching address]"
 | 
			
		||||
	elif [ "$PUBLIC_IP4" = "-1" ]; then
 | 
			
		||||
		printf "%b" "$PUBLIC_IP6"
 | 
			
		||||
	elif [ "$PUBLIC_IP6" = "-1" ]; then
 | 
			
		||||
		printf "%b" "$PUBLIC_IP4"
 | 
			
		||||
	else
 | 
			
		||||
		printf "%b / %b" "$PUBLIC_IP4" "$PUBLIC_IP6"
 | 
			
		||||
	fi
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
PUBLIC_IP="$(get_public_ip)"
 | 
			
		||||
PUBLIC_IP="$(ifpublic)"
 | 
			
		||||
 | 
			
		||||
printbar() {
 | 
			
		||||
	printf "%b" "$(get_current_desktop)"
 | 
			
		||||
@ -111,14 +86,14 @@ printbar() {
 | 
			
		||||
 | 
			
		||||
# check to make sure customizeable vars are in proper format
 | 
			
		||||
 | 
			
		||||
[ -n "$INTERVAL" ] && str isdigit "$INTERVAL" \
 | 
			
		||||
str isdigit "$INTERVAL" \
 | 
			
		||||
	|| INTERVAL=1
 | 
			
		||||
 | 
			
		||||
[ -n "$CPU_TEMP_SCALE" ] && str isdigit "$CPU_TEMP_SCALE" \
 | 
			
		||||
str isdigit "$CPU_TEMP_SCALE" \
 | 
			
		||||
		&& [ "$CPU_TEMP_SCALE" -gt 0 ] \
 | 
			
		||||
	|| CPU_TEMP_SCALE=1
 | 
			
		||||
 | 
			
		||||
[ -n "$CPU_TEMP_FILES" ] \
 | 
			
		||||
str isvalue "$CPU_TEMP_FILES" \
 | 
			
		||||
	|| alias get_cpu_temp="printf '[no temperature files specified]\n'"
 | 
			
		||||
 | 
			
		||||
# main loop
 | 
			
		||||
@ -128,6 +103,6 @@ while true; do
 | 
			
		||||
	sleep "$INTERVAL"
 | 
			
		||||
	if streq $(date +'%S') 00; then
 | 
			
		||||
		# every minute
 | 
			
		||||
		PUBLIC_IP="$(get_public_ip)"
 | 
			
		||||
		PUBLIC_IP="$(ifpublic)"
 | 
			
		||||
	fi
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								dist/Makefile
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/Makefile
									
									
									
									
										vendored
									
									
								
							@ -26,7 +26,7 @@ bin/battery: bin ../battery/battery
 | 
			
		||||
	cp ../battery/battery* bin/
 | 
			
		||||
 | 
			
		||||
.PHONY: data
 | 
			
		||||
data: bin/data battery ifpublic lowercase nonzero str streq
 | 
			
		||||
data: bin/data battery ifpublic lowercase str streq
 | 
			
		||||
bin/data: bin ../data/data
 | 
			
		||||
	cp ../data/data bin/
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user