Saturday, April 16, 2011

Conky in FreeBSD -- troublesome.

Having become enamoured of Conky in Ubuntu I decided to try it in FreeBSD 8.2-RELEASE on my Dell E520.
Conky, as well as conkyForcast and conkyEmail are all included in the FreeBSD ports and can be easily installed.
As a first shot, I tried bringing across my .conkyrc from Ubuntu 11.04, but, although, there was a display, it was badly configured and a real mess.
So, back to basics and I started from the /usr/local/share/examples/conky/conkyrc.sample file that comes when you install conky from ports.
OK, this worked fine, but is very, very basic.
With a lot of trial and error, I eventually got together a version of .conkyrc that worked well for me in FreeBSD. You'll see this later in this post.
However, I did have one major problem.
First, remember to choose (among others) the Xft option when compiling conky.
Secondly, the lm-sensors that I used in Ubuntu to report the processor core temperatures are not available in FreeBSD. Instead I used sysctl with the following line (for core0) in .conkyrc:

Core0 Temperature:${color} ${alignr} ${execi 30 sysctl -n dev.cpu.0.temperature | cut -c 1-2}°C

The "cut" that I used is simply to get the first two digits from the output of "sysctl -n dev.cpu.0.temperature" (try this in a terminal) and leave the rest. Actually, should the temperature ever reach 100°C, the output I'd see in conky would be 10°C. But if this ever happened, my cpu would be well and truly cooked by that stage.
Thirdly, to eliminate the severe flickering that I found in conky without it, use the "double_buffer yes" option in .conkyrc as detailed in the conky faq (see point 3).
Another problem was that launching conky from Startup Applications, gave me a separate conky window which stayed on top. I resolved this as before by using a start script for conky with a generous sleep. In FreeBSD, I used a 40 second sleep. This was because Yakuake (drop-down terminal) takes about 40 seconds to launch in FreeBSD (for reasons I don't understand) and I wanted to have everything else launched and in place before I fired up conky.
Yet another annoyance (rather than a serious problem) was that the WS (windspeed) object in conkyForecast does not accept "metrespersecond" as units. In contrast to my experience in Linux, it seems that the only units allowed for WS is "imperial". So, looks like I have to settle for the archaic miles-per-hour.
By far the most serious problem I had, however, was that Conky after launching would, almost always, freeze on launch.
I googled around about this problem and found various suggestions as to how to rectify this problem. They included:
1. Removing the line in .conkyrc that finds the external (or public) IP
2. Shutting down compiz
3. Making sure "load dbe" is included in the Modules section of /etc/X11/xorg.conf if "double buffer yes" is included in .conkyrc.

However, none of these made any improvment in my situation.
What did work for me was to kill and relaunch conky about 20 seconds after its launch. This worked, up to now at laest, every time for me.
I have added a small script to Startup Applications to do this automatically for me on every reboot.
Here it is:
#! /bin/sh
sleep 60
killall -9 conky && conky

Unfortunately, I was unable to inlcude Gmail in .conkyrc as this inevitably caused immediate freezing of conky. The line I tried to use was as follows:
${color}${execi 60 conkyEmail --servertype=IMAP --username=myuser --password=mypassword --ssl}
Have a look at the screenshot and my .conkyrc for more details.
# conky configuration
# edited by Mark Buck (Kaivalagi)

# set to yes if you want Conky to be forked in the background
background no

# X font when Xft is disabled, you can pick one with program xfontsel
#font 5x7
#font 6x10
#font 7x13
#font 8x13
#font 9x15
#font **
#font -*-*-*-*-*-*-34-*-*-*-*-*-*-*

# Use Xft?
use_xft yes

# Xft font when Xft is enabled
xftfont Bitstream Vera Sans Mono:size=10

# Text alpha when using Xft
xftalpha 0.8

# Update interval in seconds
update_interval 1.0

# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0

# Create own window instead of using desktop (required in nautilus)
own_window no
own_window_hints below

# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes

# Minimum size of text area
minimum_size 300 0
maximum_width 300

# Draw shades?
draw_shades yes

# Draw outlines?
draw_outline no

# Draw borders around text
draw_borders no
draw_graph_borders yes

# Stippled borders?
stippled_borders 8

# border margins
border_margin 4

# border width
border_width 1

# Default colors and also border colors
default_color yellow
default_shade_color black
default_outline_color white

# own window options
own_window yes
own_window_transparent yes
own_window_type override
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

# Text alignment, other possible values are commented
#alignment top_left
alignment top_right
#alignment bottom_left
#alignment bottom_right

# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 250
gap_y 35

# Subtract file system buffers from used memory?
no_buffers yes

# set to yes if you want all text to be in uppercase
uppercase no

# number of cpu samples to average
# set to 1 to disable averaging
cpu_avg_samples 2

# number of net samples to average
# set to 1 to disable averaging
net_avg_samples 2

# Force UTF8? note that UTF8 support required XFT
override_utf8_locale yes

# Add spaces to keep things from moving about? This only affects certain objects.
use_spacer right

# colours
color1 white
# light blue
color2 6892C6
# yellow
color3 FC8820
# green
color4 78BF39
# red
color5 CC0000

text_buffer_size 2048

# variable is given either in format $variable or in ${variable}. Latter
# allows characters right after the variable and must be used in network
# stuff because of an argument

# stuff after 'TEXT' will be formatted on screen

${font Bitstream Vera Sans Mono:size=14 :bold}${execi 1800 conkyForecast --location=EIXX0026 --datatype=CT}${font}
${color white}${font ConkyWeather:style=Bold:size=40}${execi 1800 conkyForecast --location=EIXX0026 --datatype=WF} ${font ConkyWindNESW:size=40}${execi 1800 conkyForecast --location=EIXX0026 --datatype=BS}${font}
${execi 1800 conkyForecast --location=EIXX0026 --datatype=HT --centeredwidth=4}/${execi 1800 conkyForecast --location=EIXX0026 --datatype=LT --centeredwidth=4} ${execi 1800 conkyForecast --location=EIXX0026 --datatype=WS --imperial} - ${execi 1800 conkyForecast --location=EIXX0026 --datatype=WD}
${color #00ff00}SYSTEM${color}
${color red}CPU0: ${alignr} ${cpu cpu0}%
${color}CPU1: ${alignr} ${cpu cpu1}%
CPU2: ${alignr} ${cpu cpu2}%
${color green}${cpugraph 20}

${color #00ff00}CPU Usage $alignr PID CPU%
${color}${top name 1} $alignr ${top pid 1} ${top cpu 1}
${top name 2} $alignr ${top pid 2} ${top cpu 2}
${top name 3} $alignr ${top pid 3} ${top cpu 3}

${color #00ff00}Mem usage $alignr PID MEM%
${color}${top_mem name 1} $alignr ${top_mem pid 1} ${top_mem mem 1}
${top_mem name 2} $alignr ${top_mem pid 2} ${top_mem mem 2}
${top_mem name 3} $alignr ${top_mem pid 3} ${top_mem mem 3}

RAM: $alignr $mem/$memmax
${color green}${membar 3}${color}
Swap: $alignr $swap / $swapmax
${color green}${swapbar 3}${color}

${color #00ff00}Partitions$color
ROOT: $alignr ${fs_used /} / ${fs_size /}
${color green}${fs_bar 3 /}${color}
/var: $alignr ${fs_used /var} / ${fs_size /var}
${color green}${fs_bar 3 /var}${color}
/tmp: $alignr ${fs_used /tmp} / ${fs_size /tmp}
${color green}${fs_bar 3 /tmp}${color}
/usr: $alignr ${fs_used /usr} / ${fs_size /usr}
${color green}${fs_bar 3 /usr}${color}

${color #00ff00}CPU Freq, CPU and GPU Temperatures.
${color}CPU Frequency: ${alignr}${freq_g} GHz$color
Core0 Temperature:${color} ${alignr} ${execi 30 sysctl -n dev.cpu.0.temperature | cut -c 1-2}°C
Core1 Temperature:${color} ${alignr} ${execi 30 sysctl -n dev.cpu.1.temperature | cut -c 1-2}°C
GPU Temperature: $alignr ${execi 30 nvidia-settings -q [gpu:0]/GPUCoreTemp | grep '):' | awk '{print $4}' | sed 's/\.//'}°C
${color #00ff00}Network
${color}Download Speed: $alignr ${downspeed em0}
# Total Down: $alignr ${totaldown em0}
Upload Speed: $alignr ${upspeed em0}
${color}IP on LAN $alignr ${addr em0}
External IP: ${alignr}${execi 3600 ~/scripts/conkyip}

${color}${font :size=36}$alignc${time %H:%M:%S}
${voffset -30}${font :size=15}$alignc${time %d %b. %Y}
${font :bold:size=10}$alignc${time %A}

No comments:

Post a Comment