You are not logged in.
Would love to know what scripting language your using to position the pointers in the dials. <whisper> and would love to see the code! </whisper>
it's lua code here cpu1.lua (attention in konsole there is an error at line 100)
--==============================================================================
-- baro.lua
--
-- author : SLK-adapted by shamen456
-- version : v2011-06-13
-- license : Distributed under the terms of GNU GPL version 2 or later
--
--==============================================================================
require 'cairo'
--------------------------------------------------------------------------------
-- gauge DATA
gauge = {
{
name='cpu', arg='cpu0', max_value=100, sub_value=0,
x=120, y=130,
graph_radius=56,
graph_thickness=80,
graph_start_angle=297,
graph_unit_angle=1.18, graph_unit_thickness=1.,
graph_bg_colour=0xFFFFFF, graph_bg_alpha=0,
graph_fg_colour=0xB1ADA7, graph_fg_alpha=0,
hand_fg_colour=0x303030, hand_fg_alpha=1,
},
}
-------------------------------------------------------------------------------
-- 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 = data['max_value']-data['sub_value']
local sub_value = data['sub_value']
local x, y = data['x'], data['y']
local graph_radius = data['graph_radius']
local graph_thickness, graph_unit_thickness = data['graph_thickness'], data['graph_unit_thickness']
local graph_start_angle = data['graph_start_angle']
local graph_unit_angle = data['graph_unit_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
-- 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-sub_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 * 2)
stop_arc = (graph_unit_angle * val)
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(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
-- text
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, "ubuntu", 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
local caption = data['caption']
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, "ubuntu", 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 + 5, y + toy + 1)
-- bad hack but not enough time !
if graph_start_angle < 105 then
cairo_move_to (display, x + tox - 30, y + toy + 1)
end
cairo_show_text (display, caption)
cairo_stroke (display)
end
-------------------------------------------------------------------------------
-- go_gauge_rings
-- loads data and displays gauges
--
function go_gauge_rings(display)
local function load_gauge_rings(display, data)
local str, value = '', 0
str = string.format('${%s %s}',data['name'], data['arg'])
str = conky_parse(str)
value = tonumber(str)
draw_gauge_ring(display, data, value)
end
for i in pairs(gauge) do
load_gauge_rings(display, gauge[i])
end
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
end
Last edited by loutch (2016-12-19 20:46:30)
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
Note that using backticks for shell commands can cause problems, and is not POSIX complient (it is an old legacy notation). The preferred notation is to use "$(...)":
days=$(uptime -p | awk '{print $2}')
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
@ damo
change it in file but no change in conky
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
@ damo
change it in file but no change in conky
I didn't expect it to. I was just pointing out that using backticks is not recommended in modern shells. You can check your code by using an online tool https://www.shellcheck.net/, or apt-get the shellcheck package.
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
AWESOME damo ... Tried to get shellcheck only to find I had it - :rolleyes: go figure - ran it, a few times, against my copy of thew script making changes and checking things:
https://github.com/koalaman/shellcheck/wiki/Sc2086
https://github.com/koalaman/shellcheck/wiki/SC1083
Then I "trimmed the fat" and ran it through shellcheck again:
19 Dec 16 @ 20:10:15 ~
$ shellcheck /media/5/Conky/SuperKaramba/scripts/up-time.sh
CLEAN! I'm Happy!
Thank you - looks good! A nice learning experience.
@loutch - if you are interested:
up-time.sh
#!/bin/bash
days=$(uptime -p | awk '{print $2}')
hours=$(uptime -p | awk '{print $4}')
mins=$(uptime -p | awk '{print $6}')
day1=${days:0:1}
day2=${days:1:1}
day3=${days:2:1}
hour1=${hours:0:1}
hour2=${hours:1:1}
min1=${mins:0:1}
min2=${mins:1:1}
if [ "$day3" = "" ] ;
then
if [ "$day2" = "" ] ;
then
if [ "$day1" != " " ] ;
then
echo "\${image /media/5/Conky/SuperKaramba/numbers/1-$day1.png -p 111,20}"
fi
else
echo "\${image /media/5/Conky/SuperKaramba/numbers/1-$day1.png -p 80,20}\${image /media/5/Conky/SuperKaramba/numbers/1-$day2.png -p 111,20}"
fi
else
echo "\${image /media/5/Conky/SuperKaramba/numbers/1-$day1.png -p 49,20}\${image /media/5/Conky/SuperKaramba/numbers/1-$day2.png -p 80,20}\${image /media/5/Conky/SuperKaramba/numbers/1-$day3.png -p 111,20}"
fi
if [ "$hour2" = "" ] ;
then
echo "\${image /media/5/Conky/SuperKaramba/numbers/1-$hour1.png -p 184,20}"
else
echo "\${image /media/5/Conky/SuperKaramba/numbers/1-$hour1.png -p 153,20}\${image /media/5/Conky/SuperKaramba/numbers/1-$hour2.png -p 184,20}"
fi
if [ "$min2" = "" ] ;
then
echo "\${image /media/5/Conky/SuperKaramba/numbers/1-$min1.png -p 256,20}"
else
echo "\${image /media/5/Conky/SuperKaramba/numbers/1-$min1.png -p 225,20}\${image /media/5/Conky/SuperKaramba/numbers/1-$min2.png -p 256,20}"
fi
Now I'll have to leave my computer up for a couple or 99 days to see everything is working correctly.
EDIT: Just found my open terminal on another desktop ... with some script OOPS!
19 Dec 16 @ 20:09:50 ~
$ shellcheck /media/5/Conky/SuperKaramba/scripts/up-time.sh
In /media/5/Conky/SuperKaramba/scripts/up-time.sh line 50:
echo \${image /media/5/Conky/SuperKaramba/numbers/1-$min1.png -p 225,20}\${image /media/5/Conky/SuperKaramba/numbers/1-$min2.png -p 256,20}
^-- SC1083: This { is literal. Check expression (missing ;/\n?) or quote it.
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC1083: This } is literal. Check expression (missing ;/\n?) or quote it.
^-- SC1083: This { is literal. Check expression (missing ;/\n?) or quote it.
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC1083: This } is literal. Check expression (missing ;/\n?) or quote it.
19 Dec 16 @ 20:09:52 ~
$
NICE shellcheck!!
Last edited by Sector11 (2016-12-19 23:52:28)
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
^ Something like this maybe...
if (( mins < 10 )) then
image=zero.png
fi
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
ok here's my screenshot..i went down from 2 conky's to 1...still a work in progress
Offline
^ Something like this maybe...
I use that kind of stuff all the time for CPU's, etc in the conky itself but the where and howto in a bash script is something I need to play with.
${alignc}${color6}1${color} ${if_match ${cpu cpu1} < 10} ${cpu cpu1}\
${else}${if_match ${cpu cpu1} < 100} ${cpu cpu1}\
${else}${color9}${cpu cpu1}${color}${endif}${endif}
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
down from 2 conky's to 1
Ahhh blue, my favourite colour. Be careful, go down one more and 'blink' no conky!
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
@loutch
Note that using backticks for shell commands can cause problems, and is not POSIX complient (it is an old legacy notation). The preferred notation is to use "$(...)":
days=$(uptime -p | awk '{print $2}')
Correct, however for whatever reason on my system my shell prefers the legacy notation - I was getting strange output using the preferred notation probably due to the shebang. #!/bin/sh will operate differently than #!/bin/bash. I have been in such a hurry to publish the code that I've not polished up my code as I should - I just made it work for my system and wasn't worried about portability, shebang, nor shell.
I feel bad I didn't note that in my code since I provided it for others to use...
I apologize for the mistake.
P.S. I'm a old guy and been doing bash long enough that the old legacy stuff still rolls off the top of the head where I have to think about the new notation...
Edited to add the following:
It really depends on how you write your bash scripts. /bin/sh is typically linked to the systems default shell. If your /bin/sh is symlinked to bash, when bash is invoked as sh, some features are unavailable: Bash-POSIX Mode
If you want bash-specific, non-POSIX features, use #!/bin/bash
Last edited by rwyarbrough (2016-12-20 21:45:28)
Offline
@Sector11
Set the variables in the bash script, which you call from the conky, then echo/print out the formatted conky code.
${execpi nnn ./path/to/images.sh}
In the script you pass the $image var to the print statement:
printf "\${position info here}%s" "$image"
Last edited by damo (2016-12-20 21:35:55)
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
I have some bash code that I wrote where I can "source" it into my scripts to provide debugging for my bash scripts. For something with as few lines as the uptime.sh script has, you can add echo/prints for the variables and static text in the conditional IF and else code to indicate where the code is branching for debugging.
Maybe we should start a bash scripting thread in a more appropriate area for bash scripting tips, help, etc???
P.S> Here is the defato Bash Manual.
Last edited by rwyarbrough (2016-12-20 21:48:14)
Offline
@everybody:
maybe i'm missing something here (just scrolled through 3+ pages since my last post) but if you want to parse uptime to be displayed with nixietubes, isn't it counterproductive to use the "-p" a.k.a "pretty" switch?
meaning, uptime's output is more predictable and thus parseable by a script if you just use it like this:
#!/bin/bash
uptime_var="$(uptime)"
# now do unspeakable bash-things to this string! harharhar!!!
Offline
@everybody:
<snip snip>
uptime's output is more predictable and thus parseable by a script if you just use it like this:#!/bin/bash uptime_var="$(uptime)" # now do unspeakable bash-things to this string! harharhar!!!
The normal uptime output is also somewhat unpredictable.
before kernel upgrade reboot:
robert@ubuntumain>uptime
16:44:47 up 10 days, 23:55, 1 user, load average: 0.04, 0.09, 0.08
after kernel upgrade reboot:
robert@ubuntumain>uptime
17:29:11 up 38 min, 2 users, load average: 0.75, 1.68, 0.44
Last edited by rwyarbrough (2016-12-27 23:52:52)
Offline
Not my conky, but I think these are awesome...
Oblivion Themed Conky at Deviant Art
Last edited by rwyarbrough (2016-12-29 13:46:12)
Offline
These are also pretty neat
The link below is taklertama's favorite conkys list on Deviant Art.
talkertama's Favorites
A search for conky on Deviant Art
Deviant Art Search for conky
Offline
The normal uptime output is also somewhat unpredictable.
before kernel upgrade reboot:
robert@ubuntumain>uptime 16:44:47 up 10 days, 23:55, 1 user, load average: 0.04, 0.09, 0.08
after kernel upgrade reboot:
robert@ubuntumain>uptime 17:29:11 up 38 min, 2 users, load average: 0.75, 1.68, 0.44
indeed, i missed that.
it seems the best solution would be to simply query /proc/uptime.
uptime in seconds:
uptime_var="$(cut -f1 -d. /proc/uptime)"
now there's a simple number you can bash around with!
Offline
now there's a simple number you can bash around with!
Or simply go for the gold - took me HOURS searching the net to get the right combo
from: man last
The pseudo user reboot logs in each time the system is rebooted. Thus last reboot will show a log of all reboots since the log file was created.
-x Display the system shutdown entries and run level changes.
-num This is a count telling last how many lines to show.
-n num The same.
OK this is easy:
31 Dec 16 @ 11:47:35 ~
$ last -x reboot -1
reboot system boot 3.16.0-4-amd64 Sat Dec 31 09:10 - 11:51 (02:41)
wtmp begins Thu Dec 1 11:18:44 2016
31 Dec 16 @ 11:51:40 ~
$
What we want is that time between the ( ) at the end
This is where the hunt started for the right command .....
tadaaaaaa
31 Dec 16 @ 11:58:32 ~
$ last -x reboot -1
reboot system boot 3.16.0-4-amd64 Sat Dec 31 09:10 - 11:58 (02:48)
wtmp begins Thu Dec 1 11:18:44 2016
31 Dec 16 @ 11:58:39 ~
$ last -x reboot -1 | cut -d' ' -f17 | sed 's/^.*(//;s/)$//'
02:48
31 Dec 16 @ 11:58:43 ~
$
I think in my travels across the net I saw that it uses:
(9+02:48)
for "days" so it still works:
31 Dec 16 @ 12:01:53 ~
$ echo '(9+02:48)' | sed 's/^.*(//;s/)$//'
9+02:48
31 Dec 16 @ 12:03:14 ~
$
Now someone else will need to sed/grep/cut/chop/slice/dice and puree that up into
if exist: days
if exist: HH
MM <--- pretty well a given.
test.conky:
${color9}${swapbar 0}${color}
uptime: ${uptime}
/proc/uptime: ${exec cut -f1 -d. /proc/uptime} seconds
who: ${pre_exec who -b | cut -c 23-}
boot time who: ${pre_exec who -b | cut -d' ' -f14}
---
uptime last: ${exec last -x reboot -1 | cut -d' ' -f17 | sed 's/^.*(//;s/)$//'}--
${color9}${swapbar 0}${color}
Don't like the extra "return" after the uptime last command though.
See the: --
Debian 12 Beardog, SoxDog and still a Conky 1.9er
Offline
Offline