Conky! - znx - 2006-02-14
OK .. first.. lets show you WHY you might want to do this :)
<a class="ipsAttachLink ipsAttachLink_image" href="<fileStore.core_Attachment>/post-798-1139953495.png" data-fileid="477">[img]<fileStore.core_Attachment>/post-798-1139953495.png[/img]</a>
This is my conky :) You can see that this is weighted towards gentoo users
Ok, first the preparation. I will assume that you have conky installed (yum install conky, emerge conky, most systems have it now).
Ok so we need to create a couple of scripts to help create the output. If you aren't a gentoo user, skip these.
If you don't have a local user bin folder then you should make it:
~/bin/emerge-current.sh
Code: #!/bin/bash
# emerge-current.sh by Hellf[i]re
#
# This script is designed to read the name of the last package compiled.
#
# As this script does read the entirety of emerge.log, it will be rather
# heavy on the CPU. It shouldn't be enough to be noticable on newer (2.0Ghz+)
# processors, but it still should not be run more often than every 30 seconds.
#
# Usage:
# .conkyrc: ${execi [time] /path/to/script/emerge-current.sh}
#
# Usage Example
# ${execi 30 /home/youruser/scripts/emerge-current.sh}
tail -n 50 /var/log/emerge.log |\
tac |\
grep 'Compiling' |\
head |\
sed -e 's/.*(//' |\
sed -e 's/::.*)//' |\
head -n 1 |\
cut -d \) -f 1
~/bin/emerge-progress.sh
Code: #!/bin/bash
# source: Jeremy_Z @ forums.gentoo.org http://forums.gentoo.org/viewtopic-t-351806-postdays-0-pos
torder-asc-start-550.html
#
# This script will report the progress of the last emerge command run. It
# reports the TOTAL percentage complete - not the percentage of the current
# package. For example, if there are 110 packages currently being emerged, and
# it is on the 55th package, it will report 50.
#
# Usage:
# .conkyrc: ${execibar [time] /path/to/script/emerge-progress.sh}
#
# Usage Example
# ${execibar 30 /home/youruser/scripts/emerge-progress.sh}
tail -n 50 /var/log/emerge.log |\
tac |\
grep -v "Starting retry" |\
grep -iE '([0-9]* of [0-9]*)' -o -m 1 |\
sed -e 's/\(.*\) of \(.*\)/\1 \2/' |\
awk '{print 100.0*$1/$2}'
~/bin/emerge-status.sh
Code: #!/bin/bash
#
# emerge-status.sh by Hellf[i]re
#
# This script will report the current status of portage.
#
# Usage:
# .conkyrc: ${execi [time] /path/to/script/emerge-current.sh}
#
# Usage Example
# ${execi 30 /home/youruser/scripts/emerge-current.sh}
#
# Known Bugs:
# 1) If there are two emerges running at once, when the first one finishes
# running, the script will report the current status as "Completed".
# 2) If there is a emerge running and you run a search, the script will
# report the current status as "Completed", until the running emerge
# moves to the next package, or itself completes.
# The reasons for this are twofold - one, it's a feature;) and two, there
# would be far too much parsing required to find out the current status of
# every command which is run in parallel.
STATUS=`tail -n 15 /var/log/emerge.log |\
grep -iE "Compiling|Cleaning|AUTOCLEAN|completed|search|terminating|rsync" |\
cut -d ' ' -f "2-" |\
grep -Ev 'Finished\.|Cleaning up\.\.\.' |\
tail -n 1`
#echo "$STATUS"
if [ "`echo "$STATUS" | grep -i compiling`" != "" ]; then echo Compiling
elif [ "`echo "$STATUS" | grep -i cleaning`" != "" ]; then echo Cleaning
elif [ "`echo "$STATUS" | grep -i autoclean`" != "" ]; then echo Autoclean
elif [ "`echo "$STATUS" | grep -i sync`" != "" ]; then echo Syncing
elif [ "`echo "$STATUS" | grep -i search`" != "" ]; then echo Searching
elif [ "`echo "$STATUS" | grep -i completed`" != "" ]; then echo Completed
elif [ "`echo "$STATUS" | grep -i terminating`" != "" ]; then echo Completed
fi
~/bin/lastsync.pl
Code: #!/usr/bin/perl
use Date::Manip;
$date = `grep "Sync completed" /var/log/emerge.log | tail -n1 | cut -c-10`;
$date = &DateCalc("Jan 1, 1970 00:00:00 GMT",$date);
$date = UnixDate("$date","%A %H:%M");
print "$date";
Right thats those out of the way. Major thanks to the respective authors!
Now onto the ~/.conkyrc:
Code: # ~/.conkyrc
background yes
use_xft no
on_bottom yes
font 6x10
update_interval 5.0
total_run_times 0
own_window no
own_window_transparent yes
double_buffer yes
minimum_size 180 5
draw_shades yes
draw_outline no
draw_borders no
stippled_borders 8
border_margin 4
border_width 1
default_color white
default_shade_color black
default_outline_color black
alignment top_right
gap_x 12
gap_y 12
no_buffers yes
uppercase no
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale no
use_spacer no
TEXT
${color #98c2c7}$nodename linux-$kernel${alignr}${time %T}$color
${color #98c2c7}SYSTEM$color
${color #ffcb48}UPTIME$color $uptime${alignr}${color #ffcb48}LOAD$color $loadavg
${color #ffcb48}CPU$color $cpu%${alignr}${color #ffcb48}FREQ$color $freq_dyn_g / $freq_g
${color #000000}${cpugraph cpu0 32,255 104e8b 0077ff}
${color #ffcb48}RAM$color $mem / $memmax ${color #7f8ed3}${membar}$color
${color #ffcb48}SWAP$color $swap / $swapmax ${color #7f8ed3}${swapbar}$color
${color #98c2c7}NETWORK$color
${color #ffcb48}PING$color mute${execi 50 sh -c "ping -q -c5 mute | tail -n 2 | head -n 1 | cut -d',' -f3" }
${color #ffcb48}DOWN$color ${downspeed eth0} k/s ${offset 80}${color #ffcb48}UP$color ${upspeed eth0} k/s
${color #000000}${downspeedgraph eth0 32,125 104e8b 0077ff} ${color #000000}${upspeedgraph eth0 32,125 104e8b 0077ff}
${color #98c2c7}STORAGE$color
root ${fs_used /} / ${fs_size /} ${color #7f8ed3}${fs_bar /}$color
${color #98c2c7}PROCESSES$color
${color #ffcb48}NAME PID CPU% MEM%$color
${color #007700}${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}$color
${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
${color #ffcb48}PROC$color $processes${alignr}${color #ffcb48}RUN$color $running_processes
${color #ffcb48}MEM USAGE$color
${color #007700}${top_mem name 1} ${top_mem pid 1} ${top_mem cpu 1} ${top_mem mem 1}$color
${top_mem name 2} ${top_mem pid 2} ${top_mem cpu 2} ${top_mem mem 2}
${top_mem name 3} ${top_mem pid 3} ${top_mem cpu 3} ${top_mem mem 3}
${color #98c2c7}PORTAGE$color
${color #ffcb48}LAST SYNC$color ${execi 300 /home/znx/bin/lastsync.pl}
${color #ffcb48}LAST 3$color
${execi 50 genlop -lnu | sed -e 's/.*\([><]\+\)/ \1/' | tail -n 3 | tac}
${color #ffcb48}CURRENT$color
> ${color #98c2c7}${execibar 30 /home/znx/bin/emerge-progress.sh}$color
> ${execi 30 /home/znx/bin/emerge-current.sh}
> ${execi 30 /home/znx/bin/emerge-status.sh}
NOTE if you are not using gentoo remove the lines at the end of the ~/.conkyrc from PORTAGE down to the end. And if you ARE then switch the "/home/znx/bin" for your user. :)
Thats it.. start up conky and it will run. If you are using KDE/Gnome you will need to tamper with them to make it work because conky doesn't work well with them yet.
Conky's Home where I sourced the script and 99% of the idea to the production of this layout.
Weeeeee.. just a quick jaunt.. ask questions if you have any
OH ..
Code: ${color #ffcb48}PING$color mute${execi 50 sh -c "ping -q -c5 mute | tail -n 2 | head -n 1 | cut -d',' -f3" }
This line is used to ping another system in my local network, you can either edit the name "mute" to be another machine, or remove the line as it will loose 100% of its packets.
See below for information about securing the genlop command.
Updated to fix mistakes found by dragon_788, many thanks!
Conky! - enigma - 2006-02-14
Thanks alot znx what a great tutorial on conky hehe, i am now using yours :)
Conky! - xDamox - 2006-02-15
Nice one znx :)
Conky! - enigma - 2006-07-16
Ok so I decided to try out this portage thing with conky...
gentoostatus seems broken ...
./gentoo-status.sh: line 38: syntax error: unexpected end of file
if you can help that would be great heres a pic so far...
<a class="ipsAttachLink ipsAttachLink_image" href="<fileStore.core_Attachment>/post-204-1153139591.png" data-fileid="623">[img]<fileStore.core_Attachment>/post-204-1153139591.png[/img]</a>
Conky! - znx - 2006-07-21
Quote:./gentoo-status.sh: line 38: syntax error: unexpected end of file
Nice pic! Hrmm .. well that complaint is about the final line of the script, all I can suggest is that something is missing in that "if / fi" statement. Maybe try recopying that script.. works ok here still!
Conky! - enigma - 2006-07-27
Yeah it was that and i hade to emerge genlop for it to work as well, still a problem with the status though doesn't output anything to conky... if i run it manually it says Completed being that the package is emerged and installed i'm lost on that one
Oh yeah znx somthing else i was wondering is it possible to run 2 different conky scripts at once?
Update:
Notice the Current status doesn't show anything
<a class="ipsAttachLink ipsAttachLink_image" href="<fileStore.core_Attachment>/post-204-1154279356.png" data-fileid="630">[img]<fileStore.core_Attachment>/post-204-1154279356.png[/img]</a>
Conky! - znx - 2006-07-30
Quote:still a problem with the status though doesn't output anything to conky... if i run it manually it says Completed being that the package is emerged and installed i'm lost on that one
Ah .. maybe its permissions.. is your user in the portage group?
Quote:Oh yeah znx somthing else i was wondering is it possible to run 2 different conky scripts at once?
well .. yes it is...
Code: # conky -c firstconfigfile
# conky -c secondconfigfile
:)
Conky! - enigma - 2006-07-30
Ok I added user to portage group via vigr still the same error :(
Conky! - enigma - 2006-07-31
Thanks for the tip znx on having conky run more then once :)
I got the cal script from the following url...
[/url][url=http://www.ubuntuforums.org/showpost.php?p...mp;postcount=85]http://www.ubuntuforums.org/showpost.php?p...mp;postcount=85
<a class="ipsAttachLink ipsAttachLink_image" href="<fileStore.core_Attachment>/post-204-1154341029.png" data-fileid="635">[img]<fileStore.core_Attachment>/post-204-1154341029.png[/img]</a>
<a class="ipsAttachLink ipsAttachLink_image" href="<fileStore.core_Attachment>/post-204-1154341042.png" data-fileid="636">[img]<fileStore.core_Attachment>/post-204-1154341042.png[/img]</a>
Conky! - dragon_788 - 2006-10-22
Any reason you couldn't use tail in your emerge status script rather than parsing the whole file? Might make it a bit easier on the resources so this could be used on lower end machines. I definitely plan on trying this once I get my machine up and happy.
|