Код отслеживания Google Analytics.

Dec 29, 2010

My conky

Conky is really nice tool. Hundreds articles were written around how you can setup its and it is useless to repeat them. This note is just about some details and scripts which can be helpful


My config you can find here
What can be treated as interesting?
color1 bebebe #title (grey)
color2 ff6347 #emergency - tomato
color3 f5deb3 #warning   - wheat
#color4 98fb98 #good      - pale green
color4 C1FFC1 #good      - DarkSeaGreen1
At first it is very good idea to use variable for colors (color1,color2 etc). There are a lot of editing at begin and this trick will help you to economy your time.
default_shade_color black
draw_shades yes
If you are use "own_window_transparent yes" or any other "transparent features" then shadow will help words be more contrast on light wallpapers
own_window yes
....
own_window_type desktop
own_window_argb_visual true
own_window_argb_value 150
double_buffer yes
it is standard set of properties for show conky at every workspace. Now I'm using different scheme, but it for the next note
I've found very cool "own_window_argb_*" parameters - they are really work in my XFCE 4 without any compiz or something like that. Please note if you want to use them then comment out "own_window_transparent"
text_buffer_size 2048 #256 by default is too small for fileSystem.sh script
As always I've written scripts. The strings they returns may be longer the 256 bytes - it produces some freaky unexpected errors.
There are two scripts is used in my config - fileSystem.sh and networkSystem.sh. Both of them use function
function formatForConky () {
    #merge all in one string - see http://beggytech.blogspot.com/2008/10/one-more-note.html
    echo "$1" | sed -e ':x;$by;N;bx' -e ':y;s/\n *//g'
}
in conkyScriptUtil.sh
fileSystem.sh:
#!/bin/bash

#don't forget set text_buffer_size in enough size
#e.g. text_buffer_size 1024
#I presume the color1 is defined for title, color2-4 for emergency, warning and normal

source ~/bin/conky/conkyScriptUtil.sh

function createConkyString () {
#this function just format text for support. It should be merged in one string later
    local mountFrom="$1"
    local mountTo="$2"
    cat << END_FORMATED_TEXT
\${color1}${mountFrom} -> ${mountTo}\${color} \$alignr\${fs_used ${mountTo}}/\${fs_size ${mountTo}}
\${if_match \${fs_free_perc ${mountTo}}<10}
    \${color2}
\${else}
    \${if_match \${fs_free_perc ${mountTo}}<30}
        \${color3}
    \${else}
        \${color4}
    \${endif}
\${endif}\n
\${fs_bar ${mountTo}}\${color}\n
read:\${diskio_read ${mountFrom}}\${goto 162}write:\${diskio_write ${mountFrom}}\n
\${diskiograph_read ${mountFrom} 20,150 000000 98fb98} \${diskiograph_write ${mountFrom} 20,150 000000 FFC125}
END_FORMATED_TEXT
}

while read mountFrom mountTo; do
    echo -e $(formatForConky "$(createConkyString "${mountFrom}" "${mountTo}")")
done < <(mount |\
    grep -v -E "^[^[:space:]]*fuse|^udev|^lrm|^securityfs|^binfmt|^devpts|^tmpfs|^varlock|^varrun|^sysfs|^proc|^none" |\
    sed "s|^\(.*\) on \(.*\) type.*$|\1 \2|g")
networkSystem.sh:
#!/bin/bash

#don't forget set text_buffer_size in enough size
#e.g. text_buffer_size 1024
#I presume the color1 is defined for title, color2-4 for emergency, warning and normal

source ~/bin/conky/conkyScriptUtil.sh

function createConkyString () {
#this function just format text for support. It should be merged in one string later
    local interface="$1"
    cat << END_FORMATED_TEXT
\${if_existing /sys/class/net/${interface}/operstate down}
\${else}
    ${interface}(\${addr ${interface}})\n
    \${color1}Down:\$color \${downspeed ${interface}}\${goto 160}\${color1}Up:\$color \${upspeed ${interface}}\n
    \${downspeedgraph ${interface} 20,150 000000 98fb98} \${upspeedgraph ${interface} 20,150 000000 FFC125}\${endif}
END_FORMATED_TEXT
}

while read interface; do
    echo -e $(formatForConky "$(createConkyString "${interface}")")
done < <(ifconfig -a -s | grep -v "^Iface" | grep -o "^[[:alnum:]]*" | grep -v "^lo$" )
Both scripts are very similar and self descriptive - they are read current state file or network systems and produce number conky strings for each. It allows to have updated status each 10 seconds and more than conky config comprehensible scripts.
The last theme - auto start conky in XFCE. In some unknown for me reason just adding in auto started programs makes conky failed. So I just use one more script which delay it on 30 seconds:
#!/bin/bash

echo conky will be started after a half of minute 
sleep 30
killall conky
/usr/bin/conky --daemonize

No comments: