You are not logged in.
Hello
Guys i need your help for my radiotray conky .
Some radios done this : example for this title
Reggae Night || 3133 || S || 64416e03-a40d-42b4-bb3c-bd936fced63d
& i would have just the title before || like this
Reggae Night
here the code line i'm used
${execi 4 qdbus com.github.radiotray_ng /com/github/radiotray_ng com.github.radiotray_ng.get_player_state | jq -r '.title'}
i try this but not work
${execi 4 qdbus com.github.radiotray_ng /com/github/radiotray_ng com.github.radiotray_ng.get_player_state | jq -r '.title' | awk '{printf("%d\n",$1)}'}
many tanks &
@+
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
Instead of awk (which is generally way over my head ) I would use cut like this:
${execi 4 qdbus com.github.radiotray_ng /com/github/radiotray_ng com.github.radiotray_ng.get_player_state | jq -r '.title' | cut -d'|' -f1}
It only accepts a single character as filed delimiter and thus may behave strange for every field number over 1, but this shouldn't be a problem right?
"Kaum macht [Mensch]* es richtig, funktioniert es sofort!"
BL-Kitchen Codeberg
Offline
Hello
Guys i need your help for my radiotray conky .
@+
KoO over at ArchLabs found this.
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
Hello
Guys , many tanks , conky work great with Naik's code .
@+
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
KUDO's to Naik
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
*blush*
de nada!
"Kaum macht [Mensch]* es richtig, funktioniert es sofort!"
BL-Kitchen Codeberg
Offline
Radiotray-NG
Some useful commands for conky.
Artist + Song:
$ pacmd list-sink-inputs | grep -A 2 'Radiotray-NG' | awk 'END{print}' | awk -F'"' '{print $2}'
Arthur Godfrey - Hello In There
Artist:
$ pacmd list-sink-inputs | grep -A 2 'Radiotray-NG' | awk 'END{print}' | awk -F'"' '{print $2}' | awk -F' - ' '{print $1}'
Arthur Godfrey
Song:
$ pacmd list-sink-inputs | grep -A 2 'Radiotray-NG' | awk 'END{print}' | awk -F'"' '{print $2}' | awk -F' - ' '{print $2}'
Hello In There
Conky example:
${font Ubuntu:size=10:italic}${alignc}${color 0098FF}Radio Tray \
${if_empty ${texeci 5 pacmd list-sink-inputs | grep 'Radiotray-NG'}}${color FF8080}Disabled\
${else}${color F2DA40}${texeci 5 pacmd list-sink-inputs | grep -A 2 'Radiotray-NG' | awk 'END{print}' | awk -F'"' '{print $2}' | sed 's/-/ - /g'}${endif}
Last edited by marens (2023-03-26 13:20:47)
If people would know how little brain is ruling the world, they would die of fear.
Offline
@marens,
Very nice!
Offline
@marens,
Very nice!
Thanks.
If people would know how little brain is ruling the world, they would die of fear.
Offline
Hello
@ unklar
mein freund funktioniert dieser conky noch, wenn ja könnte ich die Skripte haben
Danke.
@+
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
@loutch, mon ami, il fonctionne encore
Tu es déjà le deuxième.
Je laisse tomber le .conkyrc, juste ces lignes (si tu en as besoin en entier, dis-le moi) :
---Lua--
lua_load = '~/damo-weather/lua1-weather.lua',
lua_draw_hook_pre = 'conky_main',
};
conky.text = [[
${execpi 1800 bash $HOME/damo-weather/lua-weather.sh Chemnitz}
#${color0}${voffset 170}${alignc -30}${font monofur bold:size=7}Chemnitz${font}
]];
lua-weather.sh
#!/bin/bash
#
## lua-weather.sh by <damo> July 2016
## Adapted from bunsenweather.sh, which was based on ideas from
## weatherbang.sh version 1.0, 2013 by Ryan Fantus
##
## Requires:
## 'jq' (sudo apt-get install jq);
## API Key from http://openweathermap.org/api
##
## USAGE: Call this script from Conky with ( replace "<t>" with the update interval)
## ${execpi <t> /path/to/lua-weather.sh [location]}
#### User configurables: ##############################################
# Get API KEY by registering for one at http://openweathermap.org/api
api="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Either set the location manually here, or by passing it as a script parameter in the Conky.
# "yourlocation" must be a name (which doesn't have spaces), or a numeric id.
#
# id's can be obtained from http://bulk.openweathermap.org/sample/city.list.json.gz
# Download and extract the json file, then simply search for an id with grep.
# For example: grep "New York" city.list.json
#
# If $place is not set, then the script attempts to get a geolocation from the IP address.
LANG="en_GB.UTF-8"
#place="$1" # Get $place from script parameter.
place="Chemnitz" # Uncomment and add name or id. NB If the name has spaces, then you must use the id.
# Choose fahrenheit/Imperial or Celcius/metric:
#metric='imperial'
metric='metric'
# data file
datafile="/tmp/weather.txt"
#########################################################################
connectiontest() {
local -i i attempts=${1-0}
for (( i=0; i < attempts || attempts == 0; i++ )); do
if wget -o /dev/null -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 "Weather information unavailable"
else
echo "No API key"
echo "Weather information unavailable"
fi
}
if [[ $metric == metric ]] &>/dev/null;then
scaleT="°C"
scaleV="m/s"
else
scaleT="°F"
scaleV="mph"
fi
if [[ -z "$api" ]] &>/dev/null;then
placeholder 0 && exit 1
else
connectiontest 10
# If latlong is preferred then don't set a value for $place
if (( $? == 0 )) &>/dev/null;then
if [[ -z $place ]] &>/dev/null;then
# Geolocate IP:
ipinfo=$(curl -s ipinfo.io)
latlong=$(echo "$ipinfo" | jq -r '.loc')
# Parse the latitude and longitude
lat=${latlong%,*}
long=${latlong#*,}
location="lat=$lat&lon=$long"
else
# check if numeric id, or placename is being used
[[ ${place##*[!0-9]*} ]] &>/dev/null && location="id=$place" || location="q=$place"
fi
# get json data from openweathermap:
weather=$(curl -s http://api.openweathermap.org/data/2.5/weather\?APPID=$api\&"$location"\&units=$metric)
city=$(echo "$weather" | jq -r '.name') # In case location has spaces in the name
weather_desc=$(echo "$weather" | jq -r '.weather[0].description') # In case description has spaces in the name
# load values into array:
all=($(echo "$weather" | jq -r '.coord.lon,.coord.lat,.weather[0].main,.main.temp,.main.pressure,.main.temp_min,.main.temp_max,.wind.speed,.wind.deg,.clouds.all,.sys.sunrise,.sys.sunset'))
# ARRAY INDEX 0 1 2 3 4 5 6 7 8 9 10 11
longitude=$(printf '%06.1f' ${all[0]})
latitude=$(printf '%+.1f' ${all[1]})
condition="${all[2]}"
temperature=$(printf '%+.1f%s' ${all[3]} $scaleT)
pressure=$(printf '%.f %s' ${all[4]} mb)
temperature_min=$(printf '%+.1f%s' ${all[5]} $scaleT)
temperature_max=$(printf '%+.1f%s' ${all[6]} $scaleT)
cloud_cover=$(printf '%d%s' ${all[9]} %)
sunrise=$(date -d @${all[10]} +"%R")
sunset=$(date -d @${all[11]} +"%R")
description="$weather_desc"
winddir=$(printf '%3.f%s' ${all[8]} °)
winddir=${all[8]}
echo ${winddir%.*} > "$datafile"
windspeed=$(echo ${all[7]})
windspeed=$(printf '%s %s' "$windspeed" "m/s")
echo "$windspeed" | sed 's/,/./' >> "$datafile"
echo "$sunrise" | sed 's/://' >> "$datafile"
echo "$sunset" | sed 's/://'>> "$datafile"
temp_degrees=$(printf '%.1f' ${all[3]})
echo "$temp_degrees" >> "$datafile"
echo "$city" >> "$datafile"
echo "$description" >> "$datafile"
else
placeholder 1
fi
fi
exit
lua1-weather.lua c'est ce que j'ai travaillé à l'époque. J'ai aussi l'original quelque part.
--[[
lua-weather.lua, written by <damo>, July 2016
---------------------------------------------
Use this in a conky with
lua_load /path/to/lua-weather.lua
lua_draw_hook_pre conky_main
In the conky, get the weather data from lua-weather.sh with
TEXT
${execi <interval> /path/to/lua-weather.sh}
---------------------------------------------]]
require 'cairo'
-- set default font
--fontface="Dustismo"
fontface="Liberation"
function conky_main()
if conky_window==nil then return end
cs=cairo_xlib_surface_create(conky_window.display,
conky_window.drawable,
conky_window.visual,
conky_window.width,
conky_window.height)
cr=cairo_create(cs)
xW=190 -- x pos wind dial centre
yW=90 -- y pos wind dial centre
radiusW=55 -- radiusW wind dial
xT=20 -- x pos temp bar (top)
yT=10 -- y pos temp bar (top)
wT=6 -- width temp bar
hT=150 -- height temp bar
xSun=190 -- x pos sun dial centre
ySun=90 -- y pos sun dial centre
radiusSun=80-- radius sun dial
datafile="/tmp/weather.txt" -- textfile to hold lua-weather.sh output
direction,windS,temperature,sunrise,sunset,loc,wx = get_vals()
local updates=conky_parse('${updates}')
update_num=tonumber(updates)
-- Edit this for concentric dials ---------------------------------
concentric = 0 --<-- Change to "1" to display concentric rings
if ( concentric == 1 ) then
xSun = 300
ySun = 100
radiusSun = 90
xW = xSun
yW = ySun
radiusW = 0.7*radiusSun
end
------------------------------------------------------------------------
if update_num>1 then
draw_widgets()
end
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end
-- Choose the widgets to be displayed:
function draw_widgets()
draw_thermometer(cr,xT,yT,wT,hT)
draw_wind_rose()
draw_sun_ring()
end
-- read values from datafile
function get_vals()
local path = datafile
local file = io.open( path)
local array = {}
local i=0
if (file) then
-- read all contents of file into array
for line in file:lines() do
i=i+1
array[i]=line
end
file:close()
dir=tostring(array[1]) -- get wind direction, convert to value required
if ( dir == "null" ) then
winddir=-math.pi*(tonumber(0))/180
wind_speed="No wind data"
else
winddir=-math.pi*(tonumber(dir))/180
wind_speed=tostring(array[2]) -- windspeed knots
end
temperature=tonumber(array[5])
sunrise=array[3]
sunset=array[4]
location=array[6]
weather=array[7]
return winddir,wind_speed,temperature,sunrise,sunset,location,weather
else
print("datafile " .. datafile .. " not found")
end
end
-- convert degree to rad
function angle_to_position(start_angle, current_angle)
local pos = start_angle + current_angle
return pos * math.pi/180
end
function draw_sun_ring()
-- local hours=20
-- local mins=0
local hours=os.date("%H")
local mins=os.date("%M")
current_time=(hours .. mins)
mins_arc = 360/60*mins
hours_arc = (360/24*hours + mins_arc/24) + 90
start_angle = 90 -- south
end_angle = 360
start_arc = 0
stop_arc = 0
-- get times and angle position from function sun_rise_set()
sunrise,sunset,sun_rise,sun_set = sun_rise_set()
local border_pat=cairo_pattern_create_linear(xSun,ySun-radiusSun*1.25,xSun,ySun+radiusSun*1.25)
cairo_pattern_add_color_stop_rgba(border_pat,0,1,1,0,0.7)
cairo_pattern_add_color_stop_rgba(border_pat,0.4,0.9,0.9,0.2,0.6)
cairo_pattern_add_color_stop_rgba(border_pat,0.55,0.9,0.2,0,0.6)
cairo_pattern_add_color_stop_rgba(border_pat,0.7,0,0.1,1,0.7)
cairo_set_source(cr,border_pat)
-- draw ring, starting at south position ( = midnight/00hrs)
cairo_arc(cr, xSun, ySun, radiusSun, angle_to_position(start_angle, 0), angle_to_position(start_angle, end_angle))
-- set width of ring
cairo_set_line_width(cr,radiusSun*0.06)
cairo_stroke(cr)
cairo_pattern_destroy (pat)
-- draw sun
-- get position on circumference ( = time from midnight (south), 24hr clock)
sun_pos=angle_to_position(start_angle,hours_arc)
local sunx=xSun - (math.sin(-sun_pos)*radiusSun)
local suny=ySun - (math.cos(-sun_pos)*radiusSun)
-- set colour & alpha, for day/night
if ( tonumber(current_time) > tonumber(sunrise) ) and ( tonumber(current_time) < tonumber(sunset) ) then
r,g,b,a = 1,1,0,0.9 --day
else
r,g,b,a = 0.5,0.5,0.5,0.9 --night
end
cairo_set_source_rgba (cr,r,g,b,a)
cairo_arc(cr,sunx,suny,radiusSun*0.09,0,360)
cairo_fill(cr)
local r,g,b,a = 1,1,0,0.9
cairo_set_source_rgba (cr,r,g,b,a)
cairo_set_line_width(cr,2)
cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND)
-- draw sunrise mark
local sunrise_x=xSun - (math.sin(-sun_rise)*radiusSun*1.05)
local sunrise_y=ySun - (math.cos(-sun_rise)*radiusSun*1.05)
local sunrise_xc=xSun - (math.sin(-sun_rise)*radiusSun*0.95)
local sunrise_yc=ySun - (math.cos(-sun_rise)*radiusSun*0.95)
cairo_move_to(cr,sunrise_x,sunrise_y)
cairo_line_to(cr,sunrise_xc,sunrise_yc)
cairo_stroke(cr)
-- draw sunset mark
local sunset_x=xSun - (math.sin(-sun_set)*radiusSun*1.05)
local sunset_y=ySun - (math.cos(-sun_set)*radiusSun*1.05)
local sunset_xc=xSun - (math.sin(-sun_set)*radiusSun*0.95)
local sunset_yc=ySun - (math.cos(-sun_set)*radiusSun*0.95)
local r,g,b,a = 1,0,0,0.6
cairo_set_source_rgba (cr,r,g,b,a)
cairo_move_to(cr,sunset_x,sunset_y)
cairo_line_to(cr,sunset_xc,sunset_yc)
cairo_stroke(cr)
-- print sunrise/sunset text
sun_text(sunrise_x,sunrise_y,sunset_x,sunset_y)
end
function sun_text(xr,yr,xs,ys)
-- display sunrise time
sunrise1 = string.sub(sunrise,1,2)
sunrise2 = string.sub(sunrise,3,4)
sunset1 = string.sub(sunset,1,2)
sunset2 = string.sub(sunset,3,4)
local sunrise = ( sunrise1 .. ":" .. sunrise2 )
local sunset = ( sunset1 .. ":" .. sunset2 )
local r,g,b,a = 1,1,0,0.6
cairo_set_source_rgba (cr,r,g,b,a)
print_text(cr,sunrise,xr-4,yr,4,12)
print_text(cr,"sunrise",xr-4,yr+8,4,12)
-- display sunset time
local r,g,b,a = 1,0,0,0.6
cairo_set_source_rgba (cr,r,g,b,a)
print_text(cr,sunset,xs,ys+10,0,12)
print_text(cr,"sunset",xs,ys+18,0,12)
-- print("concentric= " .. concentric)
if ( concentric == 0 ) then
-- display time
--[[ local current_time = os.date("%H:%M")
local fontface="Dustismo"
local r,g,b,a = 1,1,1,0.6
cairo_set_source_rgba (cr,r,g,b,a)
cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
cairo_set_font_size (cr,24)
local xt,yt = position_text(cr,current_time,xSun,ySun-6,2)
cairo_move_to (cr,xt,yt)
cairo_show_text (cr,current_time)
cairo_stroke (cr)
-- display date
local cal = os.date("%a %d %b")
local fontface="Dustismo"
local r,g,b,a = 1,1,1,0.6
cairo_set_source_rgba (cr,r,g,b,a)
cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
cairo_set_font_size (cr,12)
local xt,yt = position_text(cr,cal,xSun,ySun+10,1)
cairo_move_to (cr,xt,yt)
cairo_show_text (cr,cal)
cairo_stroke (cr)
-- print location
local fontface="Dustismo"
local r,g,b,a = 1,1,1,0.7
cairo_set_source_rgba (cr,r,g,b,a)
cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
cairo_set_font_size (cr,10)
local xt,yt = position_text(cr,loc,xSun,ySun+25,1)
cairo_move_to (cr,xt,yt)
cairo_show_text (cr,loc)
--]] cairo_stroke (cr)
else
print_location_text(xSun,ySun+1.4*radiusSun)
end
end
function print_location_text(x,y)
-- display time
local current_time = os.date("%H%M")
local fontface="Dustismo"
local r,g,b,a = 1,1,1,0.6
cairo_set_source_rgba (cr,r,g,b,a)
cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
cairo_set_font_size (cr,24)
local xt,yt = position_text(cr,current_time,x,y,2)
cairo_move_to (cr,xt,yt)
cairo_show_text (cr,current_time)
cairo_stroke (cr)
-- display date
local cal = os.date("%a %d %b")
local fontface="Dustismo"
local r,g,b,a = 1,1,1,0.6
cairo_set_source_rgba (cr,r,g,b,a)
cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
cairo_set_font_size (cr,12)
local xt,yt = position_text(cr,cal,x,y+10,1)
cairo_move_to (cr,xt,yt)
cairo_show_text (cr,cal)
cairo_stroke (cr)
-- print location
local fontface="Dustismo"
local r,g,b,a = 1,1,1,0.7
cairo_set_source_rgba (cr,r,g,b,a)
cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
cairo_set_font_size (cr,10)
local xt,yt = position_text(cr,loc,x,y+25,1)
cairo_move_to (cr,xt,yt)
cairo_show_text (cr,loc)
cairo_stroke (cr)
end
function sun_rise_set()
sunupH = string.sub(sunrise,1,2)
sunupM = string.sub(sunrise,3,4)
sundownH = string.sub(sunset,1,2)
sundownM = string.sub(sunset,3,4)
minSR_arc = 360/60*sunupM
hourSR_arc = (360/24*sunupH + minSR_arc/24) + 90
pos_SR = angle_to_position(start_angle,hourSR_arc)
minSS_arc = 360/60*sundownM
hourSS_arc = (360/24*sundownH + minSS_arc/24) + 90
pos_SS = angle_to_position(start_angle,hourSS_arc)
return sunrise,sunset,pos_SR,pos_SS
end
function draw_thermometer(cr,x,y,wT,hT)
local alpha=0.7
HT = y+hT
pat = cairo_pattern_create_linear (x,y,wT,HT)
cairo_pattern_add_color_stop_rgba (pat, 1, 0, 0, 1, alpha)
cairo_pattern_add_color_stop_rgba (pat, 0.4, 1,0.8, 0, alpha)
cairo_pattern_add_color_stop_rgba (pat, 0.3, 1,0.3, 0, alpha)
cairo_pattern_add_color_stop_rgba (pat, 0, 1,0, 0, alpha)
cairo_rectangle (cr, x,y,wT,HT)
cairo_set_source (cr, pat)
cairo_fill (cr)
cairo_pattern_destroy (pat)
draw_temperature(cr,x,y,hT,temperature)
end
function draw_temperature(cr,x,y,hT,Tdegrees)
local range=hT/100
local zero = y + range*60
local T = Tdegrees*range
t = tostring(Tdegrees)
t = ( t .. "°C" )
cairo_set_source_rgba (cr,1,1,1,0.7)
cairo_set_line_width(cr,1)
for i = 0,100,10 do -- draw 10 degree marks
local l = 3
local xT = x-1
if ( i == 60 ) then -- longer mark for freezing point
xT = x-6
l = -12
end
cairo_move_to (cr,xT,y)
cairo_rel_line_to (cr,-l,0)
cairo_stroke (cr)
y = y + range*10
end
cairo_set_source_rgba (cr,1,1,1,0.7)
cairo_set_line_width(cr,3)
cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND)
cairo_move_to(cr,x-1,zero-T) -- temperature indicator
cairo_rel_line_to(cr,10,0)
-- temperature text
print_text(cr,t,x+28,zero-T,1,10)
-- zero degrees text
print_text(cr,"0",x-12,zero,1,12)
end
function draw_wind_rose()
draw_marks(cr,xW,yW,radiusW)
draw_WindArrow(cr,xW,yW,50,direction,radiusW-8)
draw_NESW(cr,xW,yW,radiusW,10)
-- print windspeed
local fontface="Dustismo"
local r,g,b,a = 1,1,1,0.6
cairo_set_source_rgba (cr,r,g,b,a)
cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
cairo_set_font_size (cr,17)
local xt,yt = position_text(cr,windS,xW,yW,2)
cairo_move_to (cr,xt,yt)
cairo_show_text (cr,windS)
cairo_stroke (cr)
-- print weather conditions
local fontface="Dustismo"
local r,g,b,a = 1,1,1,0.6
cairo_set_source_rgba (cr,r,g,b,a)
cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
cairo_set_font_size (cr,11)
local xt,yt = position_text(cr,wx,xW,yW+10,1)
cairo_move_to (cr,xt,yt)
cairo_show_text (cr,wx)
cairo_stroke (cr)
end
function draw_WindArrow(cr,x, y, length, bearing,radiusW)
-- startpoint x, startpoint y, length of side, compass bearing
local head_ratio = 1.05 -- ratio of side to overall length
local head_angle = 0.02 -- proportion 0 - 0.5 (straight, at right angle to direction)
local x1=x- (math.sin(bearing)*radiusW)
local y1=y- (math.cos(bearing)*radiusW)
--arrow body
local angle = bearing
local x0 = x1 + (math.sin(angle) * length)
local y0 = y1 + (math.cos(angle) * length)
local xtext = x1 + (math.sin(angle) * 0.25*length)
local ytext = y1 + (math.cos(angle) * 0.25*length)
--arrow head left
angle = bearing - (head_angle * math.pi)
x2 = x0 - (math.sin(angle) * length * head_ratio)
y2 = y0 - (math.cos(angle) * length * head_ratio)
--arrow head right
angle = bearing + (head_angle * math.pi)
x3 = x0 - (math.sin(angle) * length * head_ratio)
y3 = y0 - (math.cos(angle) * length * head_ratio)
start_x=(x0+x2+x3)/3
start_y=(y0+y2+y3)/3
cairo_set_source_rgba (cr,1,1,1,0.7)
cairo_move_to (cr,start_x,start_y)
cairo_line_to (cr,x2,y2)
cairo_line_to (cr,x1,y1)
cairo_line_to (cr,x3,y3)
cairo_close_path (cr)
cairo_fill(cr)
cairo_stroke (cr)
return true
end
-- display compass points
function draw_NESW(cr,x,y,rt,font_size)
local compass={0,90,180,270}
local cpoints={"N","E","S","W"}
radiusW=rt+12
for i = 1,4,1 do
compass_point=-math.pi*(tonumber(compass[i]))/180
local x1=x - (math.sin(compass_point)*radiusW)
local y1=y - (math.cos(compass_point)*radiusW)
local t = cpoints[i]
print_text(cr,t,x1,y1,1,font_size)
end
end
-- draw compass rose graduations
function draw_marks(cr,x,y,r)
local angle=0
local inner=r-2
local outer=r+2
local r,g,b,a=1,1,1,0.7
cairo_set_source_rgba (cr,r,g,b,a)
cairo_set_line_width(cr, 1)
for i = 0,36,1 do -- draw small ticks, every 10 deg
compass_arc=(-2*math.pi/360)*angle
local x0 = x - (math.sin(compass_arc) * inner)
local y0 = y - (math.cos(compass_arc) * inner)
local endx = x - (math.sin(compass_arc) * outer)
local endy = y - (math.cos(compass_arc) * outer)
if ( (i/3) - math.floor(i/3) ~= 0 ) then -- don't draw every third tick
cairo_move_to (cr,x0,y0)
cairo_line_to(cr,endx,endy)
cairo_stroke(cr)
end
angle=angle+10
end
angle=0 -- re-set angle
for i = 0,12,1 do -- draw large ticks, every 30 deg
compass_arc=(-2*math.pi/360)*angle
x0 = x - (math.sin(compass_arc) * (inner-5))
y0 = y - (math.cos(compass_arc) * (inner-5))
endx = x - (math.sin(compass_arc) * outer)
endy = y - (math.cos(compass_arc) * outer)
cairo_move_to (cr,x0,y0)
cairo_line_to(cr,endx,endy)
cairo_stroke(cr)
angle=angle+30
end
end
function print_text(cr,t,xT,yT,posT,font_size)
-- align text, using text area extents
-- posT: 0 = none
-- 1 = align both
-- 2 = horizontal
-- 3 = vertical
-- 4 = left
cairo_set_font_size (cr,font_size)
if ( posT == 0 ) then
xt = xT
yt = yT
else
xt,yt = position_text(cr,t,xT,yT,posT)
end
cairo_move_to (cr,xt,yt)
cairo_show_text (cr,t)
cairo_stroke (cr)
end
function position_text(cr,t,text_x,text_y,pos)
-- adjust text position
-- get text area (x_bearing,y_bearing,width,height,x_advance,y_advance)
te=cairo_text_extents_t:create()
cairo_text_extents(cr,t,te)
xtext = text_x
ytext = text_y
if ( pos == 1 ) then -- centre text
xtext = text_x - te.width/2
ytext = text_y + te.height/2
elseif ( pos == 2 ) then -- horizontal align
xtext = text_x - te.width/2
elseif ( pos == 3 ) then -- vertical align
ytext = text_y + te.height/2
elseif ( pos == 4 ) then -- set right edge of text to pos
xtext = text_x - te.width
end
return xtext,ytext
end
PS: (le formatage du code a l'air un peu bizarre.)
Offline
Hello
Danke mein Freund
@+
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
## pkill -xf "conky -q -c /media/5/conky/OB-Cal.conky" &
## ---------- Begin Window Settings
own_window yes
own_window_type normal
own_window_transparent no
#own_window_hints skip_taskbar,skip_pager ## ,sticky,undecorated
own_window_hints skip_taskbar,skip_pager #,below #,sticky
own_window_colour 000000
own_window_class Conky
own_window_title OB Cal
## ARGB can be used for real transparency
own_window_argb_visual yes ## Options: yes or no
## Valid range is 0-255, where 0 is 0% opacity, and 255 is 100% opacity.
own_window_argb_value 150
## Normal with no test
#minimum_size 420 10 ##220 10 ## w|h
#maximum_width 420 ##220
#minimum_size 250 0
#maximum_width 250
minimum_size 250 0
maximum_width 250
gap_x 100 ## l|r
gap_y 100 ## u|d
alignment tl
## ---------- End Window Settings
## ---------- Font Settings
## Force UTF8? requires XFT
override_utf8_locale yes
## Use Xft (anti-aliased font and stuff)
use_xft yes
#xftfont Liberation Mono:bold:size=11
#xftfont Fantasque Sans Mono:bold:size=10
xftfont Monofur:bold:size=16
#xftfont DejaVu Sans Mono:bold:size=10
#xftfont Fira Mono:bold:size=9
## Alpha of Xft font. Must be a value at or between 1 and 0
xftalpha 1.0
## --------- End Font Settings
## --------- Color Settings
draw_shades yes
default_shade_color 000000
draw_outline no
default_outline_color 000000
default_color DCDCDC #Gainsboro
color0 98FB98 #PaleGreen
color1 778899 #LightSlateGray
color2 FFD700 #Gold
color3 B0E0E6 #PowderBlue
color4 F4A460 #SandyBrown
color5 DEB887 #BurlyWood
color6 00BFFF #DeepSkyBlue
color7 5F9EA0 #CadetBlue
color8 FFA500 #Orange
color9 FF4500 #OrangeRed
## ---------- End Color Settings
## ---------- Begin Borders Section
draw_borders no
## Stippled borders?
stippled_borders 5
## border margins
border_inner_margin 5
border_outer_margin 0
## border width
border_width 2
## graph borders
draw_graph_borders no
## default_graph_size 15 40
## ---------- End Borders Secton
## ---------- Begin Miscellaneous Section
## Boolean value, if true, Conky will be forked to background when started.
background no ## yes
## Adds spaces around certain objects to stop them from moving other things
## around, this only helps if you are using a mono font
## Options: right, left or none
use_spacer none
## Subtract (file slystem) buffers from used memory?
no_buffers yes
## Use the Xdbe extension? (eliminates flicker)
## It is highly reco${color}mmended to use own window with this one
## so double buffer won't be so big.
double_buffer yes
## ---------- End Miscellaneous Section
update_interval 1
TEXT
${goto 20}${color2}${time %b %Y} ${time %T}${color2}
${goto 20}${if_match ${time %w}==0}${color2}SU${color} MO TU WE TH FR SA${else}\
${if_match ${time %w}==1}${color}SU ${color2}MO${color} TU WE TH FR SA${else}\
${if_match ${time %w}==2}${color}SU MO ${color2}TU${color} WE TH FR SA${else}\
${if_match ${time %w}==3}${color}SU MO TU ${color2}WE${color} TH FR SA${else}\
${if_match ${time %w}==4}${color}SU MO TU WE ${color2}TH${color} FR SA${else}\
${if_match ${time %w}==5}${color}SU MO TU WE TH ${color2}FR${color} SA${else}\
${color}SU MO TU WE TH FR ${color2}SA${color}\
${endif}${endif}${endif}${endif}${endif}${endif}
${goto 20}${color}${execpi 1800 LAR=`date +%-d`; ncal -bh | sed '2d' | sed -e '1d' -e 's/\<'$LAR'\>/${color2}&${color}/' | sed ':a;N;$!ba;s/\n/\n${goto 20}/g'}
${font Fantasque Sans Mono:bold:size=12}${color7}${membar 0,81}${color} Reminders ${color7}${membar 0}${color}
${pre_exec remind -q -r ~/.reminders | sed -e "/.*(today):/d" -e '/^$/d'}
${color7}${membar 0}${color}${font}
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
@ loutch
That's awesome! Love it.
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
Hello
@ unklar
https://i.postimg.cc/zf3gZFgr/Capture-d-cran-2023-02-22-17-49-51.png
nochmals vielen Dank
@+
Très beau. C'est, comme toujours, brillant !
Savais-tu que tu pouvais facilement séparer les anneaux ?
concentric = 0
concentric = 1
Mais tu as besoin de la version non traitée
lua-weather.lua
--[[
lua-weather.lua, written by <damo>, July 2016
---------------------------------------------
Use this in a conky with
lua_load /path/to/lua-weather.lua
lua_draw_hook_pre conky_main
In the conky, get the weather data from lua-weather.sh with
TEXT
${execi <interval> /path/to/lua-weather.sh}
---------------------------------------------]]
require 'cairo'
-- set default font
--fontface="Dustismo"
fontface="Liberation"
function conky_main()
if conky_window==nil then return end
cs=cairo_xlib_surface_create(conky_window.display,
conky_window.drawable,
conky_window.visual,
conky_window.width,
conky_window.height)
cr=cairo_create(cs)
xW=160 -- x pos wind dial centre
yW=90 -- y pos wind dial centre
radiusW=60 -- radiusW wind dial
xT=30 -- x pos temp bar (top)
yT=10 -- y pos temp bar (top)
wT=6 -- width temp bar
hT=150 -- height temp bar
xSun=340 -- x pos sun dial centre
ySun=90 -- y pos sun dial centre
radiusSun=60-- radius sun dial
datafile="/tmp/weather.txt" -- textfile to hold lua-weather.sh output
direction,windS,temperature,sunrise,sunset,loc,wx = get_vals()
local updates=conky_parse('${updates}')
update_num=tonumber(updates)
-- Edit this for concentric dials ---------------------------------
concentric = 0 --<-- Change to "1" to display concentric rings
if ( concentric == 1 ) then
xSun = 300
ySun = 100
radiusSun = 90
xW = xSun
yW = ySun
radiusW = 0.7*radiusSun
end
------------------------------------------------------------------------
if update_num>1 then
draw_widgets()
end
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end
-- Choose the widgets to be displayed:
function draw_widgets()
draw_thermometer(cr,xT,yT,wT,hT)
draw_wind_rose()
draw_sun_ring()
end
-- read values from datafile
function get_vals()
local path = datafile
local file = io.open( path)
local array = {}
local i=0
if (file) then
-- read all contents of file into array
for line in file:lines() do
i=i+1
array[i]=line
end
file:close()
dir=tostring(array[1]) -- get wind direction, convert to value required
winddir=-math.pi*(tonumber(dir))/180
wind_speed=tostring(array[2]) -- windspeed knots
temperature=tonumber(array[5])
sunrise=array[3]
sunset=array[4]
location=array[6]
weather=array[7]
return winddir,wind_speed,temperature,sunrise,sunset,location,weather
else
print("datafile " .. datafile .. " not found")
end
end
-- convert degree to rad
function angle_to_position(start_angle, current_angle)
local pos = start_angle + current_angle
return pos * math.pi/180
end
function draw_sun_ring()
-- local hours=20
-- local mins=0
local hours=os.date("%H")
local mins=os.date("%M")
current_time=(hours .. mins)
mins_arc = 360/60*mins
hours_arc = (360/24*hours + mins_arc/24) + 90
start_angle = 90 -- south
end_angle = 360
start_arc = 0
stop_arc = 0
-- get times and angle position from function sun_rise_set()
sunrise,sunset,sun_rise,sun_set = sun_rise_set()
local border_pat=cairo_pattern_create_linear(xSun,ySun-radiusSun*1.25,xSun,ySun+radiusSun*1.25)
cairo_pattern_add_color_stop_rgba(border_pat,0,1,1,0,0.3)
cairo_pattern_add_color_stop_rgba(border_pat,0.4,0.9,0.9,0.2,0.2)
cairo_pattern_add_color_stop_rgba(border_pat,0.55,0.9,0.2,0,0.2)
cairo_pattern_add_color_stop_rgba(border_pat,0.7,0,0.1,1,0.3)
cairo_set_source(cr,border_pat)
-- draw ring, starting at south position ( = midnight/00hrs)
cairo_arc(cr, xSun, ySun, radiusSun, angle_to_position(start_angle, 0), angle_to_position(start_angle, end_angle))
-- set width of ring
cairo_set_line_width(cr,radiusSun*0.06)
cairo_stroke(cr)
cairo_pattern_destroy (pat)
-- draw sun
-- get position on circumference ( = time from midnight (south), 24hr clock)
sun_pos=angle_to_position(start_angle,hours_arc)
local sunx=xSun - (math.sin(-sun_pos)*radiusSun)
local suny=ySun - (math.cos(-sun_pos)*radiusSun)
-- set colour & alpha, for day/night
if ( tonumber(current_time) > tonumber(sunrise) ) and ( tonumber(current_time) < tonumber(sunset) ) then
r,g,b,a = 1,1,0,0.4 --day
else
r,g,b,a = 0.5,0.5,0.5,0.4 --night
end
cairo_set_source_rgba (cr,r,g,b,a)
cairo_arc(cr,sunx,suny,radiusSun*0.09,0,360)
cairo_fill(cr)
local r,g,b,a = 1,1,0,0.5
cairo_set_source_rgba (cr,r,g,b,a)
cairo_set_line_width(cr,2)
cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND)
-- draw sunrise mark
local sunrise_x=xSun - (math.sin(-sun_rise)*radiusSun*1.05)
local sunrise_y=ySun - (math.cos(-sun_rise)*radiusSun*1.05)
local sunrise_xc=xSun - (math.sin(-sun_rise)*radiusSun*0.95)
local sunrise_yc=ySun - (math.cos(-sun_rise)*radiusSun*0.95)
cairo_move_to(cr,sunrise_x,sunrise_y)
cairo_line_to(cr,sunrise_xc,sunrise_yc)
cairo_stroke(cr)
-- draw sunset mark
local sunset_x=xSun - (math.sin(-sun_set)*radiusSun*1.05)
local sunset_y=ySun - (math.cos(-sun_set)*radiusSun*1.05)
local sunset_xc=xSun - (math.sin(-sun_set)*radiusSun*0.95)
local sunset_yc=ySun - (math.cos(-sun_set)*radiusSun*0.95)
local r,g,b,a = 1,0,0,0.5
cairo_set_source_rgba (cr,r,g,b,a)
cairo_move_to(cr,sunset_x,sunset_y)
cairo_line_to(cr,sunset_xc,sunset_yc)
cairo_stroke(cr)
-- print sunrise/sunset text
sun_text(sunrise_x,sunrise_y,sunset_x,sunset_y)
end
function sun_text(xr,yr,xs,ys)
-- display sunrise time
local r,g,b,a = 1,1,0,0.5
cairo_set_source_rgba (cr,r,g,b,a)
print_text(cr,sunrise,xr-4,yr,4,10)
print_text(cr,"sunrise",xr-4,yr+8,4,8)
-- display sunset time
local r,g,b,a = 1,0,0,0.5
cairo_set_source_rgba (cr,r,g,b,a)
print_text(cr,sunset,xs,ys+10,0,10)
print_text(cr,"sunset",xs,ys+18,0,8)
-- print("concentric= " .. concentric)
if ( concentric == 0 ) then
-- display time
local current_time = os.date("%H%M")
local fontface="Dustismo"
local r,g,b,a = 1,1,1,0.3
cairo_set_source_rgba (cr,r,g,b,a)
cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
cairo_set_font_size (cr,24)
local xt,yt = position_text(cr,current_time,xSun,ySun-6,2)
cairo_move_to (cr,xt,yt)
cairo_show_text (cr,current_time)
cairo_stroke (cr)
-- display date
local cal = os.date("%a %d %b")
local fontface="Dustismo"
local r,g,b,a = 1,1,1,0.3
cairo_set_source_rgba (cr,r,g,b,a)
cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
cairo_set_font_size (cr,12)
local xt,yt = position_text(cr,cal,xSun,ySun+10,1)
cairo_move_to (cr,xt,yt)
cairo_show_text (cr,cal)
cairo_stroke (cr)
-- print location
local fontface="Dustismo"
local r,g,b,a = 1,1,1,0.4
cairo_set_source_rgba (cr,r,g,b,a)
cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
cairo_set_font_size (cr,10)
local xt,yt = position_text(cr,loc,xSun,ySun+25,1)
cairo_move_to (cr,xt,yt)
cairo_show_text (cr,loc)
cairo_stroke (cr)
else
print_location_text(xSun,ySun+1.4*radiusSun)
end
end
function print_location_text(x,y)
-- display time
local current_time = os.date("%H:%M")
local fontface="Dustismo"
local r,g,b,a = 1,1,1,0.3
cairo_set_source_rgba (cr,r,g,b,a)
cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
cairo_set_font_size (cr,24)
local xt,yt = position_text(cr,current_time,x,y,2)
cairo_move_to (cr,xt,yt)
cairo_show_text (cr,current_time)
cairo_stroke (cr)
-- display date
local cal = os.date("%a. %d. %b")
local fontface="Dustismo"
local r,g,b,a = 1,1,1,0.3
cairo_set_source_rgba (cr,r,g,b,a)
cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
cairo_set_font_size (cr,12)
local xt,yt = position_text(cr,cal,x,y+10,1)
cairo_move_to (cr,xt,yt)
cairo_show_text (cr,cal)
cairo_stroke (cr)
-- print location
local fontface="Dustismo"
local r,g,b,a = 1,1,1,0.4
cairo_set_source_rgba (cr,r,g,b,a)
cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
cairo_set_font_size (cr,10)
local xt,yt = position_text(cr,loc,x,y+25,1)
cairo_move_to (cr,xt,yt)
cairo_show_text (cr,loc)
cairo_stroke (cr)
end
function sun_rise_set()
sunupH = string.sub(sunrise,1,2)
sunupM = string.sub(sunrise,3,4)
sundownH = string.sub(sunset,1,2)
sundownM = string.sub(sunset,3,4)
minSR_arc = 360/60*sunupM
hourSR_arc = (360/24*sunupH + minSR_arc/24) + 90
pos_SR = angle_to_position(start_angle,hourSR_arc)
minSS_arc = 360/60*sundownM
hourSS_arc = (360/24*sundownH + minSS_arc/24) + 90
pos_SS = angle_to_position(start_angle,hourSS_arc)
return sunrise,sunset,pos_SR,pos_SS
end
function draw_thermometer(cr,x,y,wT,hT)
local alpha=0.5
HT = y+hT
pat = cairo_pattern_create_linear (x,y,wT,HT)
cairo_pattern_add_color_stop_rgba (pat, 1, 0, 0, 1, alpha)
cairo_pattern_add_color_stop_rgba (pat, 0.4, 1,0.8, 0, alpha)
cairo_pattern_add_color_stop_rgba (pat, 0.3, 1,0.3, 0, alpha)
cairo_pattern_add_color_stop_rgba (pat, 0, 1,0, 0, alpha)
cairo_rectangle (cr, x,y,wT,HT)
cairo_set_source (cr, pat)
cairo_fill (cr)
cairo_pattern_destroy (pat)
draw_temperature(cr,x,y,hT,temperature)
end
function draw_temperature(cr,x,y,hT,Tdegrees)
local range=hT/100
local zero = y + range*60
local T = Tdegrees*range
t = tostring(Tdegrees)
t = ( t .. "°C" )
cairo_set_source_rgba (cr,1,1,1,0.5)
cairo_set_line_width(cr,1)
for i = 0,100,10 do -- draw 10 degree marks
local l = 3
local xT = x-1
if ( i == 60 ) then -- longer mark for freezing point
xT = x-6
l = -12
end
cairo_move_to (cr,xT,y)
cairo_rel_line_to (cr,-l,0)
cairo_stroke (cr)
y = y + range*10
end
cairo_set_source_rgba (cr,1,1,1,0.5)
cairo_set_line_width(cr,3)
cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND)
cairo_move_to(cr,x-1,zero-T) -- temperature indicator
cairo_rel_line_to(cr,10,0)
-- temperature text
print_text(cr,t,x+28,zero-T,1,10)
-- zero degrees text
print_text(cr,"0",x-12,zero,1,12)
end
function draw_wind_rose()
draw_marks(cr,xW,yW,radiusW)
draw_WindArrow(cr,xW,yW,50,direction,radiusW-8)
draw_NESW(cr,xW,yW,radiusW,10)
-- print windspeed
local fontface="Dustismo"
local r,g,b,a = 1,1,1,0.4
cairo_set_source_rgba (cr,r,g,b,a)
cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD)
cairo_set_font_size (cr,16)
local xt,yt = position_text(cr,windS,xW,yW,2)
cairo_move_to (cr,xt,yt)
cairo_show_text (cr,windS)
cairo_stroke (cr)
-- print weather conditions
local fontface="Dustismo"
local r,g,b,a = 1,1,1,0.4
cairo_set_source_rgba (cr,r,g,b,a)
cairo_select_font_face(cr,fontface,CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_NORMAL)
cairo_set_font_size (cr,10)
local xt,yt = position_text(cr,wx,xW,yW+10,1)
cairo_move_to (cr,xt,yt)
cairo_show_text (cr,wx)
cairo_stroke (cr)
end
function draw_WindArrow(cr,x, y, length, bearing,radiusW)
-- startpoint x, startpoint y, length of side, compass bearing
local head_ratio = 1.05 -- ratio of side to overall length
local head_angle = 0.02 -- proportion 0 - 0.5 (straight, at right angle to direction)
local x1=x- (math.sin(bearing)*radiusW)
local y1=y- (math.cos(bearing)*radiusW)
--arrow body
local angle = bearing
local x0 = x1 + (math.sin(angle) * length)
local y0 = y1 + (math.cos(angle) * length)
local xtext = x1 + (math.sin(angle) * 0.25*length)
local ytext = y1 + (math.cos(angle) * 0.25*length)
--arrow head left
angle = bearing - (head_angle * math.pi)
x2 = x0 - (math.sin(angle) * length * head_ratio)
y2 = y0 - (math.cos(angle) * length * head_ratio)
--arrow head right
angle = bearing + (head_angle * math.pi)
x3 = x0 - (math.sin(angle) * length * head_ratio)
y3 = y0 - (math.cos(angle) * length * head_ratio)
start_x=(x0+x2+x3)/3
start_y=(y0+y2+y3)/3
cairo_set_source_rgba (cr,1,1,1,0.5)
cairo_move_to (cr,start_x,start_y)
cairo_line_to (cr,x2,y2)
cairo_line_to (cr,x1,y1)
cairo_line_to (cr,x3,y3)
cairo_close_path (cr)
cairo_fill(cr)
cairo_stroke (cr)
return true
end
-- display compass points
function draw_NESW(cr,x,y,rt,font_size)
local compass={0,90,180,270}
local cpoints={"N","E","S","W"}
radiusW=rt+12
for i = 1,4,1 do
compass_point=-math.pi*(tonumber(compass[i]))/180
local x1=x - (math.sin(compass_point)*radiusW)
local y1=y - (math.cos(compass_point)*radiusW)
local t = cpoints[i]
print_text(cr,t,x1,y1,1,font_size)
end
end
-- draw compass rose graduations
function draw_marks(cr,x,y,r)
local angle=0
local inner=r-2
local outer=r+2
local r,g,b,a=1,1,1,0.5
cairo_set_source_rgba (cr,r,g,b,a)
cairo_set_line_width(cr, 1)
for i = 0,36,1 do -- draw small ticks, every 10 deg
compass_arc=(-2*math.pi/360)*angle
local x0 = x - (math.sin(compass_arc) * inner)
local y0 = y - (math.cos(compass_arc) * inner)
local endx = x - (math.sin(compass_arc) * outer)
local endy = y - (math.cos(compass_arc) * outer)
if ( (i/3) - math.floor(i/3) ~= 0 ) then -- don't draw every third tick
cairo_move_to (cr,x0,y0)
cairo_line_to(cr,endx,endy)
cairo_stroke(cr)
end
angle=angle+10
end
angle=0 -- re-set angle
for i = 0,12,1 do -- draw large ticks, every 30 deg
compass_arc=(-2*math.pi/360)*angle
x0 = x - (math.sin(compass_arc) * (inner-5))
y0 = y - (math.cos(compass_arc) * (inner-5))
endx = x - (math.sin(compass_arc) * outer)
endy = y - (math.cos(compass_arc) * outer)
cairo_move_to (cr,x0,y0)
cairo_line_to(cr,endx,endy)
cairo_stroke(cr)
angle=angle+30
end
end
function print_text(cr,t,xT,yT,posT,font_size)
-- align text, using text area extents
-- posT: 0 = none
-- 1 = align both
-- 2 = horizontal
-- 3 = vertical
-- 4 = left
cairo_set_font_size (cr,font_size)
if ( posT == 0 ) then
xt = xT
yt = yT
else
xt,yt = position_text(cr,t,xT,yT,posT)
end
cairo_move_to (cr,xt,yt)
cairo_show_text (cr,t)
cairo_stroke (cr)
end
function position_text(cr,t,text_x,text_y,pos)
-- adjust text position
-- get text area (x_bearing,y_bearing,width,height,x_advance,y_advance)
te=cairo_text_extents_t:create()
cairo_text_extents(cr,t,te)
xtext = text_x
ytext = text_y
if ( pos == 1 ) then -- centre text
xtext = text_x - te.width/2
ytext = text_y + te.height/2
elseif ( pos == 2 ) then -- horizontal align
xtext = text_x - te.width/2
elseif ( pos == 3 ) then -- vertical align
ytext = text_y + te.height/2
elseif ( pos == 4 ) then -- set right edge of text to pos
xtext = text_x - te.width
end
return xtext,ytext
end
Offline
conky (1.18.1-1) unstable; urgency=medium
* New upstream release.
- Fix broken graph colours. (Closes: #1031736)
-- Vincent Cheng <vcheng@debian.org> Fri, 24 Feb 2023 15:09:43 -0800
conky (1.18.0-1) unstable; urgency=medium
* New upstream release.
- Unbreak Xinerama config loading. (Closes: #1027895)
-- Vincent Cheng <vcheng@debian.org> Sun, 19 Feb 2023 22:57:28 -0800
conky (1.17.0-1) unstable; urgency=medium
[ Vincent Cheng ]
* New upstream release.
* Add support for wayland in conky-std and conky-all.
- Add build-dep on libwayland-dev and wayland-protocols.
* Add some basic autopkgtests.
* Update build-deps for doc generation (pandoc, pyyaml, jinja2).
* Update standards version to 4.6.2, no changes needed.
[ Debian Janitor ]
* debian/copyright: use spaces rather than tabs to start continuation lines.
* Remove obsolete field Name from debian/upstream/metadata (already present in
machine-readable debian/copyright).
* Set upstream metadata fields: Bug-Submit.
-- Vincent Cheng <vcheng@debian.org> Tue, 03 Jan 2023 00:19:55 -0800
...and, there I wanted to check today, why the colors in the graphs were no longer correct after 18.0
So, debian currently beats arch by a long way. It's never been this fast before!
Offline
I think moving here because the starting point should stay with @TeoBigusGeekus. It is his thread.
meteo-api
@loutch,
mon approche du script serait la suivante (my approach for the script would be)
#!/bin/bash
# Closebox73, modified with meteo-api February 2023 @unklar
# This script is to get weather data from openweathermap.com in the form of a json file
# so that conky will still display the weather when offline even though it doesn't up to date
url="https://api.open-meteo.com/v1/forecast?latitude=50.45&longitude=12.37&hourly=temperature_2m&timezone=Europe%2FBerlin"
curl ${url} -s -o ~/.cache/meteo.json
Offline
Hello
Ich bin Dabei .
@+
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
Shamelessly borrowed unklar's bash script idea.
That json file will be a fun one to parse.
Getting it in "pretty" mode would be nice.
{
"latitude": -34.625,
"longitude": -58.5,
"generationtime_ms": 0.702977180480957,
"utc_offset_seconds": -10800,
"timezone": "America/Argentina/Buenos_Aires",
"timezone_abbreviation": "-03",
"elevation": 37,
"hourly_units": {
"time": "iso8601",
"temperature_2m": "°C"
},
"hourly": {
"time": [
"2023-02-28T00:00",
"2023-02-28T01:00",
"2023-02-28T02:00",
"2023-02-28T03:00",
"2023-02-28T04:00",
"2023-02-28T05:00",
"2023-02-28T06:00",
"2023-02-28T07:00",
{snip-snip}
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline