Can anyone isolate the code for one of these gauges please? [SOLVED]
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Re: Can anyone isolate the code for one of these gauges please? [SOLVED]
Have you played with the alpha numbers?
I think the colors do fade into each other when you set them to 0.5 instead of 1.0.
I think the colors do fade into each other when you set them to 0.5 instead of 1.0.
- Logansfury
- Level 8
- Posts: 2411
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Re: Can anyone isolate the code for one of these gauges please? [SOLVED]
I haven't, I am a bit groggy today from a crappy night trying to sleep. I may crash for a bit then experiment with the gauges more when I am more alert.
Re: Can anyone isolate the code for one of these gauges please? [SOLVED]
I can clean up that code quite a bit. Those edits were just using copy/paste to represent the idea.
I kinda liked seeing the whole thing go uncontrollably blaring red all of a sudden!
-but wondering if the whole active bar should be represented by the current color.
It looks good and clean, and clear though, and with the data and labels changing colors i guess that does flash some attention into your peripheral view.
I kinda liked seeing the whole thing go uncontrollably blaring red all of a sudden!
-but wondering if the whole active bar should be represented by the current color.
It looks good and clean, and clear though, and with the data and labels changing colors i guess that does flash some attention into your peripheral view.
- Logansfury
- Level 8
- Posts: 2411
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Re: Can anyone isolate the code for one of these gauges please? [SOLVED]
I kept the edit that produced the color change across the entire gauge and text just to be able to refer back to it if desired, but the gauges I added to my Minimalis display are the clean edits you provided, and a set that Koentje edited. They look beautiful!zcot wrote: ⤴Thu Jul 11, 2024 10:08 pm I can clean up that code quite a bit. Those edits were just using copy/paste to represent the idea.
I kinda liked seeing the whole thing go uncontrollably blaring red all of a sudden!
-but wondering if the whole active bar should be represented by the current color.
It looks good and clean, and clear though, and with the data and labels changing colors i guess that does flash some attention into your peripheral view.
- Logansfury
- Level 8
- Posts: 2411
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Re: Can anyone isolate the code for one of these gauges please? [SOLVED]
Hey Zcot,
Can you show me what part of the code determines the ranges of med, warn, and alarm?
I note that med, the yellow range is really small and warn the orange range is large
I would like to edit this to add about 15-20% to yellow/med and subtract the same from orange/warn
Can you do this edit or explain to me how I can do it please?
Can you show me what part of the code determines the ranges of med, warn, and alarm?
I note that med, the yellow range is really small and warn the orange range is large
I would like to edit this to add about 15-20% to yellow/med and subtract the same from orange/warn
Can you do this edit or explain to me how I can do it please?
Re: Can anyone isolate the code for one of these gauges please? [SOLVED]
I just used the numbers you had mentioned in your prior post, easily changeable though.Logansfury wrote: ⤴Sat Jul 13, 2024 3:34 am Hey Zcot,
Can you show me what part of the code determines the ranges of med, warn, and alarm?
I note that med, the yellow range is really small and warn the orange range is large
I would like to edit this to add about 15-20% to yellow/med and subtract the same from orange/warn
Can you do this edit or explain to me how I can do it please?
look at my previous post, it's in the conky config when you call it, and i added to the comment. you can see the zones. medium warn alert.
- Logansfury
- Level 8
- Posts: 2411
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Re: Can anyone isolate the code for one of these gauges please? [SOLVED]
Good Morning Zcot,zcot wrote: ⤴Sun Jul 14, 2024 7:58 amI just used the numbers you had mentioned in your prior post, easily changeable though.Logansfury wrote: ⤴Sat Jul 13, 2024 3:34 am Hey Zcot,
Can you show me what part of the code determines the ranges of med, warn, and alarm?
I note that med, the yellow range is really small and warn the orange range is large
I would like to edit this to add about 15-20% to yellow/med and subtract the same from orange/warn
Can you do this edit or explain to me how I can do it please?
look at my previous post, it's in the conky config when you call it, and i added to the comment. you can see the zones. medium warn alert.
I woke up a little ill this morning but I will take a look at the documentation you left and see if I can puzzle out the edit
- Logansfury
- Level 8
- Posts: 2411
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Re: Can anyone isolate the code for one of these gauges please? [SOLVED]
Im not seeing it. I just opened up the .lua and started at the top and searched "med" and all I see is variables divided by variables an no numeric values to set anywhere in the .lua.zcot wrote: ⤴Sun Jul 14, 2024 7:58 amI just used the numbers you had mentioned in your prior post, easily changeable though.Logansfury wrote: ⤴Sat Jul 13, 2024 3:34 am Hey Zcot,
Can you show me what part of the code determines the ranges of med, warn, and alarm?
I note that med, the yellow range is really small and warn the orange range is large
I would like to edit this to add about 15-20% to yellow/med and subtract the same from orange/warn
Can you do this edit or explain to me how I can do it please?
look at my previous post, it's in the conky config when you call it, and i added to the comment. you can see the zones. medium warn alert.
I'm afraid I will need a bit more help to perform the edit.
Re: Can anyone isolate the code for one of these gauges please? [SOLVED]
It's not in the lua file.zcot wrote: ⤴Thu Jul 11, 2024 7:18 am this is that sample(notice the hard coded sample values), notice the additional input parameter called medium, so the zones are OK/Medium/Warn/Alarm.Code: Select all
# ... label/(no spaces) unit/(type nil if blank) measure/(conky_parse) max medium warn alarm xr yc ... ${lua conky_gauge CPU % ${cpu cpu0} 100 35 50 80 25 50 } ${lua conky_gauge CPU1 % 30 100 35 50 80 70 50 } ${lua conky_gauge CPU2 % 45 100 35 50 80 115 50 } ${lua conky_gauge CPU3 % 65 100 35 50 80 160 50 } ${lua conky_gauge CPU4 % 95 100 35 50 80 205 50 }
look in the config file.
specifically look at the comment line:
Code: Select all
# ... label/(no spaces) unit/(type nil if blank) measure/(conky_parse) max medium warn alarm xr yc ...
Code: Select all
${lua conky_gauge CPU % ${cpu cpu0} 100 35 50 80 25 50 }
medium warn alarm
are defined as 35 50 80
.-those are the numbers you specified in an earlier post. just change them to your liking.
35 starts the medium zone
50 starts the warn zone
80 starts the alarm zone
- Logansfury
- Level 8
- Posts: 2411
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Re: Can anyone isolate the code for one of these gauges please? [SOLVED]
ah I see. I feel foolish for not checking out the config fill.zcot wrote: ⤴Sun Jul 14, 2024 7:58 pmIt's not in the lua file.zcot wrote: ⤴Thu Jul 11, 2024 7:18 am this is that sample(notice the hard coded sample values), notice the additional input parameter called medium, so the zones are OK/Medium/Warn/Alarm.Code: Select all
# ... label/(no spaces) unit/(type nil if blank) measure/(conky_parse) max medium warn alarm xr yc ... ${lua conky_gauge CPU % ${cpu cpu0} 100 35 50 80 25 50 } ${lua conky_gauge CPU1 % 30 100 35 50 80 70 50 } ${lua conky_gauge CPU2 % 45 100 35 50 80 115 50 } ${lua conky_gauge CPU3 % 65 100 35 50 80 160 50 } ${lua conky_gauge CPU4 % 95 100 35 50 80 205 50 }
look in the config file.
specifically look at the comment line:now compare that to a call of the gauge as in this example:Code: Select all
# ... label/(no spaces) unit/(type nil if blank) measure/(conky_parse) max medium warn alarm xr yc ...
you can see thatCode: Select all
${lua conky_gauge CPU % ${cpu cpu0} 100 35 50 80 25 50 }
medium warn alarm
are defined as35 50 80
.
-those are the numbers you specified in an earlier post. just change them to your liking.
35 starts the medium zone
50 starts the warn zone
80 starts the alarm zone
As always, thank you for saving me from myself Zcot
Have a great weekend, I'm off to do edits!
-
- Level 3
- Posts: 178
- Joined: Mon Jul 29, 2024 8:18 pm
Re: Can anyone isolate the code for one of these gauges please? [SOLVED]
I actually use the same code for the gauges, I forget where I found it.
Do you guys see errors in your
The line in question is:
My conky_rc is calling it like so:
and
If I run conky on the command line I also see them.
I think it has to do with lua trying to process the value and is expecting a number, but since it is empty, it displays an error. It's not a huge deal but sometimes it can spam the
PS.
I also have this function defined in the same lua file as
Do you guys see errors in your
~/.xsession_errors
file with these lines?:Code: Select all
conky: Bad arguments: ' ' and ' 60'
conky: compare failed for expression ' <= 60'
conky: llua_getnumber: function conky_loadavg didn't return a number, result discarded
conky: llua_do_call: function conky_loadavg execution failed: ~/.conky/conky_myluafunctions.lua:130: attempt to perform arithmetic on a nil value (local 'value')
local pct = value/max
My conky_rc is calling it like so:
${if_match ${lua conky_loadavg} <= 60}${color white}
and
${lua conky_gauge FAN % ${exec sensors | grep Right | cut -c14-18 | awk '{print (($1-1985)/4200)*100}' | awk '{printf "%.0f\n", $1}'} 100 40 80 132 139 }
If I run conky on the command line I also see them.
I think it has to do with lua trying to process the value and is expecting a number, but since it is empty, it displays an error. It's not a huge deal but sometimes it can spam the
~/.xsession_errors
file.PS.
I also have this function defined in the same lua file as
conky_gauge
:Code: Select all
function conky_loadavg()
loadavg = conky_parse("${loadavg 1}") / 8
loadavg_graphval = string.sub(loadavg, 3, 4)
loadavg_graphval_no_leading_zeroes = string.gsub(loadavg_graphval, '0*', '', 1)
return loadavg_graphval_no_leading_zeroes
end
Re: Can anyone isolate the code for one of these gauges please? [SOLVED]
Code: Select all
conky: Bad arguments: ' ' and ' 60'
conky: compare failed for expression ' <= 60'
conky: llua_getnumber: function conky_loadavg didn't return a number, result discarded
conky: llua_do_call: function conky_loadavg execution failed: ~/.conky/conky_myluafunctions.lua:130: attempt to perform arithmetic on a nil value (local 'value')
lua conky_loadavg
,-we know those 2 lines refer to the conky_rc line:
${if_match ${lua conky_loadavg} <= 60}${color white}
the next 2 lines go further up to where the problem is starting, which we know is the lua scripting but you mention
conky_gauge
but the error mentions conky_myluafunctions.lua
, so quite confusing as to what the real chain of process is on that, and it would be hard to start guessing other than starting from scratch and showing an entirely different solution.you also throw in this comment about the
conky_gauge
line, but I can not understand where that interacts with any of this.In a case like this, if you just show some snippets, it's hard to really troubleshoot. The functionality is there, and even though there's not enough code to see exactly how it all works, it does look like it's part of a larger functional scripting setup.
Why don't you post the scripts so we can see all the calls and relationship of those snippets.
-
- Level 3
- Posts: 178
- Joined: Mon Jul 29, 2024 8:18 pm
Re: Can anyone isolate the code for one of these gauges please? [SOLVED]
Thanks, zcot, sure, here they are:
.conkyrc:
Code: Select all
conky.config = {
alignment = 'top_left',
background = false,
border_width = 1,
cpu_avg_samples = 2,
draw_borders = false,
draw_graph_borders = true,
draw_outline = false,
draw_shades = false,
use_xft = true,
font = 'DejaVu Sans Mono:size=10',
minimum_height = 5,
minimum_width = 215,
maximum_width = 215,
net_avg_samples = 2,
no_buffers = true,
out_to_console = false,
out_to_stderr = false,
extra_newline = false,
own_window = true,
own_window_transparent = false,
own_window_argb_visual = true,
own_window_argb_value = 70,
own_window_type = 'desktop',
own_window_class = 'Conky',
stippled_borders = 0,
update_interval = 1,
update_interval_on_battery = 2,
uppercase = false,
use_spacer = 'none',
show_graph_scale = false,
show_graph_range = false,
double_buffer = true,
gap_x = 1460,
gap_y = 365,
--always display conky on my laptop screen when using an external monitor:
xinerama_head = 1,
--colours:
default_color = 'white',
default_outline_color = 'white',
default_shade_color = 'white',
color1 = '1793d1', --blue
color2 = 'FE1B1B', --red
color3 = '84F66E', --green,
color4 = 'FEFD1B', --yellow
color5 = 'ff5500', --reddish-orange
--function used to allow load to be displayed divided by # of CPUs (because otherwise it shows load as too high)
-- conky_loadavg() - need to divide load by the 8 (virtual) cores on this machine.
lua_load = '~/.conky/conky_myluafunctions.lua',
lua_draw_hook_pre = 'main'
}
conky.text = [[
# ----------------------------------------
# ----- TIME, DATE, & WIFI STATUS -------
# ----------------------------------------
${voffset -5}${font :size=14}${time %l:%M%P}${font}${font :size=8}${if_match "${execi 5 nmcli radio wifi}" == "disabled"}${color red}WIFI OFF${color}${endif} ${alignr}${font :size=8}${time %a, %b %d, %Y}${font}
# ----------------------------------------
# ----- PRINTER SERVICES -----------------
# ----------------------------------------
${voffset -3}${font :size=7}${if_match "${execi 5 systemctl is-active cups-browsed}" == "active"}\
${color red}Printer on${color} | ${else}\
Printer off | ${endif}\
# ----------------------------------
# ----- MIC MUTING -----------------
# ----------------------------------
${font :size=7}${if_match "${execi 5 amixer -D pulse sget Capture | sed -n '5,6p' | grep -wq 'off'; echo $?}" == "0"}\
${goto 58}Mic muted
${else}\
${goto 58}${color red}Mic not muted${color}
${endif}\
# ------------------------------
# ----- UPTIME -----------------
# ------------------------------
${voffset -13}${alignr}${font :size=7}Up ${uptime}
# -------------------------------------
# ----- BACKUP STATUS -----------------
# -------------------------------------
${if_match "${execpi 10 ~/.conky/is_backup_running_conky.sh}" == "A backup is running"}\
${font :size=7}${color red}A backup is running${color}${font}\
${else}\
${if_match "${execi 5 ~/.conky/check_backup_dates.php}" == "warning"}\
${color red}Backups: ${font :size=7}BiT:${execi 3 cat ~/.conky/last_backup_backintime_logfile_datetime.txt} ${alignr}TS:${execi 3 cat ~/.conky/last_backup_timeshift_logfile_datetime.txt}${font}${color}\
${else}\
Backups: ${font :size=7}BiT:${execi 3 cat ~/.conky/last_backup_backintime_logfile_datetime.txt} ${alignr}TS:${execi 3 cat ~/.conky/last_backup_timeshift_logfile_datetime.txt}${font}\
${endif}\
${endif}
${voffset -12}$stippled_hr
# ---------------------------
# ----- CPU -----------------
# ---------------------------
${voffset 6}${color orange}${font :size=8}CPU:${color} ${voffset -3}${goto 77}${font :size=6}\
${if_match ${cpu cpu0} <= 60}${color white}${else}${if_match ${cpu cpu0} < 80}${color yellow}${else}${if_match ${cpu cpu0} > 79}${color5}${endif}${endif}${endif}\
${voffset -7}${goto 85}(${execi 3 sensors | awk '/Core/ && !/-/ {print($3)}' | sort -r | head -n 1 | tr -d 'C+'}) ${freq_g } Ghz${color}
${alignr}${cpugraph cpu0 10,135 008844 ef010f -t}
${lua conky_gauge CPU % ${cpu cpu0} 100 75 90 60 75 }
# ---------------------------
# ----- LOAD ----------------
# ---------------------------
${voffset 2}${color orange}${font :size=8}LOAD:${color} ${voffset -5}${goto 83}${font :size=6}\
${if_match ${lua conky_loadavg} <= 60}${color white}${else}${if_match ${lua conky_loadavg} < 80}${color yellow}${else}${if_match ${lua conky_loadavg} > 79}${color5}${endif}${endif}${endif}\
${voffset -4}${goto 85}(${loadavg})${color}
${alignr}${lua_graph conky_loadavg 10,135 008844 ef010f -t}$font
${lua conky_gauge LOAD % ${lua conky_loadavg} 100 60 85 60 107 }
# ---------------------------
# ----- FANS ----------------
# ---------------------------
${voffset -7}${color orange}${font :size=8}FANS:${color}
${voffset -23}${font :size=6}${goto 82}${execi 3 sensors | grep Left | cut -c14-18}
${goto 84}RPM
${voffset -23}${goto 152} ${execi 3 sensors | grep Right | cut -c14-18}
${goto 155}RPM$font
# ... label/(no spaces) unit/(type nil if blank) measure/(conky_parse) max warn alarm xr yc ...
${lua conky_gauge FAN % ${exec sensors | grep Left | cut -c14-18 | awk '{print (($1-1980)/4200)*100}' | awk '{printf "%.0f\n", $1}'} 100 40 80 60 139 }
${lua conky_gauge FAN % ${exec sensors | grep Right | cut -c14-18 | awk '{print (($1-1985)/4200)*100}' | awk '{printf "%.0f\n", $1}'} 100 40 80 132 139 }
# ---------------------------
# ----- RAM / SWAP / DISK ---
# ---------------------------
${voffset -35}${color orange}${font :size=8}RAM:${color} ${font :size=6}$mem / $memmax ${membar}$font
${voffset -7}${color orange}${font :size=8}SWAP:${color} ${font :size=6}$swap / $swapmax ${swapbar}$font
${voffset -6}${color orange}${font :size=8}DISK:${color} ${font :size=6}${fs_free} free ${fs_bar 6 /}
${font :size=6}Read: ${diskio_read} Write: ${color 24d4c2}${diskio_write}${color} ${alignr}${diskiograph 9,100 b2f47c 3884AC -t}
# ---------------------------
# ----- NETWORKING ----------
# ---------------------------
${voffset 3}${color orange}${font :size=8}NETWORKING:${color} ${voffset -1}$stippled_hr
${goto 5}${font PizzaDudeBullets:size=8}O${font}${voffset -3}${goto 20}${font :size=6}Up: ${upspeed wlp3s0} ${alignr}${voffset -4}${upspeedgraph wlp3s0 10,120 FEC2A5 FA9C6F}
${voffset 4}${goto 5}${font PizzaDudeBullets:size=8}U${font}${voffset -3}${goto 20}${font :size=6}Down: ${downspeed wlp3s0} ${alignr}${voffset -4}${downspeedgraph wlp3s0 10,120 D9FFDF A5FEB3}
${voffset -19}
${if_match "${acpiacadapter}" != "on-line"}
$stippled_hr
${voffset -10}
# ---------------------------
# ----- BATTERY -------------
# ---------------------------
${color orange}${font :size=8}BATTERY:${color}${font :size=7} ${execi 3 upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep --color=never -E 'percentage' | awk '{print $2}' | tr -d '%' | grep -o '^[0-9]*'}% (${execi 3 upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep --color=never -E 'to\ empty' | awk '{printf $4 " " $5}' | tr -d '%'}) ${execbar upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep --color=never -E 'percentage' | awk '{print $2}' | tr -d '%'}
${font :size=6}Discharge Rate: ${exec ~/.conky/discharge_rate_for_conky.sh} ${alignr}${execgraph ~/.conky/discharge_rate_for_conky.sh 8,110 008844 ef010f -t}
${voffset -14}${endif}
# ---------------------------
# ----- CALENDAR ------------
# ---------------------------
${voffset 2}${color orange}${font :size=8}CALENDAR:${color} ${voffset -1}$stippled_hr
${voffset -5}${execpi 3 php /home/<username>/.conky/display_calendar_events.php}
# ---------------------------
# ----- AUDIO PLAYBACK ------
# ---------------------------
${if_match "${execi 3 playerctl --no-messages -p audacious status}" == "Playing"}\
${voffset 5}${color orange}${font LineAwesomeMod:size=11}c${font}${font :size=8} ${voffset -1}NOW PLAYING:${color} ${voffset -1}$stippled_hr
${goto 3}${voffset -1}${font :size=6}${execi 3 playerctl --no-messages -p audacious metadata artist | fold -sw 50}
${font DejaVu Sans Mono:size=10}♫${goto 11}${font :size=8} ${execi 3 playerctl --no-messages -p audacious metadata title | sed 's/http[^ ]*//g' | fold -sw 30 | sed 's/| |//' | perl -pe 'chomp if eof'}${font}\
${endif}
${voffset -87}
]]
Code: Select all
require 'cairo'
function conky_main ()
if conky_window == nil then
return
end
end
function conky_loadavg()
loadavg = conky_parse("${loadavg 1}") / 8
loadavg_graphval = string.sub(loadavg, 3, 4)
loadavg_graphval_no_leading_zeroes = string.gsub(loadavg_graphval, '0*', '', 1)
return loadavg_graphval_no_leading_zeroes
end
-- ==================================================
function rgb_to_r_g_b(color,alpha)
return ((color / 0x10000) % 0x100) / 255., ((color / 0x100) % 0x100) / 255., (color % 0x100) / 255., alpha
end --- end function rgb_to_r_g_b ---
-- ==================================================
-- ==================================================
function conky_gauge(p_label, p_unit, p_measure, p_max, p_warn, p_alarm, p_xr, p_yc)
--[[ NOTES:
-- "label" is the label/name for this gauge
-- "measure" is the type of stat to display; you can choose from 'cpu', 'memperc'... in Conky you would write ${cpu cpu0}
-- "max" is the maximum value of gauge
-- "warn" is the value at which warn colors takes effect... must be less than "max" value
-- "xr" & "yc" are the x/row y/col coordinates for center of gauge
-- for colors: regular rgb color prefixed with 0x as in 0x######
--]]
local cs = cairo_xlib_surface_create(conky_window.display,conky_window.drawable,conky_window.visual, conky_window.width,conky_window.height)
local cr = cairo_create(cs)
cairo_surface_destroy(cs)
--- items common to all rings ------------------
local bg_color = 0x36556b
local bg_alpha = 1.0
local ok_color = 0x00c600 -- color for ok guide/arc (default green) --
local ok_alpha = 1.0
local alarm_color = 0xff0000 -- color for alarm - whole gauge (default orange) ---
local alarm_alpha = 1.0
local warn_color = 0xffff00 -- color for warning guide/arc (default yellow) --
local warn_alpha = 1.0
local needle_color = 0xff5500 -- color of indicator needle (default orange) ---
local needle_alpha = 1.0
local label_color = 0xffffff -- color of label (same as "label" in conky.rc) --
local label_alpha = 1.0
local val_color = 0xffffff -- color of current value (same as "data" in conky.rc) --
local val_alpha = 1.0
local bg_radius = 15 -- gauge background starts here --
local guide_radius = 17 -- guide is the colored line (showing ok/warn zones) starts here --
local val_radius = 16 -- value indicator arc... generally between bg_radius & guide_radius --
local needle_radius = 10 -- bottom of needle rests here --
local bg_width = 5 -- width/thickness of background arc --
local guide_width = 1 -- width/thickness of guide arc --
local val_width = 2 -- width/thickness of value indicator arc --
local warn_width = 3 -- width/thickness of warn indicator arc (should we want it thicker for visibility --
local needle_width = 16 -- "length" of needle --
local needle_thickness = .07 -- give needle a thickness (actually width?) so it is visible, .04 was default --
local start_angle = -180 -- note: 0 is at "3 o'clock"... example: to start at top/12 o'clock use -90 --
local end_angle = 0
local angle_0 = (start_angle)*(math.pi/180)
local angle_f = (end_angle)*(math.pi/180)
local font = "Monospace"
local font_size = 9
local font_h = font_size -- normally same as font size, but adjust as needed --
local font_w = 5 -- adjust this for font used --
local font_slant = CAIRO_FONT_SLANT_NORMAL -- mono font does not have SLANT --
local font_face = CAIRO_FONT_WEIGHT_NORMAL -- mono font does not have BOLD --
cairo_select_font_face (cr, font, font_slant, font_face);
cairo_set_font_size (cr, font_size)
--- --------------------------------------------
--- individual ring items ----------------------
local label = p_label
local unit = p_unit
if unit == "nil" then unit = "" end
local measure = p_measure
local max = p_max
local alarm = tonumber(p_alarm)
local warn = tonumber(p_warn)
local xr = p_xr
local yc = p_yc
local str = conky_parse(measure)
local value = tonumber(str)
local pct = value/max
local pct_warn = warn/max
local pct_needle = (value/max)-needle_thickness -- we do a minus because needle starts at value & goes back amount set --
local t_arc = pct*(angle_f-angle_0)
local t_arc_warn = pct_warn*(angle_f-angle_0)
local t_arc_needle = pct_needle*(angle_f-angle_0)
-- ---------------------------------------------
--- draw background ring ---
cairo_arc(cr,xr,yc,bg_radius,angle_0,angle_f)
if value > alarm then
cairo_set_source_rgba(cr,rgb_to_r_g_b(alarm_color,alarm_alpha))
else
cairo_set_source_rgba(cr,rgb_to_r_g_b(bg_color,bg_alpha))
end
cairo_set_line_width(cr,bg_width)
cairo_stroke(cr)
--- draw OK area ring ---
cairo_arc(cr,xr,yc,guide_radius,angle_0,angle_0+t_arc_warn)
cairo_set_source_rgba(cr,rgb_to_r_g_b(ok_color,ok_alpha))
cairo_set_line_width(cr,guide_width)
cairo_stroke(cr)
--- draw warn area ring ---
cairo_arc(cr,xr,yc,guide_radius,angle_0+t_arc_warn,angle_f)
cairo_set_source_rgba(cr,rgb_to_r_g_b(warn_color,warn_alpha))
cairo_set_line_width(cr,guide_width)
cairo_stroke(cr)
--- draw value indicator ring ---
cairo_set_line_width(cr,val_width)
cairo_arc(cr,xr,yc,val_radius,angle_0,angle_0+t_arc)
cairo_set_source_rgba(cr,rgb_to_r_g_b(ok_color,ok_alpha))
cairo_stroke(cr)
if value > warn then
cairo_set_line_width(cr,warn_width)
cairo_arc(cr,xr,yc,val_radius,angle_0+t_arc_warn,angle_0+t_arc)
cairo_set_source_rgba(cr,rgb_to_r_g_b(warn_color,warn_alpha))
cairo_stroke(cr)
end
--- draw indicator needle ---
cairo_arc(cr,xr,yc,needle_radius,angle_0+t_arc_needle,angle_0+t_arc)
cairo_set_line_width(cr,needle_width)
cairo_set_source_rgba(cr,rgb_to_r_g_b(needle_color,needle_alpha))
cairo_stroke(cr)
--- display label text ---
if value > alarm then
cairo_set_source_rgba(cr,rgb_to_r_g_b(alarm_color,alarm_alpha))
elseif value > warn then
cairo_set_source_rgba(cr,rgb_to_r_g_b(warn_color,warn_alpha))
else
cairo_set_source_rgba(cr,rgb_to_r_g_b(label_color,label_alpha))
end
local text_label = label
-- get length of string, multiply by 4 (width of mono font), and divide by 2 to get center) --
-- note that special chars, such as ° in °F add one to length (this making it offcenter) --
text_label_pos = (string.len(text_label) * font_w) / 2
cairo_move_to (cr,xr-text_label_pos,yc)
cairo_show_text (cr,text_label)
cairo_stroke (cr)
--- display value text ---
if value > alarm then
cairo_set_source_rgba(cr,rgb_to_r_g_b(alarm_color,alarm_alpha))
elseif value > warn then
cairo_set_source_rgba(cr,rgb_to_r_g_b(warn_color,warn_alpha))
else
cairo_set_source_rgba(cr,rgb_to_r_g_b(val_color,val_alpha))
end
local text_value = value .. unit
text_value_pos = (string.len(text_value) * font_w) / 2
cairo_move_to (cr,xr-text_value_pos,yc+font_h)
cairo_show_text (cr,text_value)
cairo_stroke (cr)
-- use the following to test font width ---
-- cairo_set_source_rgba(cr,rgb_to_r_g_b(warn_color,warn_alpha))
-- cairo_move_to (cr,xr-text_value_len-1,yc+font_h)
-- cairo_show_text (cr,".")
-- cairo_stroke (cr)
-- cairo_move_to (cr,xr-text_value_len-1+font_w,yc+font_h)
-- cairo_show_text (cr,".")
-- cairo_stroke (cr)
cairo_destroy(cr)
return ""
end
-- ==================================================
- Logansfury
- Level 8
- Posts: 2411
- Joined: Fri Oct 27, 2023 4:08 pm
- Location: Las Vegas NV, USA
Re: Can anyone isolate the code for one of these gauges please? [SOLVED]
Can you post a screenshot of your conky? I would like to see what your Minimalis looks like.
Re: Can anyone isolate the code for one of these gauges please? [SOLVED]
Missing semicolons..minthelp777 wrote: ⤴Wed Oct 02, 2024 2:28 pm
conky.config = {
....
--function used to allow load to be displayed divided by # of CPUs (because otherwise it shows load as too high)
-- conky_loadavg() - need to divide load by the 8 (virtual) cores on this machine.
lua_load = '~/.conky/conky_myluafunctions.lua',
lua_draw_hook_pre = 'main'
}; <--- needs a semicolon here!
conky.text = [[
....
| sed 's/http[^ ]*//g' | fold -sw 30 | sed 's/| |//' | perl -pe 'chomp if eof'}${font}\
${endif}
${voffset -87}
]]; <--- and here!
-
- Level 3
- Posts: 178
- Joined: Mon Jul 29, 2024 8:18 pm
Re: Can anyone isolate the code for one of these gauges please? [SOLVED]
The semicolons didn't seem to make a difference, unfortunately. Thanks, though.
-
- Level 3
- Posts: 178
- Joined: Mon Jul 29, 2024 8:18 pm
Re: Can anyone isolate the code for one of these gauges please? [SOLVED]
Not sure what I did but all those errors went away. Then I was only getting a couple of these lines when I would first launch conky on the command line:zcot wrote: ⤴Wed Oct 02, 2024 11:40 amfirst 2 lines show failure because nil is returned fromCode: Select all
conky: Bad arguments: ' ' and ' 60' conky: compare failed for expression ' <= 60' conky: llua_getnumber: function conky_loadavg didn't return a number, result discarded conky: llua_do_call: function conky_loadavg execution failed: ~/.conky/conky_myluafunctions.lua:130: attempt to perform arithmetic on a nil value (local 'value')
lua conky_loadavg
,
-we know those 2 lines refer to the conky_rc line:${if_match ${lua conky_loadavg} <= 60}${color white}
the next 2 lines go further up to where the problem is starting, which we know is the lua scripting but you mentionconky_gauge
but the error mentionsconky_myluafunctions.lua
, so quite confusing as to what the real chain of process is on that, and it would be hard to start guessing other than starting from scratch and showing an entirely different solution.
you also throw in this comment about theconky_gauge
line, but I can not understand where that interacts with any of this.
In a case like this, if you just show some snippets, it's hard to really troubleshoot. The functionality is there, and even though there's not enough code to see exactly how it all works, it does look like it's part of a larger functional scripting setup.
Why don't you post the scripts so we can see all the calls and relationship of those snippets.
Code: Select all
conky: llua_do_call: function conky_gauge execution failed: /home/<username>/.conky/conky_myluafunctions.lua:130: attempt to perform arithmetic on a nil value (local 'value')
local value = tonumber(str)
:
Code: Select all
if value == nil then
return ''
end
Anyway, now I get no more errors. Thanks again guys.