Conky: Add graphs for more CPUs as needed
This commit is contained in:
		@@ -150,6 +150,7 @@ EOF
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
step_text() {
 | 
					step_text() {
 | 
				
			||||||
	local -r topitems=4
 | 
						local -r topitems=4
 | 
				
			||||||
 | 
						local -r nproc="$(nproc)"
 | 
				
			||||||
	# Generate our actual functional Conky stuff
 | 
						# Generate our actual functional Conky stuff
 | 
				
			||||||
	# Header
 | 
						# Header
 | 
				
			||||||
	cat <<- 'EOF' >> "$_optout"
 | 
						cat <<- 'EOF' >> "$_optout"
 | 
				
			||||||
@@ -163,9 +164,44 @@ step_text() {
 | 
				
			|||||||
	cat <<- 'EOF' >> "$_optout"
 | 
						cat <<- 'EOF' >> "$_optout"
 | 
				
			||||||
	${color3}$hr$color
 | 
						${color3}$hr$color
 | 
				
			||||||
	${font Roboto:style=Medium:size=9}CPU$font: $freq_g GHz$alignr$cpu%
 | 
						${font Roboto:style=Medium:size=9}CPU$font: $freq_g GHz$alignr$cpu%
 | 
				
			||||||
	${color8}${cpugraph cpu1 36,200} ${cpugraph cpu2 36,200}
 | 
					 | 
				
			||||||
	${cpugraph cpu3 36,200} ${cpugraph cpu4 36,200}$color
 | 
					 | 
				
			||||||
	EOF
 | 
						EOF
 | 
				
			||||||
 | 
						local gpl=1
 | 
				
			||||||
 | 
						if (( nproc <= 2 )); then
 | 
				
			||||||
 | 
							gpl=1
 | 
				
			||||||
 | 
						elif (( nproc <= 4 )); then
 | 
				
			||||||
 | 
							gpl=2
 | 
				
			||||||
 | 
						elif (( nproc <= 8 )); then
 | 
				
			||||||
 | 
							gpl=4
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							gpl=8
 | 
				
			||||||
 | 
						fi
 | 
				
			||||||
 | 
						local width=$(( 400 / gpl ))
 | 
				
			||||||
 | 
						log "Generating $gpl graphs per row of CPU core stats" 1
 | 
				
			||||||
 | 
						log "Graphs will be $width wide" 2
 | 
				
			||||||
 | 
						local cpuinfo
 | 
				
			||||||
 | 
						for i in $(seq 1 "$gpl" "$nproc"); do
 | 
				
			||||||
 | 
							# Generate lines
 | 
				
			||||||
 | 
							local line="\${color8}"
 | 
				
			||||||
 | 
							for j in $(seq 0 $(( gpl - 1 ))); do
 | 
				
			||||||
 | 
								# Generate graphs
 | 
				
			||||||
 | 
								local cpu=$(( i + j ))
 | 
				
			||||||
 | 
								log "Generating graph for CPU $cpu" 2
 | 
				
			||||||
 | 
								if [ -z "$line" ]; then
 | 
				
			||||||
 | 
									line="\${cpugraph cpu$cpu 36,$width}"
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
									line="$line \${cpugraph cpu$cpu 36,$width}"
 | 
				
			||||||
 | 
								fi
 | 
				
			||||||
 | 
							done
 | 
				
			||||||
 | 
							# Trim whitespace
 | 
				
			||||||
 | 
							line="${line%" "}$color"
 | 
				
			||||||
 | 
							log "Appending line: $line" 2
 | 
				
			||||||
 | 
							cpuinfo="$cpuinfo$line\n"
 | 
				
			||||||
 | 
							unset line
 | 
				
			||||||
 | 
						done
 | 
				
			||||||
 | 
						while [ "$cpuinfo" != "${cpuinfo%\\n}" ]; do
 | 
				
			||||||
 | 
							cpuinfo="${cpuinfo%\\n}"
 | 
				
			||||||
 | 
						done
 | 
				
			||||||
 | 
						echo -e "$cpuinfo" >> "$_optout"
 | 
				
			||||||
	for i in $(seq $topitems); do
 | 
						for i in $(seq $topitems); do
 | 
				
			||||||
		echo "\${color8}\${top name $i}\$color\$alignr\${top cpu $i}%" >> "$_optout"
 | 
							echo "\${color8}\${top name $i}\$color\$alignr\${top cpu $i}%" >> "$_optout"
 | 
				
			||||||
	done
 | 
						done
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user