You are not logged in.

#961 2018-05-24 07:18:49

Hervé Moustache
New Member
Registered: 2018-05-24
Posts: 1

Re: Show us your conky

Hi Everybody!

I've just made one of my first (more or less) usefull script for conky.
It shows yours Strava (kind of sport social network) info on your desktop.
The script is not as clean as I would like but I'll work on it and at least it works.
On Github
Here it is:
7ca069459500f2a17c9e4f22ff396485.th.png

The Script:

#!/bin/bash
#
#   stravonky.sh: a strava script for conky (or others) 
#   Copyright (C) 2018 Hervé Moustache
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.

#version 2018-05-24-08-20

##### TO DO #####
#- Read athlete_id/access_token/cliend_id/client_secret from a file
#- Obtain an access_token if needed
#- Verify if the athlete_id & the access_token are well linked
#- Get the names of the JSON variables in a proper way (curl | jq -> in array | 2 bash arrays ?)
#- Change time/distance/speed scale in a proper way
#- Chose which stats to show in a proper way

## Requires:
##          'jq' (sudo apt install jq);
##          API Keys from Strava (https://strava.com/settings/api)
##

#### Athlete id & access_token from Strava ###
#athlete_id as a number, access_token as a sentence (with quotes'')
athlete_id=
access_token=

#########################################################################
connectiontest() {
    local -i i attempts=${1-0}
    for (( i=0; i < attempts || attempts == 0; i++ )); do
        if wget -O - 'http://ftp.debian.org/debian/README' &> /dev/null; then
            return 0
        fi
        if (( i == attempts - 1 )); then # if last attempt
            return 1
        fi
    done
}

placeholder() {
    if (( $1 == 1 )) &>/dev/null;then
        echo "No internet connection"
        echo "Strava information unavailable"
    else
        echo "No API key"
        echo "Strava information unavailable"
    fi
}


#### Scale to show ####
#/!\ not finished yet. Do not convert, only change few names print, the other have to be changed manually (watch below)
scalet="h"

if [[ $metric == metric ]] &>/dev/null;then
    scaleD="m"
    scaleV="m/s"
else
    scaleT="miles"
    scaleV="mph"
fi


#
if [[ -z "$access_token" ]] || [[ -z "$athlete_id" ]] &>/dev/null;then
    placeholder 0 && exit 1
else
    connectiontest 10

    
    if (( $? == 0 )) &>/dev/null;then
        

        # get json data from strava:
        athlete_stats=$(curl -s https://www.strava.com/api/v3/athletes/$athlete_id/stats\?access_token=$access_token)
   
        # load values into array:
        #               	    ARRAY INDEX  0          1          2                3          4              5              6              7           8         9           10           11          12 -> 49
		all=($(echo "$athlete_stats" | jq -r '.biggest_ride_distance,.biggest_climb_elevation_gain,.recent_ride_totals.count,.recent_ride_totals.distance,.recent_ride_totals.moving_time,.recent_ride_totals.elapsed_time,.recent_ride_totals.elevation_gain,.recent_ride_totals.achievement_count,.recent_run_totals.count,.recent_run_totals.distance,.recent_run_totals.moving_time,.recent_run_totals.elapsed_time,.recent_run_totals.elevation_gain,.recent_run_totals.achievement_count,.recent_swim_totals.count,.recent_swim_totals.distance,.recent_swim_totals.moving_time,.recent_swim_totals.elapsed_time,.recent_swim_totals.elevation_gain,.recent_swim_totals.achievement_count,.ytd_ride_totals.count,.ytd_ride_totals.distance,.ytd_ride_totals.moving_time,.ytd_ride_totals.elapsed_time,.ytd_ride_totals.elevation_gain,.ytd_run_totals.count,.ytd_run_totals.distance,.ytd_run_totals.moving_time,.ytd_run_totals.elapsed_time,.ytd_run_totals.elevation_gain,.ytd_swim_totals.count,.ytd_swim_totals.distance,.ytd_swim_totals.moving_time,.ytd_swim_totals.elapsed_time,.ytd_swim_totals.elevation_gain,.all_ride_totals.count,.all_ride_totals.distance,.all_ride_totals.moving_time,.all_ride_totals.elapsed_time,.all_ride_totals.elevation_gain,.all_run_totals.count,.all_run_totals.distance,.all_run_totals.moving_time,.all_run_totals.elapsed_time,.all_run_totals.elevation_gain,.all_swim_totals.count,.all_swim_totals.distance,.all_swim_totals.moving_time,.all_swim_totals.elapsed_time,.all_swim_totals.elevation_gain'))
		
		#Fix an issue due the figures after the dot
		for i in `seq 0 49`;
		do
			all[$i]=${all[$i]%.*}
		done
				
		#converting m in km
		let "all[0] = all[0] / 1000"
		let "all[9] = all[9] / 1000"
		let "all[15] = all[15] / 1000"
		let "all[21] = all[21] / 1000"
		let "all[26] = all[26] / 1000"
		let "all[31] = all[31] / 1000"
		let "all[36] = all[36] / 1000"
		let "all[41] = all[41] / 1000"
		let "all[46] = all[46] / 1000"
		
		#converting s in hour
		let "all[10] = all[10] / 3600"
		let "all[11] = all[11] / 3600"
		let "all[16] = all[16] / 3600"
		let "all[17] = all[17] / 3600"
		let "all[22] = all[22] / 3600"
		let "all[23] = all[23] / 3600"
		let "all[27] = all[27] / 3600"
		let "all[28] = all[28] / 3600"
		let "all[32] = all[32] / 3600"
		let "all[33] = all[33] / 3600"
		let "all[37] = all[37] / 3600"
		let "all[38] = all[38] / 3600"
		let "all[38] = all[38] / 3600"
		let "all[42] = all[42] / 3600"
		let "all[43] = all[43] / 3600"
		let "all[47] = all[47] / 3600"
		let "all[48] = all[48] / 3600"
		
		#building sentences
		biggest_ride_distance=$(printf '%g km' ${all[0]})
		biggest_climb_elevation_gain=$(printf '%g %s' ${all[1]} $scaleD)
		recent_ride_totals__count=$(printf '%g' ${all[2]})
		recent_ride_totals__distance=$(printf '%g km' ${all[3]})
		recent_ride_totals__moving_time=$(printf '%d%s' ${all[4]} $scalet)
		recent_ride_totals__elapsed_time=$(printf '%g %s' ${all[5]} $scalet)
		recent_ride_totals__elevation_gain=$(printf '%g %s' ${all[6]} $scaleD)
		recent_ride_totals__achievement_count=$(printf '%g %s' ${all[7]})
		recent_run_totals__count=$(printf '%g' ${all[8]})
		recent_run_totals__distance=$(printf '%g km' ${all[9]})
		recent_run_totals__moving_time=$(printf '%g %s' ${all[10]} $scalet)
		recent_run_totals__elapsed_time=$(printf '%g %s' ${all[11]} $scalet)
		recent_run_totals__elevation_gain=$(printf '%g %s' ${all[12]} $scaleD)
		recent_run_totals__achievement_count=$(printf '%g %s' ${all[13]})
		recent_swim_totals__count=$(printf '%g' ${all[14]})
		recent_swim_totals__distance=$(printf '%g km' ${all[15]})
		recent_swim_totals__moving_time=$(printf '%g %s' ${all[16]} $scalet)
		recent_swim_totals__elapsed_time=$(printf '%g %s' ${all[17]} $scalet)
		recent_swim_totals__elevation_gain=$(printf '%g %s' ${all[18]} $scaleD)
		recent_swim_totals__achievement_count=$(printf '%g %s' ${all[19]} )
		ytd_ride_totals__count=$(printf '%g' ${all[20]})
		ytd_ride_totals__distance=$(printf '%g km' ${all[21]})
		ytd_ride_totals__moving_time=$(printf '%g %s' ${all[22]} $scalet)
		ytd_ride_totals__elapsed_time=$(printf '%g %s' ${all[23]} $scalet)
		ytd_ride_totals__elevation_gain=$(printf '%g %s' ${all[24]} $scaleD)
		ytd_run_totals__count=$(printf '%g' ${all[25]})
		ytd_run_totals__distance=$(printf '%g km' ${all[26]})
		ytd_run_totals__moving_time=$(printf '%g %s' ${all[27]} $scalet)
		ytd_run_totals__elapsed_time=$(printf '%g %s' ${all[28]} $scalet)
		ytd_run_totals__elevation_gain=$(printf '%g %s' ${all[29]} $scaleD)
		ytd_swim_totals__count=$(printf '%g' ${all[30]})
		ytd_swim_totals__distance=$(printf '%g km' ${all[31]})
		ytd_swim_totals__moving_time=$(printf '%g %s' ${all[32]} $scalet)
		ytd_swim_totals__elapsed_time=$(printf '%g %s' ${all[33]} $scalet)
		ytd_swim_totals__elevation_gain=$(printf '%g %s' ${all[34]} $scaleD)
		all_ride_totals__count=$(printf '%g' ${all[35]})
		all_ride_totals__distance=$(printf '%g km' ${all[36]})
		all_ride_totals__moving_time=$(printf '%g %s' ${all[37]} $scalet)
		all_ride_totals__elapsed_time=$(printf '%g %s' ${all[38]} $scalet)
		all_ride_totals__elevation_gain=$(printf '%g %s' ${all[39]} $scaleD)
		all_run_totals__count=$(printf '%g' ${all[40]})
		all_run_totals__distance=$(printf '%g km' ${all[41]})
		all_run_totals__moving_time=$(printf '%g %s' ${all[42]} $scalet)
		all_run_totals__elapsed_time=$(printf '%g %s' ${all[43]} $scalet)
		all_run_totals__elevation_gain=$(printf '%g %s' ${all[44]} $scaleD)
		all_swim_totals__count=$(printf '%g' ${all[45]})
		all_swim_totals__distance=$(printf '%g km' ${all[46]})
		all_swim_totals__moving_time=$(printf '%g %s' ${all[47]} $scalet)
		all_swim_totals__elapsed_time=$(printf '%g %s' ${all[48]} $scalet)
		all_swim_totals__elevation_gain=$(printf '%g %s' ${all[49]} $scaleD)
		
		#Final show: Comment lines you don't need
        printf "Biggest ride distance: %s\n" "$biggest_ride_distance"
        printf "Biggest climb elevation: %s\n" "$biggest_climb_elevation_gain"
        #printf ": %s\n" "$recent_ride_totals__count"
		printf "Recent ride distance: %s\n" "$recent_ride_totals__distance"
		printf "Recent ride moving time: %s\n" "$recent_ride_totals__moving_time"
		#printf ": %s\n" "$recent_ride_totals__elapsed_time"
		printf "Recent ride elevation gain: %s\n" "$recent_ride_totals__elevation_gain"
		#printf ": %s\n" "$recent_ride_totals__achievement_count"
		#printf ": %s\n" "$recent_run_totals__count"
		printf "Recent run distance: %s\n" "$recent_run_totals__distance"
		printf "Recent run moving time: %s\n" "$recent_run_totals__moving_time"
		#printf ": %s\n" "$recent_run_totals__elapsed_time"
		printf "Recent run elevation gain: %s\n" "$recent_run_totals__elevation_gain"
		#printf ": %s\n" "$recent_run_totals__achievement_count"
		#printf ": %s\n" "$recent_swim_totals__count"
		#printf ": %s\n" "$recent_swim_totals__distance"
		#printf ": %s\n" "$recent_swim_totals__moving_time"
		#printf ": %s\n" "$recent_swim_totals__elapsed_time"
		#printf ": %s\n" "$recent_swim_totals__elevation_gain"
		#printf ": %s\n" "$recent_swim_totals__achievement_count"
		printf "Year total rides: %s\n" "$ytd_ride_totals__count"
		printf "Year total ride distance: %s\n" "$ytd_ride_totals__distance"
		printf "Year total ride moving time: %s\n" "$ytd_ride_totals__moving_time"
		#printf ": %s\n" "$ytd_ride_totals__elapsed_time"
		printf "Year total ride elevation gain: %s\n" "$ytd_ride_totals__elevation_gain"
		#printf ": %s\n" "$ytd_run_totals__count"
		printf "Year total run distance: %s\n" "$ytd_run_totals__distance"
		printf "Year total run moving time: %s\n" "$ytd_run_totals__moving_time"
		#printf ": %s\n" "$ytd_run_totals__elapsed_time"
		printf "Year total run elevation gain: %s\n" "$ytd_run_totals__elevation_gain"
		#printf ": %s\n" "$ytd_swim_totals__count"
		#printf ": %s\n" "$ytd_swim_totals__distance"
		#printf ": %s\n" "$ytd_swim_totals__moving_time"
		#printf ": %s\n" "$ytd_swim_totals__elapsed_time"
		#printf ": %s\n" "$ytd_swim_totals__elevation_gain"
		printf "All ride count: %s\n" "$all_ride_totals__count"
		printf "All ride distance: %s\n" "$all_ride_totals__distance"
		printf "All ride moving time: %s\n" "$all_ride_totals__moving_time"
		#printf ": %s\n" "$all_ride_totals__elapsed_time"
		printf "All ride elevation gain: %s\n" "$all_ride_totals__elevation_gain"
		#printf ": %s\n" "$all_run_totals__count"
		printf "All run distance: %s\n" "$all_run_totals__distance"
		printf "All run moving time: %s\n" "$all_run_totals__moving_time"
		#printf ": %s\n" "$all_run_totals__elapsed_time"
		printf "All run elevation gain: %s\n" "$all_run_totals__elevation_gain"
		#printf ": %s\n" "$all_swim_totals__count"
		#printf ": %s\n" "$all_swim_totals__distance"
		#printf ": %s\n" "$all_swim_totals__moving_time"
		#printf ": %s\n" "$all_swim_totals__elapsed_time"
		#printf ": %s\n" "$all_swim_totals__elevation_gain"

    else
        placeholder 1
    fi
fi

exit

The conkyrc line to add:

${alignr}A T H L E T I C    I N F O
${membar 0}
${execpi 600 $HOME/.config/conky/scripts/stravonky-0.1.sh}

Hope you'll enjoy it.

Offline

#962 2018-06-17 09:18:56

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 2,640

Re: Show us your conky

With Conky1.9 everything seems to come to an end...  sad

Since the beginning of May 2018 www.intellicast.org has ceased its service and has been collected by www.wunderground.com

v9000_1.th.jpg That's the end of those beautiful Conky's.(It is @mrpeachy's V9000.) conk4.th.jpg


the script published by @ragamatrix can also no longer work correctly, since the French satellite updates the image daily only between 9.00 a.m. and 10.45 a.m.
ende1.th.jpg

and there are also more and more failures here
ende2.th.jpg mrpeachy's WUN

oh man  mad

reliable only works, thanks to Teo, accuweather   smile

Last edited by unklar (2018-06-19 19:10:20)

Offline

#963 2018-06-26 09:20:27

ragamatrix
Member
Registered: 2015-10-04
Posts: 427

Re: Show us your conky

@unklar I know I know ...  8.(

I did a little work and modifications for the sat maps, a little bit difficult to re-find (recover) (sorry for my poor English) good web map adresses, I purpose you 2 goods IR image to change in the script.
If you have an account on wunderground test these one with your api number at the end of the link:

http://wublast.wunderground.com/cgi-bin/WUBLAST?lat=47.25999832&lon=8.60000038&radius=800&width=500&height=500&key=sat_ir4_thumb&gtt=0&extension=png&proj=me&num=1&delay=25&timelabel=0&basemap=1&borders=1&theme=WUBLAST_WORLD&rand=1527494004&api_key=your16charactersnumber

I made also a conky infrared map with this one which I find not so bad:
https://neige.meteociel.fr/satellite/la … -color.gif
the script:

#!/bin/bash

file_exists() {
    if [ -e "$1" ]; then
        return 0
    else
        return 1
    fi
}

PREFIX=${HOME}/.conky/ConkySatMap/
RSAT=${PREFIX}radar-sat
#RSAT_zoom=${PREFIX}radar-satzoom
OUTPUT=${PREFIX}satir-1.png
tailleRSAT=80
#tailleRSAT_zoom=80
tailledecoupe_ir2=692x692
#tailledecoupe_zoom=150x150
################################
################################
#Annotation pour vérifier si l'image est actualisée ##HelveticaLTStd-BlkCond
jour=$(date +%d.%m.%y); heuremodif=$(date +%H); minmodif=$(date +%M)
#fonte=Open-Sans-Bold
libelle=""
TXT=${PREFIX}updated.png
#################################################################

adrS="https://neige.meteociel.fr/satellite/latest-ir-color.gif"

wget -qO "${RSAT}" "${adrS}"

convert ${RSAT} -filter Lanczos -crop $tailledecoupe_ir2+31+57\! ${RSAT}.png
#convert ${RSAT} -filter Lanczos -crop $tailledecoupe_zoom+389+335\! ${RSAT_zoom}.png
#convert ${RSAT_zoom}.png -resize ${tailleRSAT_zoom}% ${RSAT_zoom}
#########################################################
convert ${RSAT}.png -resize ${tailleRSAT}% ${RSAT}.png
convert  ${RSAT}.png \
\( +clone  -alpha extract \
       -draw 'fill black polygon 0,0 0,5 5,0 fill white circle 5,5 5,0' \
        \( +clone -flip \) -compose Multiply -composite \
        \( +clone -flop \) -compose Multiply -composite \
     \) -alpha off -compose CopyOpacity -composite ${RSAT}.png

convert -background transparent -fill blue -font White-Rabbit -pointsize 17 -gravity center label:"${libelle} ${jour} @ ${heuremodif} : ${minmodif}" -trim \
\( +clone -background skyblue  -shadow 100x1 -channel A -level 0,6% +channel \) +swap +repage -gravity center -composite ${TXT}



convert $RSAT.png  -background  black \( +clone -shadow 70x4+4+4 \) +swap -background none -flatten ${OUTPUT}

composite -geometry +35+10 ${TXT} ${OUTPUT} ${OUTPUT}
#composite -geometry +155+10 ${RSAT_zoom} ${OUTPUT} ${OUTPUT}
if file_exists "${HOME}"/.conky/ConkySatMap/radar-sat-*; then
    rm "${HOME}"/.conky/ConkySatMap/radar-sat-* "${RSAT}" "${RSAT}.png"
else
    rm "${RSAT}" "${RSAT}.png"
fi
 
exit

I hope it can be usefull for you  wink

Offline

#964 2018-06-26 19:47:44

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 2,640

Re: Show us your conky

@ragamatrix

Bonjour mon ami,

avec WUN, je n'aime pas l'image satellite. neutral
Mais cette image s'intègre très bien dans ma configuration.  big_smile
neige3.th.jpg
Merci pour votre excellente aide !

Offline

#965 2018-06-29 14:36:17

ragamatrix
Member
Registered: 2015-10-04
Posts: 427

Re: Show us your conky

Bitte unklar,
Ist deinen Hintergrund ein dynamisches Bild?
Sieht aus wie ein Bild, das mit Blender-Software erstellt wurde.
Ich bin froh, dass diese Konfiguration zu dir passt.
Bonne soirée et bon weekend

Offline

#966 2018-06-29 16:47:27

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 2,640

Re: Show us your conky

Salut raga

c'est cool  wink  , je peux tout lire correctement. C'est ce que vous faites avec deepl.com ?

J'ai cette photo depuis longtemps et je ne sais pas d'où elle vient. Il porte le numéro 330365.jpg. Si vous le cherchez, vous viendrez chez Blender. Donc vous avez raison.

Passez un bon week-end aussi.

Offline

#967 2018-06-29 21:06:16

hhh
Gaucho
From: High in the Custerdome
Registered: 2015-09-17
Posts: 16,032
Website

Re: Show us your conky

unklar wrote:

@ragamatrix

Bonjour mon ami,

avec WUN, je n'aime pas l'image satellite. neutral
Mais cette image s'intègre très bien dans ma configuration.  big_smile
https://cdn.scrot.moe/images/2018/06/26/neige3.th.jpg
Merci pour votre excellente aide !

Sector11 is proud of you! big_smile


No, he can't sleep on the floor. What do you think I'm yelling for?!!!

Offline

#968 2018-06-30 07:37:32

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 2,640

Re: Show us your conky

hhh wrote:

Sector11 is proud of you! big_smile

There is no better Conky Teacher.  cool   O:)

Offline

#969 2018-09-28 11:41:29

ragamatrix
Member
Registered: 2015-10-04
Posts: 427

Re: Show us your conky

Hello and thank-you easysid, I've played a little with your colorfill.lua script. I made a test with the font ConkyColors to use "letters" as icons that we can fill... I don't know if you like the idea but it works smile
2018-09-28-131650_1920x1080_scrot.th.png
conkyrc:

conky.config = {
-- work in background (disabled for testing)
background = false,

-- better fonts
use_xft = true,
--xftalpha = 1,

-- update interval
update_interval = 1,
total_run_times = 0,

-- window settings
own_window = true,
own_window_transparent = true,
own_window_type = 'desktop',
own_window_hints = 'undecorated, below, sticky, skip_taskbar, skip_pager',
--own_window_argb_visual = true,
--own_window_argb_value = 0,

-- anti-flickering
double_buffer = true,

-- size
minimum_width = 1350,
minimum_height = 20,
maximum_width = 1350,

 -- shadows
draw_shades = true,
default_shade_color = 'black',

--borders
draw_outline = false,
--default_outline_color = 'D02090',
draw_graph_borders = false,

-- frame
draw_borders = false,

-- color
default_color = '778899',
color1 = 'CD2626', --Firebrick3
color2 = 'FFA500', --orange
color3 = 'FFD700', --gold
color4 = 'ADFF2F', --GreenYellow
color5 = '00CD00', --green3
color6 = '00CED1', --DarkTurquoise
color7 = '87CEEB', --SkyBlue
color8 = '1E90FF', --DodgerBlue1
color9 = 'CA99FF', --VioletRed D02090 -- 9D00FF -- magenta FF44EE

-- position
alignment = 'top_middle',
gap_x = 0,
gap_y = 11,

-- misc
no_buffers = true,
uppercase = false,
cpu_avg_samples = 2,
if_up_strictness = 'address',
use_spacer = 'none',

show_graph_range = false,
show_graph_scale = false,
--default_bar_height = 6,
--default_bar_width = 200,
text_buffer_size = 1000,
override_utf8_locale = true,
--fonts tests:
--LCDMono2
--Lucida Sans
--Neogrey
--PF Tempesta Five Condensed
--PF Tempesta Five Compressed
--Visitor TT1 BRK:Medium:size=9
--Anonymous Pro:Medium:size=8
--Commodore 64 Angled
--Terminus
font = 'Monospace:size=8', --important for shades
template0 = 'Monospace:bold:size=10',
template1 = 'Monospace:bold:size=10',

--•
-- -- Lua load -- #
	lua_load = '~/.conky/script/colorfill2.lua',
	lua_draw_hook_pre = 'conky_main',}

conky.text = [[
${voffset 3}${color1}${exec echo '#!'}${color FF4800} Top: ${color2}${top_mem name 1}\
${goto 180}|${color3} Home: ${color EDFF00}${fs_used_perc /}% (${fs_used /} / ${fs_free /}) \
${goto 370}|${color4} Stock: ${fs_used_perc /media/stock}% \
${goto 450}|${color 32FF00} Share:${color 00FF63} ${fs_used_perc /media/share}%${color 00FF9E} | \
${goto 570} CPU Stress: ${color 00FFD5}${cpu cpu0}% | ${color7}${cpu cpu2}% \
${goto 710}|${color 00AEFF} CPU T°: ${hwmon 0 temp 1}° ${color8}${execi 300 sensors | awk '/Core 0/{gsub("+","");print $3}'} ${color 7D94FF}${execi 300 sensors | awk '/Core 2/{gsub("+","");print $3}'} \
${goto 890}|${color9} Memory: ${memperc}% ${color ED72FF}($mem) \
${color FF4095}${goto 1080}| Net:\
${goto 1140}${color FE361A} ${upspeedf enp0s25} (${totalup enp0s25}) \
${goto 1260}${color FFBB27} ${downspeedf enp0s25} (${totaldown enp0s25}) \

]]

colorfill.lua:

--[[
colorfill.lua
lua script for colors conky
easysid
Monday, 23 January 2017 13:44 IST
Update:
    Tuesday, 24 January 2017
        * Allow conky vars as labels
        * catch nil value errors
]]--

require 'cairo'

-- common
local base = {0xB0B0B0, 0.2} -- {base fill color, alpha}
local font_face = 'White Rabbit'

local settings_t = {
    {
        label = "x",      -- simple label
        arg = "upspeedf enp0s25",
        max = 100,
        x = 1120,
        y = 25,
        color = {0xFF005C, 1},
        font = "ConkyColors",
        size = 20,
    },
    {
        label = "w",      -- simple label
        arg = "downspeedf enp0s25",
        max = 30,
        x = 1240,
        y = 25,
        color = {0xFF9727, 1},
        font = "ConkyColors",
        size = 20,
    },
    {
        label = "f",      -- simple label
        arg = "memperc",
        max = 25,
        x = 1040,
        y = 29,
        color = {0xED72FF, 1},
        font = "ConkyColors",
        size = 25,
    },
    {
        label = "7",        -- no label, use the arg value
        arg = "hwmon 0 temp 1",
        max = 75,
        x = 870,
        y = 29,
        color = {0x7D94FF, 1},
        font = "ConkyColors",
        size = 25
    },
    {
        label = "e",        -- no label, use the arg value
        arg = "cpu cpu0",
        max = 75,
        x = 543,
        y = 29,
        color = {0x00FF9E, 1},
        font = "ConkyColors",
        size = 25
    },
    --[[{
        label = nil,
        arg = "time %S",
        max = 60,
        x = 350,
        y = 100,
        color = {0xCA99FF, 1},
        font = font_face,
        size = 60
    },
    {
        label = "time %B",      -- conky var as a label
        parse_label = true,     -- we need to parse the label value
        arg = "time %m",
        max = 12,
        x = 500,
        y = 90,
        color = {0xd07036, 1},
        font = font_face,
        size = 60
    },
    {
        label = "time %A",
        parse_label = true,
        arg = "time %u",
        max = 7,
        x = 420,
        y = 160,
        color = {0xa9309f, 1},
        font = font_face,
        size = 80
    },--]]
}

-- ###### should not need to edit below this line ###### --

function conky_main()
    if conky_window == nil then return end
    local cs = cairo_xlib_surface_create(conky_window.display,
    conky_window.drawable, conky_window.visual,
    conky_window.width, conky_window.height)
    cr = cairo_create(cs)
    local updates=tonumber(conky_parse('${updates}'))
    if updates > 3 then
        for i in ipairs(settings_t) do
            drawText(settings_t[i])
        end -- for
    end
    cairo_destroy(cr)
    cairo_surface_destroy(cs)
    cr = nil
end --end main()

function drawText(t)
    local text = conky_parse(string.format("${%s}", t.arg))
    local value = tonumber(text)
    -- catch any nil value errors
    if value == nil then
        print(string.format("{%s} returned a nil value", t.arg))
        return
    end
    -- label jugglery
    if t.label then
        text = t.label
        if t.parse_label then
            text = conky_parse(string.format("${%s}", t.label))
        end
    end
    local x = t.x or 100
    local y = t.y or 100
    local font = t.font or "sans"
    local size = t.size or 50
    local col = t.color or {0xFFFFFF, 1}
    local max = t.max or 100
    local perc = 1 - value/max
    local extents=cairo_text_extents_t:create()
    tolua.takeownership(extents)
    cairo_select_font_face(cr, font, 0, 0)
    cairo_set_font_size(cr, size)
    cairo_text_extents(cr, text, extents)
    local w = extents.width
    local h = extents.height
    local pat = cairo_pattern_create_linear(x, y-h, x, y)
    cairo_pattern_add_color_stop_rgba(pat, perc, rgba_to_r_g_b_a(base))
    cairo_pattern_add_color_stop_rgba(pat, perc, rgba_to_r_g_b_a(col))
    cairo_set_source(cr, pat)
    cairo_move_to(cr, x, y)
    cairo_show_text(cr, text)
    cairo_stroke(cr)
end

function rgba_to_r_g_b_a(tcolor)
    local color,alpha=tcolor[1],tcolor[2]
    return ((color / 0x10000) % 0x100) / 255.,
    ((color / 0x100) % 0x100) / 255., (color % 0x100) / 255., alpha
end

Offline

#970 2018-10-08 10:09:46

easysid
Member
Registered: 2016-01-01
Posts: 49

Re: Show us your conky

ragamatrix wrote:

Hello and thank-you easysid, I've played a little with your colorfill.lua script. I made a test with the font ConkyColors to use "letters" as icons that we can fill... I don't know if you like the idea but it works smile

That's a really nice idea smile

Offline

#971 2018-11-03 11:53:28

damo
....moderator....
Registered: 2015-08-20
Posts: 6,734

Re: Show us your conky

Conky for Optimus Nvidia

I haven't found a way to use the output of ${nvidia...} when running a conky on an Optimus laptop - it fails because it can't see the gpu, so the lua script has nothing to draw.

But by using optirun nvidia-smi in a bash script to get the values, and getting the lua script to read them....it is working!
nvidia-post.png

Requirements

  • nvidia-driver (I don't know if things work with nouveau)

  • nvidia-smi: utility to get GPU data

  • nvidia-settings, for the icon

  • bbswitch/optimus setup, to run specific applications with the GPU

__________________________________________________________________________________________

nvidia-optimus.conkyrc

All this does is place the icon and the clock, and provide the window for the lua.
conky.text could be completely empty!

If you have installed nvidia-settings you will find an icon in /usr/share/icons/ or /usr/share/pixmaps/

conky.config = {
--========================  nvidia-optimus.conkyrc  ===========================================
--
-- by damo, November 2018  <damo.linux@gmail.com>
--
--=======================  Based on ideas from...  ===========================================
--  Based on code from sun_rings.lua, which in turn is a modification of 
--  seamod_rings.lua, which is modification of lunatico_rings.lua,
--  which is modification of conky_orange.lua!
--
--  conky_orange.lua:    http://gnome-look.org/content/show.php?content=137503
--  lunatico_rings.lua:  http://gnome-look.org/content/show.php?content=142884
--  seamod_rings.lua:    http://custom-linux.deviantart.com/art/Conky-Seamod-v0-1-283461046
--  sun_rings.lua:       https://forums.bunsenlabs.org/viewtopic.php?pid=49209#p49209
--
-- Ported to Conky v1.10 by damo;
--
--=============================================================================================

    background = true,
    update_interval = 1,
-- uncomment the next line if you are running 2 monitors:
--    xinerama_head = 2,

    cpu_avg_samples = 1,
    net_avg_samples = 2,
    temperature_unit = 'celsius',

    double_buffer = true,
    no_buffers = true,
    text_buffer_size = 2048,

    gap_x = 20,
    gap_y = 20,
    minimum_width = 260, minimum_height = 350,
    maximum_width = 260,

    own_window = true,
    own_window_transparent = true,
    own_window_argb_visual = true,
    own_window_type = 'normal',
    own_window_hints = 'undecorated,skip_taskbar,skip_pager,below,sticky',
    border_inner_margin = 30,
    border_outer_margin = 0,
    alignment = 'top_right',

    draw_shades = false,
    draw_outline = false,
    draw_borders = false,
    draw_graph_borders = false,

    override_utf8_locale = true,
    use_xft = true,
    font = 'Raleway:size=10',
    xftalpha = 1,
    uppercase = false,

-- Defining colors
    default_color = 'FFFFFF',
    color1 = 'FF5B5B',
    color2 = '678b8b',
    color3 = '05C5DA',
    color4 = '8FE03B',

-- Loading lua script for drawing rings
    lua_load = '~/.config/conky/LUA/nvidia-optimus.lua',
    lua_draw_hook_post = 'main',
};

conky.text = [[
${image /usr/share/icons/Paper/48x48/apps/nvidia-settings.png -p 200,10 -s 64x64}
${voffset 57}${alignr}${color4}gpu
${voffset 265}${alignr}${color4}${font Raleway:size=14}${time %H}:${time %M}
]];

__________________________________________________________________________________________

nvidia-optimus.sh

This doesn't have to be made executable, since the lua calls it with "sh" (shell)

#!/bin/bash
##
## ~/.config/conky/scripts/nvidia-optimus.sh
## Script to be called by nvidia-optimus.lua
##
## by damo, November 2018 <damo.linux@gmail.com>
##
########################################################################

OUTPUT=$(optirun nvidia-smi -q)

TEMPERATURE=$(echo "$OUTPUT" | grep 'GPU Current' | awk '{print $(NF-1)}')
TEMP_SLOWDOWN=$(echo "$OUTPUT" | grep 'GPU Slowdown' | awk '{print $(NF-1)}')
TEMP_MAX=$(echo "$OUTPUT" | grep 'GPU Max' | awk '{print $(NF-1)}')
MEM_USED=$(echo "$OUTPUT" | grep 'Used' | awk '{print $(NF-1);exit}')
MEM_TOTAL=$(echo "$OUTPUT" | grep 'Total' | awk '{print $(NF-1);exit}')
UTIL=$(echo "$OUTPUT" | grep 'Gpu' | awk '{print $(NF-1)}')
POWER=$(echo "$OUTPUT" | grep 'Draw' | awk '{print $(NF-1)}')
POWER_MAX=$(echo "$OUTPUT" | grep 'Power Limit'| awk '{print $NF;exit}')

GPU=$(echo "$OUTPUT"| grep 'Product Name' | awk -F ':' '{print $NF}')
DRIVER=$(echo "$OUTPUT" | grep 'Driver Version' | awk '{print $NF}')

# The order of the output is important!! The values are read into an array
# by nvidia-optimus.lua, and the gauges read the values in order.
# Items must correspond exactly with the lua.

## Values for lua gauges{} - FIRST
echo $TEMPERATURE
echo $TEMPERATURE       # used for red high temps sector
echo $MEM_USED
echo $UTIL
echo ${POWER%.*}        # Remove decimals

## Values for text output in lua conky_text{} - SECOND
echo "${GPU#' '}"       # remove leading whitespace
echo "$DRIVER"

## Other values for lua variables - THIRD
echo $TEMP_SLOWDOWN
echo $TEMP_MAX
echo $MEM_TOTAL
echo "$POWER_MAX"

exit

____________________________________________________________________________________________

nvidia-optimus.lua
  • Script path, fonts, colours can be set at the top of the lua script

  • The output values from nvidia-optimus.sh must correspond exactly with the gauge{}, conky_text{} and extra data in the lua script.

  • There will be an initial delay drawing the gauges, while nvidia-smi gathers the data

--==============================================================================
-- nvidia-optimus.lua
-- by damo, November 2018 <damo.linux@gmail.com>
--==============================================================================
--  Based on code from sun_rings.lua by SunForMiles, which in turn is a modification of 
--  seamod_rings.lua, which is a modification of lunatico_rings.lua,
--  which is a modification of conky_orange.lua!
--
--  conky_orange.lua:    http://gnome-look.org/content/show.php?content=137503
--  lunatico_rings.lua:  http://gnome-look.org/content/show.php?content=142884
--  seamod_rings.lua:    http://custom-linux.deviantart.com/art/Conky-Seamod-v0-1-283461046
--  sun_rings.lua:       https://forums.bunsenlabs.org/viewtopic.php?pid=49209#p49209
--==============================================================================

require 'cairo'
--
-- set path to bash script here (script does not have to be executable):
script_path = (os.getenv("HOME")..'/.config/conky/scripts/')
script_name = 'nvidia-optimus.sh'

-- Global settings
-- Add anything you like here, and use it in gauge{} or conky_text{}
-- Values can also be specified in each {} section
font_1 = 'Noto Sans Mono'
font_2 = 'Raleway'
font_size_1 = 10.0
font_size_2 = 12.0
colour_1 = 0x05C5DA
colour_2 = 0x8FE03B

--  GAUGE RINGS DATA
--  NB IMPORTANT!! There must be one section for each gauge value provided by the bash script.
gauge = {
{
    name='nvidia',                 arg='TEMPERATURE',                 max_value=nil, --can be set if known
    x=60,                          y=80,
    graph_radius=30,
    graph_thickness=7,
    graph_start_angle=225,
    graph_unit_angle=2.7,          graph_unit_thickness=2.7,
    graph_bg_colour=0xffffff,      graph_bg_alpha=0.1,
    graph_fg_colour=0x76DFE6,      graph_fg_alpha=0.3,
    hand_fg_colour=0x05C5DA,       hand_fg_alpha=0.5,
    txt_radius=22,                 hand_radius=24,
    hand_width = 2,
    txt_weight=0,                  txt_size=font_size_1,
    txt_fg_colour=colour_1,        txt_fg_alpha=0,
    graduation_radius=23,
    graduation_thickness=0,        graduation_mark_thickness=2,
    graduation_unit_angle=2.7,
    graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
    caption='true',
    caption_weight=0.5,            caption_size=12.0,
    caption_fg_colour=colour_1,    caption_fg_alpha=0.7,
    font = font_2,
},

-- This is a bit of a cheat: layered bg, for red sector, with fg no alpha
   { -- gpu high temps bg section (red)
     -- Set txt_fg_alpha=1 to show slowdown temperature
    name='nvidia',                 arg='TEMPERATURE_BG',                  max_value=11, -- =(max temp)minus(slowdown temp)
    x=60,                          y=80,
    graph_radius=30,
    graph_thickness=7,
    graph_start_angle=108,
    graph_unit_angle=2.7,          graph_unit_thickness=2.7,
    graph_bg_colour=0xff0000,      graph_bg_alpha=0.3,
    graph_fg_colour=0xCE7646,      graph_fg_alpha=0,
    hand_fg_colour=0x477CAF,       hand_fg_alpha=0.0,
    txt_radius=42,                 hand_radius=0,
    hand_width = 0,
    txt_weight=0,                  txt_size=font_size_1,
    txt_fg_colour=0xCE7646,        txt_fg_alpha=1,
    graduation_radius=23,
    graduation_thickness=8,        graduation_mark_thickness=0,
    graduation_unit_angle=2.7,
    graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.5,
    caption='',
    caption_weight=0.5,            caption_size=8.0,
    caption_fg_colour=colour_1,    caption_fg_alpha=0.7,
    font = font_2,
    },
{
    name='nvidia',                 arg='MEM_USED',               max_value=nil, --can be set if known
    x=100,                          y=165,
    graph_radius=30,
    graph_thickness=7,
    graph_start_angle=225,
    graph_unit_angle=0.044,          graph_unit_thickness=2.7,
    graph_bg_colour=0xffffff,      graph_bg_alpha=0.1,
    graph_fg_colour=0x76DFE6,      graph_fg_alpha=0.01,
    hand_fg_colour=0x05C5DA,       hand_fg_alpha=0.5,
    txt_radius=22,                 hand_radius=24,
    hand_width = 2,
    txt_weight=0,                  txt_size=font_size_1,
    txt_fg_colour=0x678b8b,        txt_fg_alpha=0,
    graduation_radius=23,
    graduation_thickness=0,        graduation_mark_thickness=2,
    graduation_unit_angle=2.7,
    graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
    caption='true',
    caption_weight=0.5,            caption_size=12.0,
    caption_fg_colour=colour_1,    caption_fg_alpha=0.7,
    font = font_2,
    },
{
    name='nvidia',                 arg='UTIL',               max_value=100,
    x=160,                          y=250,
    graph_radius=30,
    graph_thickness=7,
    graph_start_angle=225,
    graph_unit_angle=2.7,          graph_unit_thickness=2.7,
    graph_bg_colour=0xffffff,      graph_bg_alpha=0.1,
    graph_fg_colour=0x76DFE6,      graph_fg_alpha=0.3,
    hand_fg_colour=0x05C5DA,       hand_fg_alpha=0.5,
    txt_radius=22,                 hand_radius=24,
    hand_width = 2,
    txt_weight=0,                  txt_size=font_size_1,
    txt_fg_colour=0x678b8b,        txt_fg_alpha=0,
    graduation_radius=23,
    graduation_thickness=0,        graduation_mark_thickness=2,
    graduation_unit_angle=2.7,
    graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
    caption='true',
    caption_weight=0.5,            caption_size=12.0,
    caption_fg_colour=colour_1,    caption_fg_alpha=0.7,
    font = font_2,
    },
{
    name='nvidia',                 arg='POWER',               max_value=nil, --can be set if known
    x=210,                          y=335,
    graph_radius=30,
    graph_thickness=7,
    graph_start_angle=225,
    graph_unit_angle=2.7,          graph_unit_thickness=1.0,
    graph_bg_colour=0xffffff,      graph_bg_alpha=0.1,
    graph_fg_colour=0x76DFE6,      graph_fg_alpha=0.3,
    hand_fg_colour=0x05C5DA,       hand_fg_alpha=0.5,
    hand_width = 2,
    txt_radius=22,                 hand_radius=24,
    txt_weight=0,                  txt_size=font_size_1,
    txt_fg_colour=0x678b8b,        txt_fg_alpha=0,
    graduation_radius=23,
    graduation_thickness=0,        graduation_mark_thickness=2,
    graduation_unit_angle=2.7,
    graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.5,
    caption='true',
    caption_weight=0.5,            caption_size=12.0,
    caption_fg_colour=colour_1,    caption_fg_alpha=0.7,
    font = font_2,
    },
}

-- TEXT
--  NB IMPORTANT!! There must be one {} section for each text value provided by the bash script.

conky_text = {
{   name='GPU',
    x = 110,
    y = 55,
    font = font_2,
    txt_weight=0,                  
    txt_fg_colour=colour_2,
    txt_size=font_size_2,
    txt_fg_alpha=0.7,
    },
{   name='DRIVER',
    x = 110,
    y = 75,
    font = font_2,
    txt_weight=0,                  
    txt_fg_colour=colour_2,
    txt_size=font_size_2,
    txt_fg_alpha=0.7,
    },
}
-------------------------------------------------------------------------------
-- rgb_to_r_g_b
-- converts color in hexa to decimal
--
function rgb_to_r_g_b(colour, alpha)
    return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
-------------------------------------------------------------------------------
-- angle_to_position
-- convert degree to rad and rotate (0 degree is top/north)
--
function angle_to_position(start_angle, current_angle)
    local pos = current_angle + start_angle
    return ( ( pos * (2 * math.pi / 360) ) - (math.pi / 2) )
end

-------------------------------------------------------------------------------
-- draw_gauge_ring
-- displays gauges
--                                                              
function draw_gauge_ring(display, data, value)
    local max_value,graph_unit_angle = set_max_value(data['arg'],data['max_value'],data['graph_unit_angle'])
    local x, y = data['x'], data['y']
    local graph_radius = data['graph_radius']
    local hand_radius = data['hand_radius']
    local hand_width = data['hand_width']
    local graph_thickness, graph_unit_thickness = data['graph_thickness'], data['graph_unit_thickness']
    local graph_start_angle = data['graph_start_angle']
    local graph_bg_colour, graph_bg_alpha = data['graph_bg_colour'], data['graph_bg_alpha']
    local graph_fg_colour, graph_fg_alpha = data['graph_fg_colour'], data['graph_fg_alpha']
    local hand_fg_colour, hand_fg_alpha = data['hand_fg_colour'], data['hand_fg_alpha']
    local graph_end_angle = (max_value * graph_unit_angle) % 360
    local font = data['font']
    local caption = data['caption']

    -- background ring
    cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, 0), angle_to_position(graph_start_angle, graph_end_angle))
    cairo_set_source_rgba(display, rgb_to_r_g_b(graph_bg_colour, graph_bg_alpha))
    cairo_set_line_width(display, graph_thickness)
    cairo_stroke(display)

    -- arc of value
    local val = value % (max_value + 1)
    local start_arc = 0
    local stop_arc = 0
    local i = 1
    while i <= val do
        start_arc = (graph_unit_angle * i) - graph_unit_thickness
        stop_arc = (graph_unit_angle * i)
        cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
        cairo_set_source_rgba(display, rgb_to_r_g_b(graph_fg_colour, graph_fg_alpha))
        cairo_stroke(display)
        i = i + 1
    end
    local angle = start_arc

    -- hand
    start_arc = (graph_unit_angle * val) - graph_unit_thickness
    stop_arc = (graph_unit_angle * val)
    cairo_set_line_width(display, hand_width)
    cairo_move_to(display,x,y)
    cairo_arc(display, x, y, hand_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, start_arc))
    cairo_set_source_rgba(display, rgb_to_r_g_b(hand_fg_colour, hand_fg_alpha))
    cairo_stroke(display)

    -- graduations marks
    local graduation_radius = data['graduation_radius']
    local graduation_thickness, graduation_mark_thickness = data['graduation_thickness'], data['graduation_mark_thickness']
    local graduation_unit_angle = data['graduation_unit_angle']
    local graduation_fg_colour, graduation_fg_alpha = data['graduation_fg_colour'], data['graduation_fg_alpha']
    if graduation_radius > 0 and graduation_thickness > 0 and graduation_unit_angle > 0 then
        local nb_graduation = graph_end_angle / graduation_unit_angle
        local i = 0
        while i < nb_graduation do
            cairo_set_line_width(display, graduation_thickness)
            start_arc = (graduation_unit_angle * i) - (graduation_mark_thickness / 2)
            stop_arc = (graduation_unit_angle * i) + (graduation_mark_thickness / 2)
            cairo_arc(display, x, y, graduation_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
            cairo_set_source_rgba(display,rgb_to_r_g_b(graduation_fg_colour,graduation_fg_alpha))
            cairo_stroke(display)
            cairo_set_line_width(display, graph_thickness)
            i = i + 1
        end
    end

    -- gauge text - displays value at gauge pointer position.
    -- Except for display of slowdown temperature on temperature gauge:
    if data['arg'] == "TEMPERATURE_BG" then
        if temp_slowdown == nil then
            data['txt_fg_alpha'] = 0
        else
            data['txt_fg_alpha'] = 1
            value = 'Slowdown '..temp_slowdown..' °C'
            graph_start_angle = 108
            angle = 0
        end
    end

    local txt_radius = data['txt_radius']
    local txt_weight, txt_size = data['txt_weight'], data['txt_size']
    local txt_fg_colour, txt_fg_alpha = data['txt_fg_colour'], data['txt_fg_alpha']
    local movex = txt_radius * math.cos(angle_to_position(graph_start_angle, angle))
    local movey = txt_radius * math.sin(angle_to_position(graph_start_angle, angle))
        
    cairo_select_font_face (display, font, CAIRO_FONT_SLANT_NORMAL, txt_weight)
    cairo_set_font_size (display, txt_size)
    cairo_set_source_rgba (display, rgb_to_r_g_b(txt_fg_colour, txt_fg_alpha))
    cairo_move_to (display, x + movex - (txt_size / 2), y + movey + 3)
    
    cairo_show_text (display, value)
    cairo_stroke (display)

    -- caption
    caption = display_caption(caption,value,data['arg'])
    
    local caption_weight, caption_size = data['caption_weight'], data['caption_size']
    local caption_fg_colour, caption_fg_alpha = data['caption_fg_colour'], data['caption_fg_alpha']
    local tox = graph_radius * (math.cos((graph_start_angle * 2 * math.pi / 360)-(math.pi/2)))
    local toy = graph_radius * (math.sin((graph_start_angle * 2 * math.pi / 360)-(math.pi/2)))
    cairo_select_font_face (display, font, CAIRO_FONT_SLANT_NORMAL, caption_weight);
    cairo_set_font_size (display, caption_size)
    cairo_set_source_rgba (display, rgb_to_r_g_b(caption_fg_colour, caption_fg_alpha))
    cairo_move_to (display, x + tox + 2, y + toy + 20)
    cairo_show_text (display, caption)
    cairo_stroke (display)
end
------------------------------------------------------------------------
-- display_text
-- 
function display_text(display,data,value)

    local text_weight, text_size = data['txt_weight'], data['txt_size']
    local text_fg_colour, text_fg_alpha = data['txt_fg_colour'], data['txt_fg_alpha']
    local font = data['font']   
    local x, y = data['x'], data['y']
    
    cairo_select_font_face (display, font, CAIRO_FONT_SLANT_NORMAL, text_weight);
    cairo_set_font_size (display, text_size)
    cairo_set_source_rgba (display, rgb_to_r_g_b(text_fg_colour, text_fg_alpha))
    cairo_move_to (display, x, y)
    if data['name'] == "DRIVER" then
        value = "Driver: "..value
    end
    cairo_show_text (display, value)
    cairo_stroke (display)
end
------------------------------------------------------------------------
-- Format gauge caption
--
function display_caption(caption,val,arg)
    if caption == "true" and arg == "TEMPERATURE" then
        caption = ("Temperature: "..val.."°C")
    elseif caption == "true" and arg == "POWER" then
        caption = ("Power: "..val.." Watts")
    elseif caption == "true" and arg == "MEM_USED" then
        if mem_total == nil then
            caption = ("Memory used: "..val.." MB")
        else
            caption = ("Memory used: "..val.." MB / "..mem_total.." MB")
        end
    elseif caption == "true" and arg == "UTIL" then
        caption = ("GPU Utilization: "..val.."%")
    end

    return caption
end
------------------------------------------------------------------------
-- set maximum values if available, else sane defaults
function set_max_value(arg, maxval, u_angle)
    if arg == 'TEMPERATURE' then
        if temp_max ~= nil then
            maxval = temp_max
        else
            maxval = 100
        end
        u_angle = 270/maxval
        u_angle = tonumber(string.format('%.2f',u_angle))
        
    elseif arg == 'MEM_USED' then
        if mem_total ~= nil then
            maxval = mem_total
        else
            maxval = 2048
        end
        u_angle = 270/maxval
        u_angle = tonumber(string.format('%.3f',u_angle))
        
    elseif arg == 'POWER' then
        if power_max ~= nil then
            maxval = power_max
        else 
            maxval = 300
        end
        if maxval == 'N/A' then
            maxval = 300
        end
        u_angle = 270/maxval
        u_angle = tonumber(string.format('%f',u_angle))
    end
    
    return maxval, u_angle
end
------------------------------------------------------------------------
-- go_gauge_rings
-- loads data and displays gauges
--
function go_gauge_rings(display)
    
    -- get array values from output of bash script
    local val_array = {}
    local val_f = io.popen('sh '..script_path..script_name)
    local n = 1
    for line in val_f:lines() do
        table.insert(val_array,line)
        n = n+1
    end
    val_f:close()
    
    local function load_rings(display, data, value)
        if data['name'] == 'nvidia' then 
            draw_gauge_ring(display, data, value)
        end
    end
        
    local function show_data()
        local j = 1
        for i in pairs(gauge) do
            load_rings(display, gauge[i], val_array[j])
            j = j+1        
        end
    
        for n in pairs(conky_text) do
            display_text(display,conky_text[n],val_array[j])
            j = j+1 
        end
        
        -- add extra data here, if required (THIRD section in bash script output)
        -- NB IMPORTANT!! Variables must correspond to the order in the bash script
        temp_slowdown = val_array[j] -- global var, used by Temperature gauge
        temp_max = val_array[j+1]    -- global var, used by Temperature gauge
        mem_total = val_array[j+2]   -- global var, used by display_caption()
        power_max = val_array[j+3]   -- global var, used by Power gauge
    end

    show_data()      -- use array data for drawing gauges and text

end

-------------------------------------------------------------------------------
--  MAIN
function conky_main()
    if conky_window == nil then
        return
    end

    local cs = cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, conky_window.width, conky_window.height)
    local display = cairo_create(cs)

    local updates = conky_parse('${updates}')
    update_num = tonumber(updates)

    if update_num > 5 then
        go_gauge_rings(display)
    end

    cairo_surface_destroy(cs)
    cairo_destroy(display)
end

Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#972 2018-11-04 17:30:56

hhh
Gaucho
From: High in the Custerdome
Registered: 2015-09-17
Posts: 16,032
Website

Re: Show us your conky

@damo, slick!


No, he can't sleep on the floor. What do you think I'm yelling for?!!!

Offline

#973 2018-12-17 13:57:30

loutch
Member
Registered: 2015-12-12
Posts: 848

Re: Show us your conky

Hello

Guy's i have a problem with this calendar with linuxmint Sarah

1545054887.png

(the same code work great with M5 kde)


1544689576.png


The code from calendar

${goto 200}${color #E1EAE9}${font monospace:pixelsize=12}${offset 62}${execi 1800 date +%^B | cut -c1}${execi 1800 date +%B | cut -c2-} ${time (%m)}
${goto 8}${color #E1EAE9}${execpi 60 DJS=`date +%_d`; cal | sed '/./!d' | sed '1d'  | sed 's/$/                /' | fold -w 21 | sed -n '/^.\{21\}/p' | sed 's/^/                             /' | sed /" $DJS "/s/" $DJS "/" "'${color #E1EAE9}'"$DJS"'${color #676B6A}'" "/}

any idea ??

tanks for helping

@+

Last edited by loutch (2018-12-17 14:00:01)


Linuxmint 22.1 Xia xfce & mageia 9 XFCE on ssd hp pavilion g7
Xubuntu 18.04 lts & 24.04 lts on ASUS Rog STRIX

Offline

#974 2018-12-17 18:24:11

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 2,640

Re: Show us your conky

Hello loutch,
works here (currently antiX)

DJS=`date +%_d`; cal | sed '/./!d' | sed '1d'  | sed 's/$/                /' | fold -w 21 | sed -n '/^.\{21\}/p' | sed 's/^/                             /' | sed /" $DJS "/s/" $DJS "/" "'${color #E1EAE9}'"$DJS"'${color #676B6A}'" "/
                             So Mo Di Mi Do Fr Sa 
                                                1 
                              2  3  4  5  6  7  8 
                              9 10 11 12 13 14 15 
                             16 17 18 19 20 21 22 
                             23 24 25 26 27 28 29 
                             30 31  

In my opinion, this is due to different ISO 8601 formatting in the respective distri packages. I had a similar case with ncal in mageia.
Since then I always use this configuration of Sector11

#${lua conky_draw_bg 10 0 0 0 0 0x000000 0.2}
TEXT
${alignc}${color0}${time %T}
 ${time %b %Y}${alignr 15}Woche ${time %V}${color}
${alignc}${if_match ${time %u}==1}${color0}Mo${color1} Di Mi Do Fr Sa So ${else}\
${if_match ${time %u}==2}${color1}Mo ${color0}Di${color1} Mi Do Fr Sa So${else}\
${if_match ${time %u}==3}${color1}Mo Di ${color0}Mi${color1} Do Fr Sa So${else}\
${if_match ${time %u}==4}${color1}Mo Di Mi ${color0}Do${color1} Fr Sa So${else}\
${if_match ${time %u}==5}${color1}Mo Di Mi Do ${color0}Fr${color1} Sa So${else}\
${if_match ${time %u}==6}${color1}Mo Di Mi Do Fr ${color0}Sa${color1} So${else}\
${if_match ${time %u}==7}${color1}Mo Di Mi Do Fr Sa ${color0}So${color1}${else}
${endif}${endif}${endif}${endif}${endif}${endif}${endif}
${alignc}  ${color1}${execpi 1800 LAR=`date +%-d`; ncal -bhM | sed '2d' | sed -e '1d' -e 's/\<'$LAR'\>/${color0}&${color1}/' | sed ':a;N;$!ba;s/\n/\n${alignc}  /g'}${color}

or the script of Crinos512 and xaos52

#!/usr/bin/env python
# by Crinos512
#regex tweaked by xaos52
#https://forums.bunsenlabs.org/viewtopic.php?pid=11683#p11683
import time, calendar, re

localtime = time.localtime(time.time())
calendar.setfirstweekday(calendar.SUNDAY)
#calendar.setfirstweekday(calendar.MONDAY)
cal = calendar.month(localtime[0], localtime[1])

parts = cal.split('\n')
cal = '${color0}${goto 85}' + '\n${goto 85}'.join(parts)
regex = '(?<=\})%s(?= )|(?<= )%s(?= )|(?<=\n)%s(?= )|(?<= )%s(?=\n)|(?<=\})%s(?=\n)' % (localtime[2], localtime[2], localtime[2], localtime[2], localtime[2])
replace = '${color8}%s${color0}' % localtime[2]
newCal = re.sub(regex, replace, cal)
print newCal

Offline

#975 2018-12-18 08:17:44

loutch
Member
Registered: 2015-12-12
Posts: 848

Re: Show us your conky

hello unklar

Ich habe etwas gefunden und es fonctionniert hier.

${font monospace:pixelsize=12}${goto 200}${color #E1EAE9}${execpi 80000 ncal -MCh|sed '/\(20[0-9][0-9]\)/!s/^.*$/${offset 200} &/;/\(20[0-9][0-9]\)/!s/.\{8\}$/&/;s/ '"`date +%_d`"' /${color #E1EAE9} '"`date +%_d`"'${color #676B6A} /;//!s/ '"`date +%_d`"'$c/ '"`date +%_d`"'$c/;//!s/ '"`date +%_d`"' / '"`date +%_d`"'/'}
${voffset -112}${goto 320}${color #E1EAE9}${time (%m)}

1545121087.png

Noch danke schon und

@+


edit

mageia 5 immer noch die Beste

Last edited by loutch (2018-12-18 08:26:41)


Linuxmint 22.1 Xia xfce & mageia 9 XFCE on ssd hp pavilion g7
Xubuntu 18.04 lts & 24.04 lts on ASUS Rog STRIX

Offline

#976 2018-12-18 08:23:53

Döbbie03
Resident Metalhead
From: New Zealand
Registered: 2015-09-29
Posts: 3,853

Re: Show us your conky

loutch wrote:

hello unklar

Ich habe etwas gefunden und es fonctionniert hier.

${font monospace:pixelsize=12}${goto 200}${color #E1EAE9}${execpi 80000 ncal -MCh|sed '/\(20[0-9][0-9]\)/!s/^.*$/${offset 200} &/;/\(20[0-9][0-9]\)/!s/.\{8\}$/&/;s/ '"`date +%_d`"' /${color #E1EAE9} '"`date +%_d`"'${color #676B6A} /;//!s/ '"`date +%_d`"'$c/ '"`date +%_d`"'$c/;//!s/ '"`date +%_d`"' / '"`date +%_d`"'/'}
${voffset -112}${goto 320}${color #E1EAE9}${time (%m)}

http://pix.tdct.org/upload/img/1545121087.png

Noch danke schon und

@+

Very nice minimal conky there.


"All we are is dust in the wind, dude"
                                       - Theodore "Ted" Logan
"Led Zeppelin didn't write tunes that everybody liked, they left that to the Bee Gees."
                                       - Wayne Campbell

Offline

#977 2018-12-18 10:47:59

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 2,640

Re: Show us your conky

@loutch
Je suis content que ça marche pour toi maintenant.
C'est toi le maître !  wink

loutch, si vous avez le temps, jetez un coup d'oeil à ce problème.
Dans conky-Syntax1.10 j'ai encore le problème de ce changement d'image. Avec le temps de recherche, je pourrais le réduire. Elle est toujours là, cependant.

${texeci 5 ~/.conky/radiotray/pochette.sh}${texeci 2 ~/.conky/radiotray/logo.sh}

à la suite de

${texeci 3 ~/.conky/radiotray/pochette.sh}${texeci 5 ~/.conky/radiotray/logo.sh}

edit

mageia 5 immer noch die Beste

good.gif

Last edited by unklar (2018-12-18 10:54:24)

Offline

#978 2018-12-18 14:24:19

loutch
Member
Registered: 2015-12-12
Posts: 848

Re: Show us your conky

Re

Ich habe noch keine conky in 1.10 immer noch der alte 1.09 .

Ich probiere die neue Mageia7 xfce in virtualbox ,sie hat conky 1.10 ich guck mal dran .

@+


Linuxmint 22.1 Xia xfce & mageia 9 XFCE on ssd hp pavilion g7
Xubuntu 18.04 lts & 24.04 lts on ASUS Rog STRIX

Offline

#979 2018-12-18 19:00:03

unklar
Back to the roots 1.9
From: #! BL
Registered: 2015-10-31
Posts: 2,640

Re: Show us your conky

@Teo, can you please check these two scripts and do with lynx instead of wget ?

loutch suspects the error of constant image change in wget.  smile

Offline

#980 2018-12-19 09:10:18

loutch
Member
Registered: 2015-12-12
Posts: 848

Re: Show us your conky

Hello

@Theo i begin any think with linx & i have any pochette.png in my radiotray folder .The Google part is too havy for me

here my work

#!bin/bash
#créé par loutch

 
titre=$(head -1 ~/.conky/radiotray/artiste_titre.txt)
lienMiniature=$(lynx -source 'Googlebot-Image/1.0' -qO - "www.google.fr/search?q=$titre\&tbm=isch" | perl -pe 's!.*?<img .*?src="([^"]*)".*!$1!') > pochette.png

Tank for helping us



@+

Last edited by loutch (2018-12-19 09:11:15)


Linuxmint 22.1 Xia xfce & mageia 9 XFCE on ssd hp pavilion g7
Xubuntu 18.04 lts & 24.04 lts on ASUS Rog STRIX

Offline

Board footer

Powered by FluxBB