Conky YUM Updates


/ Published in: Perl
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #!/usr/bin/perl
  2. # Script to extract Update information from
  3. # YUM output for conky
  4. #
  5. # Written by Keiran "Affix" Smith <[email protected]>
  6. # http://affix.me
  7. #
  8. # Instructions
  9. # 1. download the perl script and save it to /bin/updateconky
  10. # 2. chmod a+x /bin/updateconky
  11. # 3. Add ${execpi 3600 /bin/updateconky} to you're .conkyrc file
  12. # 4. Enjoy it :D
  13. #
  14.  
  15. my $font_color = "white"; # Conky Font Color
  16.  
  17. my $output = `yum list updates 2>&1`; # Get output of yum list updates
  18.  
  19. if($output =~ /^(.*)(Updated Packages.*)$/s) # Regex to parse out Updates from junk
  20. {
  21. $data = $2; # Store the data in a variable
  22. @updates = split(/\n/, $data); # Split out new line into an array
  23. foreach $update(@updates) # For Each @updates make a variable $update
  24. {
  25. @split = split(/ /, $update); # Split by spaces
  26. push(@packages, $split[0]); # Push the package name into an array packages
  27. }
  28. }
  29.  
  30. if(scalar(@packages) > 0)
  31. {
  32. print "\${color " . $font_color . "}" . $packages[1] . "\$color \n"; # Output Package 1
  33. print "\${color " . $font_color . "}" . $packages[2] . "\$color \n"; # Output Package 2
  34. print "\${color " . $font_color . "}" . $packages[3] . "\$color \n"; # Output Package 3
  35. print "\${color " . $font_color . "}" . $packages[4] . "\$color \n"; # Output Package 4
  36. print "\${color " . $font_color . "}" . $packages[5] . "\$color \n"; # Output Package 5
  37. }
  38. print "\${color " . $font_color . "}" . scalar(@packages) . "\$color total updates\n"; # Print Total Updates

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.