Return to Snippet

Revision: 37873
at December 18, 2010 22:12 by Affix


Initial Code
#!/usr/bin/perl
# Script to extract Update information from
# YUM output for conky
#
# Written by Keiran "Affix" Smith <[email protected]>
#	     http://affix.me
#
# Instructions
#	1. download the perl script and save it to /bin/updateconky
#	2. chmod a+x /bin/updateconky
#	3. Add ${execpi 3600 /bin/updateconky} to you're .conkyrc file
#	4. Enjoy it :D
#

my $font_color = "white"; 				# Conky Font Color

my $output = `yum list updates 2>&1`;			# Get output of yum list updates

if($output =~ /^(.*)(Updated Packages.*)$/s)		# Regex to parse out Updates from junk
{
	$data = $2;					# Store the data in a variable
	@updates = split(/\n/, $data);			# Split out new line into an array
	foreach $update(@updates)			# For Each @updates make a variable $update
	{
		@split = split(/ /, $update);		# Split by spaces
		push(@packages, $split[0]);		# Push the package name into an array packages
	}
}

if(scalar(@packages) > 0)
{
	print "\${color " . $font_color . "}" . $packages[1] . "\$color \n";	# Output Package 1
	print "\${color " . $font_color . "}" . $packages[2] . "\$color \n";	# Output Package 2
	print "\${color " . $font_color . "}" . $packages[3] . "\$color \n";	# Output Package 3
	print "\${color " . $font_color . "}" . $packages[4] . "\$color \n";	# Output Package 4
	print "\${color " . $font_color . "}" . $packages[5] . "\$color \n";	# Output Package 5
}
print "\${color " . $font_color . "}" . scalar(@packages) . "\$color total updates\n";	# Print Total Updates

Initial URL


Initial Description


Initial Title
Conky YUM Updates

Initial Tags


Initial Language
Perl