Desktop environment with Conky

I share this post hoping be useful to someone.

Thanks to dietpi I turned my ODROID into a mini server very useful. Having few hardware resources is important to keep them under control and Conky can help you do that. Internet is full of how-to for conky but non always working with different distros/configs, so:

assuming you connect to session via remote desktop with a non-root user, these commands are from root user

install conky and create config file

apt-get install conky-all
nano ~/.conkyrc

Paste into it

background yes
double_buffer yes

alignment top_left

border_width 1
cpu_avg_samples 2
default_color white
default_outline_color white
default_shade_color white
draw_borders no
draw_graph_borders yes
draw_outline no
draw_shades no

gap_x 10
gap_y 10
net_avg_samples 2
no_buffers yes
out_to_console no
out_to_stderr no
extra_newline nosa

own_window yes
own_window_type normal
own_window_transparent yes
own_window_colour 000000
own_window_argb_visual no
own_window_argb_value 0
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

minimum_size 220 600
stippled_borders 0
update_interval 2.0
uppercase no
use_spacer none

show_graph_scale no
show_graph_range no

use_xft yes
xftalpha 0.1
xftfont Sans:style=Bold:size=10
color0 white
color1 EAEAEA
color2 FFA300
color3 grey
color4 red

TEXT

${font Sans:style=Bold:size=11}$alignc${color2}DietPi @ OdroidC1+

${font Sans:style=Normal:size=8}${color2}Kernel${color0}${alignr}${kernel}
${color2}Uptime${color0}${alignr}${uptime}${font Sans:style=Bold:size=10}

${color2}Utilizzo CPU${color0}${alignr}${cpu cpu0}%
${cpubar cpu0 5,}
${cpubar cpu1 5,}
${cpubar cpu2 5,}
${cpubar cpu3 5,}
${font Sans:style=Normal:size=8}${top name 1} $alignr ${top cpu 1}%
${top name 2} $alignr ${top cpu 2}%
${top name 3} $alignr ${top cpu 3}%
${top name 4} $alignr ${top cpu 4}%
${top name 5} $alignr ${top cpu 5}%${font Sans:style=Bold:size=10}

${color2}Utilizzo RAM${color0}${alignr}${mem}
${membar 5,}
${font Sans:style=Normal:size=8}${top_mem name 1} $alignr ${top_mem mem_res 1}
${top_mem name 2} $alignr ${top_mem mem_res 2}
${top_mem name 3} $alignr ${top_mem mem_res 3}
${top_mem name 4} $alignr ${top_mem mem_res 4}
${top_mem name 5} $alignr ${top_mem mem_res 5}${font Sans:style=Bold:size=10}

${color2}Utilizzo eMMC${color0}${alignr}${fs_used /}
${fs_bar /}
${font Sans:style=Normal:size=8}${color2}Lettura${color0}${alignr}${diskio_read mmcblk0}
${color2}Scrittura${color0}${alignr}${diskio_write mmcblk0}${font Sans:style=Bold:size=10}

${color2}Internet${alignr}${color0}${execpi 10 ~/.pingtest.sh}
${font Sans:style=Normal:size=8}${color2}${execi 600 cat ~/.speedtest.result }${font Sans:style=Bold:size=10}

${color2}Download ${color0}${alignr}${downspeedf eth1} KiB/s
${downspeedgraph eth1 40,}
${color2}Upload ${color0}${alignr}${upspeedf eth1} KiB/s 
${upspeedgraph eth1 40,}
${font Sans:style=Normal:size=8}${color2}IP Locale${color0}${alignr}${addr eth1}
${color2}IP Pubblico${color0}${alignr}${execi 3600 wget -q -O /dev/stdout http://checkip.dyndns.org/ | cut -d : -f 2- | cut -d \< -f -1}
${color2}No-Ip${color0}${alignr}${execi 3600 ping -c 1 yourdomain.ddns.net | perl -e '$header=<>;$header=~m/ \(([^)]+)\) /;print $1;'}${font Sans:style=Bold:size=10}

Install speedtest-cli

apt-get install speedtest-cli

Create cronjob that write speedtest results into text file. You can skip this step and pass this command directly to conky but I think this method is better

crontab -e

and paste

30 * * * * speedtest-cli --simple > ~/.speedtest.result

this create a text file with results and overwrite it every 30 minutes

Create a script to ping google and test connection

nano ~/.pingtest.sh

and paste

#!/bin/bash

if ping -c 1 -W 2 www.google.it > /dev/null; then
	echo "Online"
else
    echo "Offline"
fi

Now launching conky everything must work fine. Every text entry could be edit, english, spanish or alien languages :smiley: in .conkyrc config file. You can also add or remove functions. Be sure that mmcblk0, eth1 and other variables are right for your config. Screenshot preview attached.

Sorry for any error (I’m a newbie), I am available for any questions or explanations.

1 Like

Very nice, thanks for sharing!

I did see your tweet for this, love the system stats on Conky. I’ll have to try this out and maybe we can add it to the dietpi-software catalogue, based on your guide :slight_smile:

Thank you for DietPi, time and passion!

Can also be useful logo, temperature and notifier for updates from dietpi-update.
Examples from an Archlinux installation:

${alignc}${image ./archlinux.png -s 200x150}
${color2}Temperatura${color0}${alignr}${execi 1 sensors | grep "Physical id 0" | cut -d "+" -f2 | cut -c1-6}
${color2}Update disponibili${color0}${alignr} ${execpi 10 ~/.checkupdates.sh}

.checkupdates.sh

#!/bin/bash

if ping -c 1 -W 2 www.google.it > /dev/null; then
        checkupdates | wc -l # change with something like dietpi-update | grep "Server Version" | cut xyz
else
    echo "Updated"

I think DietPi need an official Wallpaper! Something like this attachment, simply but cool :wink:

Found an ugly but working method to notify dietpi-update in conky:

script to create /tmp/dietpi-update/server_version and copying version number into ~/.server_version (from dietpi-update script, sure contain unused functions, sorry but I’m not a coder :roll_eyes: )

nano ~/.dietpi-update-checker

and paste

#!/bin/bash
#Load the whole script into memory.
{
	#////////////////////////////////////
	# DietPi Update
	#
	#////////////////////////////////////
	# Created by Daniel Knight / daniel.knight@dietpi.com / dietpi.com
	#
	#////////////////////////////////////
	#
	# Info:
	# - Updates DietPi from Git
	# - Uses patch_file for online pactching
	#
	# Usage:
	# - dietpi-update   = Normal
	# - dietpi-update 1 = forced update
	# - dietpi-update 2 = Check for updates. print server_version to /DietPi/dietpi/.update_available (-1=new image required)
	#////////////////////////////////////

	#Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales.
	LANG=en_GB.UTF-8

	#/////////////////////////////////////////////////////////////////////////////////////
	#GIT Branch | master / testing
	#/////////////////////////////////////////////////////////////////////////////////////
	GITBRANCH=$(cat /DietPi/dietpi.txt | grep -m1 '^gitbranch=' | sed 's/.*=//')
	GITFORKOWNER=$(cat /DietPi/dietpi.txt | grep -m1 '^gitforkowner=' | sed 's/.*=//')

	#/////////////////////////////////////////////////////////////////////////////////////
	#UPDATE Vars
	#/////////////////////////////////////////////////////////////////////////////////////
	DIETPIUPDATE_VERSION_CURRENT=5 # Version of dietpi-update / set server_version line two to value++ and obsolete previous dietpi-update scripts
	DIETPIUPDATE_VERSION_REQUIRED=0

	FILEPATH_TEMP="/tmp/dietpi-update-checker"

	SERVER_ONLINE=0
	UPDATE_AVAILABLE=0
	UPDATE_REQUIRESNEWIMAGE=0
	RUN_UPDATE=0

	VERSION_CURRENT=0
	VERSION_SERVER=0

	URL_MIRROR_INDEX=0
	URL_MIRROR_SERVERVERSION=(

		"http://dietpi.com/downloads/dietpi-update_mirror/$GITBRANCH/server_version"
		"https://raw.githubusercontent.com/${GITFORKOWNER:-Fourdee}/DietPi/$GITBRANCH/dietpi/server_version"

	)

	URL_MIRROR_ZIP=(

		"http://dietpi.com/downloads/dietpi-update_mirror/$GITBRANCH/DietPi-$GITBRANCH.zip"
		"https://github.com/${GITFORKOWNER:-Fourdee}/DietPi/archive/$GITBRANCH.zip"

	)

	Get_Client_Version(){
		VERSION_CURRENT=$(cat /DietPi/dietpi/.version)
	}

	Get_Server_Version(){

		#Get server version file
		for ((i=0; i<${#URL_MIRROR_SERVERVERSION[@]}; i++))
		do

			URL_MIRROR_INDEX=$i

			/DietPi/dietpi/func/dietpi-notify 2 #"Checking Mirror : ${URL_MIRROR_SERVERVERSION[$i]}"
			curl -k -L ${URL_MIRROR_SERVERVERSION[$i]} > "$FILEPATH_TEMP"/server_version
			if (( $? == 0 )); then

				#Get server Version info
				VERSION_SERVER=$(sed -n 1p "$FILEPATH_TEMP"/server_version)
				DIETPIUPDATE_VERSION_REQUIRED=$(sed -n 2p "$FILEPATH_TEMP"/server_version)

				#Check if server_version is a valid interger.
				if [[ $VERSION_SERVER =~ ^-?[0-9]+$ ]]; then

					SERVER_ONLINE=1
					/DietPi/dietpi/func/dietpi-notify 0 #"Using update server: ${URL_MIRROR_SERVERVERSION[$i]}"

					break

				else

					/DietPi/dietpi/func/dietpi-notify 2 #"Invalid server version and/or update file unavailable"

				fi

			else

				/DietPi/dietpi/func/dietpi-notify 2 #"No response from: ${URL_MIRROR_SERVERVERSION[$i]}"

			fi

		done
	}

	Check_Update_Available(){

		#Server online?
		if (( $SERVER_ONLINE )); then

			#Update Requires new image?
			if (( $DIETPIUPDATE_VERSION_CURRENT < $DIETPIUPDATE_VERSION_REQUIRED )); then

				UPDATE_REQUIRESNEWIMAGE=1

			#Update available
			elif (( $VERSION_CURRENT < $VERSION_SERVER )); then

				UPDATE_AVAILABLE=1
				echo -e ""
				/DietPi/dietpi/func/dietpi-notify 0 "Update available"
				/DietPi/dietpi/func/dietpi-notify 2 "Current Version : $VERSION_CURRENT"
				/DietPi/dietpi/func/dietpi-notify 2 "Server Version  : $VERSION_SERVER"

			fi

		else

			/DietPi/dietpi/func/dietpi-notify 1 "Unable to access update servers. Please check your connection, then run dietpi-update again."
			exit

		fi

	}

	#/////////////////////////////////////////////////////////////////////////////////////
	# MENUS
	#/////////////////////////////////////////////////////////////////////////////////////
	WHIP_BACKTITLE='- DietPi-Update -'
	WHIP_TITLE=$WHIP_BACKTITLE
	CHOICE=0
	OPTION=0

	Menu_Update(){

		whiptail --title "$WHIP_TITLE" --yesno "Update available   : https://goo.gl/G9ikqn
Installed version  : $VERSION_CURRENT
Latest version     : $VERSION_SERVER

---------------------------------Notice-------------------------------------
The benefit of DietPi is we use standard linux configurations and commands. The downside is we can't possibly accommodate or predict, every modifcation to Linux configurations files by the end user, during the update.

Although we test the updates thoroughly, if you have made custom changes to Linux configuration files, outside of the DietPi programs, we highly recommend you create a backup of your system, before updating.

You can create a system backup, by running:
 - dietpi-backup
----------------------------------------------------------------------------

Do you wish to continue and update DietPi to v$VERSION_SERVER?" --yes-button "Ok" --no-button "Exit" --defaultno --backtitle "$WHIP_BACKTITLE" 24 80
		CHOICE=$?
		#Confirm action
		if (( $CHOICE == 0 )); then
			RUN_UPDATE=1
		fi
	}

	#/////////////////////////////////////////////////////////////////////////////////////
	# Update DietPi
	#/////////////////////////////////////////////////////////////////////////////////////

	

	#/////////////////////////////////////////////////////////////////////////////////////
	# Main Loop
	#/////////////////////////////////////////////////////////////////////////////////////
	#----------------------------------------------------------------
	#Inform user
	/DietPi/dietpi/func/dietpi-notify 3 DietPi-Update "Checking for DietPi updates"
	#----------------------------------------------------------------
	#Create temp directory used in dietpi-update
	rm -R "$FILEPATH_TEMP" &> /dev/null
	mkdir -p "$FILEPATH_TEMP" &> /dev/null
	#----------------------------------------------------------------
	#Get versions
	Get_Client_Version
	Get_Server_Version
	#----------------------------------------------------------------
	#Check if update is available
	Check_Update_Available
	#----------------------------------------------------------------
	#Check for updates only. Send result to global file for use by dietpi-banner update available notifications.

		#Clear previous .update_available file
		rm /DietPi/dietpi/.update_available &> /dev/null

		#Write update available version to file.
		if (( $UPDATE_AVAILABLE == 1 )); then

			echo -e "$VERSION_SERVER" > /DietPi/dietpi/.update_available

		elif (( $UPDATE_REQUIRESNEWIMAGE == 1 )); then

			echo -e "-1" > /DietPi/dietpi/.update_available

	#----------------------------------------------------------------
	#Run menus / prompts / updates
	else

		#----------------------------------------------------------------
		#Server offline
		if (( $SERVER_ONLINE == 0 )); then

			whiptail --title "Error - Server Offline" --msgbox "http://github.com is either offline, or, unable to connect \n \n No updates applied." 12 60

		#Update requires new DietPi image
		elif (( $UPDATE_REQUIRESNEWIMAGE == 1 )); then

			#Cannot update, Image required
			whiptail --title "New image required" --msgbox " Your version of DietPi is now obsolete and cannot be updated. \n\n Please download the latest DietPi image:\n - http://dietpi.com/downloads/images \n\n - Current Version : $VERSION_CURRENT \n - Server Version  : $VERSION_SERVER \n " 13 70

			/DietPi/dietpi/func/dietpi-notify 1 "Your version of DietPi is now obsolete and cannot be updated."
			echo -e "Please download the latest DietPi image:\n - http://dietpi.com/download \n\n - Current Version : $VERSION_CURRENT \n - Server Version  : $VERSION_SERVER \n "

		#Update available
		elif (( $UPDATE_AVAILABLE == 1 )); then

			#Forced update
			if (( $INPUT == 1 )); then

				/DietPi/dietpi/func/dietpi-notify 0 "Updates have been found and are being applied, please wait..."
				/DietPi/dietpi/func/dietpi-notify 2 "Current Version : $VERSION_CURRENT"
				/DietPi/dietpi/func/dietpi-notify 2 "Server Version  : $VERSION_SERVER"

				/DietPi/dietpi/dietpi-funtime 0

				RUN_UPDATE=1

			#Ask for update
			else

				Menu_Update

			fi

		#No Updates
		else

			echo -e ""
			/DietPi/dietpi/func/dietpi-notify 0 "No updates required, your DietPi installation is up to date.\n"
			/DietPi/dietpi/func/dietpi-notify 2 "Current Version : $VERSION_CURRENT"
			/DietPi/dietpi/func/dietpi-notify 2 "Server Version  : $VERSION_SERVER"

		fi

	
	fi

	unset URL_MIRROR_ZIP
	unset URL_MIRROR_ZIP
	
	head -1 /tmp/dietpi-update-checker/server_version > ~/.server_version
	exit

}

create a script readable from conky, it compare version and server_version

nano ~/.dietpi-update-comparison

and paste

#!/bin/bash

if ! cmp ~/.server_version /DietPi/dietpi/.version >/dev/null 2>&1
then
   echo "Update available"
else 
	echo "DietPi Updated"
fi

rm -rf /tmp/dietpi-update-checker

add to conky

${color2}Update${color0}${alignr}${execpi 10 ~/.dietpi-update-comparison}

create cronjob

crontab -e

and paste

    60 * * * * speedtest-cli --simple > ~/.dietpi-update-checker

updated.png
available.png

Nice, I think this could be simplify by using the following:

/DietPi/dietpi/dietpi-update 2

This creates a file in /DietPi/dietpi/.update_available, which contains the latest version number. If the file doesnt exist, an update is not available.

Example:

/DietPi/dietpi/dietpi-update 2

#Check if we have an update available file (if no file, no updates available)
if [ -f /DietPi/dietpi/.update_available ]; then

    version_available=$(cat /DietPi/dietpi/.update_available)
    echo -e "$version_available is available for update"
    update_available=1

fi

I think DietPi need an official Wallpaper! Something like this attachment, simply but cool

Wallpaper would be sweet, maybe we should have a competition? :smiley:

Heres the current logo, 2048x2048: http://dietpi.com/images/dietpi-logo.png

Sure, but a friendly competition :slight_smile: Thank you, how i can get it transparent?

Thank you again, I found something about it in dietpi-software code but I missed ‘2’ argument.

I always liked the conky setups that the CrunchBang community used to do (indeed the whole crunchbang desktop experience with OpenBox was great IMO).

Looks like it’s forked in to two projects now

https://crunchbangplusplus.org/

https://www.bunsenlabs.org/

Might be good for some inspiration though.

According to the Conky documentation, the “cpubar” object with the “cpu0” argument would correspond to the total load and not to the first core
http://conky.sourceforge.net/docs.html
“cpu (cpuN)
CPU usage in percents. For SMP machines, the CPU number can be provided as an argument. ${cpu cpu0} is the total usage, and ${cpu cpuX} (X >= 1) are individual CPUs.
cpubar (cpuN) (height),(width)
Bar that shows CPU usage, height is bar’s height in pixels. See $cpu for more info on SMP.”

My conky (and desktop)


Conky

background yes
update_interval 2
total_run_times 0

cpu_avg_samples 2
net_avg_samples 2
temperature_unit celsius

double_buffer yes
no_buffers yes
text_buffer_size 2048

gap_x 6
gap_y 32
minimum_size 170 1080
maximum_width 170
own_window yes
own_window_class conky
own_window_type normal
own_window_transparent yes
own_window_argb_visual no
own_window_argb_value 250
own_window_hints undecorated,sticky,skip_taskbar,skip_pager,below
alignment tr

draw_shades yes
default_shade_color 000000
draw_outline yes
draw_borders no
border_width 2
draw_graph_borders yes
short_units

override_utf8_locale yes
use_xft yes
xftfont Ubuntu Condensed :size=11
xftalpha 1.0
uppercase no

default_color eeeeee
color1 ffffff
color2 C397E5
color3 C397E5
top_name_width 15

TEXT
${goto 48}${font Ubuntu :size=22}${time %H:%M}${font}
${alignc}${color2}${time %A}${color}
${voffset 12}${execpi 3600 ~/week.sh}${font}
${alignc}${color2}${time %B %Y}${color}

${color2}${font Ubuntu Condensed :size=8}:::::::::::::::::::::::CPU::::::::::::::::::::::::::::::::::::::${color}${font}
${alignc}${font Ubuntu Condensed :size=16}${acpitemp}ºC - ${freq_g cpu}GHz${color}${font}
Core1 ${cpugraph cpu1 13 C397E5  -t}
Core2 ${cpugraph cpu2 13 C397E5  -t}
Core3 ${cpugraph cpu3 13 C397E5  -t}
Core4 ${cpugraph cpu4 13 C397E5  -t}
Carga: ${cpu cpu0}% ${cpubar 5}
Ram: ${mem} - ${memmax}${color1} ${membar 5}${color}
Swap: ${swap} - ${swapmax} ${color1}${swapbar 5}${color}
${font Ubuntu Condensed :size=8}............................. CPU ....... MEM .......
${top name 1}${goto 90}${top cpu 1}${goto 135}${top mem 1}
${top name 2}${goto 90}${top cpu 2}${goto 135}${top mem 2}
${top name 3}${goto 90}${top cpu 3}${goto 135}${top mem 3}
${top name 4}${goto 90}${top cpu 4}${goto 135}${top mem 4}${font}

${color2}${font Ubuntu Condensed :size=8}::::::::::::::::::::HDD:::::::::::::::::::::::::::::::::::::::::::${color}${font}
Home:  ${fs_used /} - ${fs_size /}${font}
${fs_bar 5 /}
Lectura               Escritura
${diskio_read mmcblk0}${goto 88}${diskio_write mmcblk0}
${diskiograph_read mmcblk0 16,83 C397E5 3 -t} ${diskiograph_write mmcblk0 16,83  C397E5 3 -t}

USB:  ${fs_used /mnt/usb_1/} - ${fs_size /mnt/usb_1/}${font}
${fs_bar 5 /mnt/usb_1/}
Lectura               Escritura
${diskio_read sda1}${goto 88}${diskio_write sda1}
${diskiograph_read sda1 16,83 C397E5 3 -t} ${diskiograph_write sda1 16,83  C397E5 3 -t}

${voffset 0}${color2}${font Ubuntu Condensed :size=8}:::::::::::::::::::::RED:::::::::::::::::::::::::::::::::::::::::::${color}${font}

WLAN0
AP: ${wireless_essid wlan0}   Brt: ${wireless_bitrate wlan0}
Señal: ${wireless_link_bar 5 wlan0}
IP: ${goto 85}${addr wlan0}
IP Publica: ${goto 85}${exec sh ip.sh}
Puerta:${goto 85}${gw_ip}
Baja ${downspeed wlan0} ${goto 90}Sube ${upspeed wlan0}
${downspeedgraph wlan0 24,83 C397E5 3 -t} ${upspeedgraph wlan0 24,83 C397E5 3 -t}
Total ${totaldown wlan0} ${goto 90}Total ${totalup wlan0}${color}
Entrante: ${tcp_portmon 1 32767 count}${alignr}Saliente: ${tcp_portmon 32768 61000 count}
${alignc}Puertos abiertos:  ${tcp_portmon 1 65535 count}
IP                           ${alignr}PORT${font Ubuntu Condensed :size=8}
${tcp_portmon 1 65535 rip 0}          ${alignr}${tcp_portmon 1 65535 rport 0}
${tcp_portmon 1 65535 rip 1}          ${alignr}${tcp_portmon 1 65535 rport 1}
${tcp_portmon 1 65535 rip 2}          ${alignr}${tcp_portmon 1 65535 rport 2} 
${tcp_portmon 1 65535 rip 3}          ${alignr}${tcp_portmon 1 65535 rport 3}
${tcp_portmon 1 65535 rip 4}          ${alignr}${tcp_portmon 1 65535 rport 4}
${tcp_portmon 1 65535 rip 5}          ${alignr}${tcp_portmon 1 65535 rport 5}

Script external IP

wget http://ipinfo.io/ip -qO -

Script week day

#!/bin/bash

font=("\${font Ubuntu :size=8}" "\${voffset -4}\${font Ubuntu :size=12}" "\${voffset -5}\${font Ubuntu :size=16}" "\${voffset -9}\${font Ubuntu :size=22}\${color C397E5}" "\${voffset 0}\${font Ubuntu :size=16}" "\${voffset 0}\${font Ubuntu :size=12}" "\${voffset 0}\${font Ubuntu :size=8}")
color=("" "" "" "\${color}" "" "" "")

for i in $(seq -3 3); do
echo -n "${font[$[i+3]]}$(date '+%d' -d "$i days")${color[3]}\${offset 3}"
done
1 Like