SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#6276 2013-09-30 03:35:10

apsoul
Member
Registered: 2011-10-25
Posts: 19

Re: Conky v1.9 Thread

oliverseal wrote:
apsoul wrote:

I understand that writing scripts such as yall have is probably less resource intensive, but other than that are there any objections to this way of doing things?

The main reason I put together scripts is because conky is not-so-good at escaping things when they are in the exec directive. For example if you ever need to grep "}", passes just grep "} to the output.

On an very completely unrelated note: I really wish these forums supported markdown.


Not that I completely understand the ramifications of this fault in conky, and I am about to speak somewhat blindly as I don't really know what I am talking about here, but...
Would the better way (within the scope of "grep xxx | grep xx | cut -c xx-xx") to do things be to write a shell script that outputs to a text file. Call upon the script once per conky refresh such as the weather conkys do via lua and extract data from that text file in a conky format-able manner?

edit: This is the first time I've used piping in terminal other than copy/paste from how-to's found on the interwebs for various tasks. I am very excited about the fact that I can finally use a previously-useless-to-me character on the keyboard lol.. not to mention how useful it can be smile

Last edited by apsoul (2013-09-30 03:43:40)

Offline

Be excellent to each other!

#6277 2013-09-30 04:08:07

oliverseal
Member
Registered: 2013-09-16
Posts: 18

Re: Conky v1.9 Thread

It's going to be more resource intensive to buffer that stuff into a text file.
The only reason to ever save a text file is if you don't want to actually process anything in realtime. For example, my conky shows meetings from several google calendars (mine and colleagues). I don't want that to connect to the internet every refresh so I set it up as a crontab (system-wide scheduler) that outputs a file called "events.data" every ten minutes. conky reads in that file rather than actually reaching all the way out to google servers every second.

For what you are looking for (the current temp of the GPU), it's best to just take the info that is output each time you ask, so you have the most up to date info. I'm assuming the sensor for the temperature on the card probably updates its reading at a rate than 1 seconds, so it's not likely done in vain.

Offline

#6278 2013-09-30 04:37:51

apsoul
Member
Registered: 2011-10-25
Posts: 19

Re: Conky v1.9 Thread

Sounds reasonable. Well thanks again for the help. Here is a screenshot of my dedicated screen conky in progress (with menu as a peek at the theme I'm working on.) Still lots more work to do on it, but it is getting there. All gpu info, including the gpu model have been accessed via nvidia-smi -a | grep...
I have found that nvidia-smi doesn't seem to give me gpu frequency, so for sake of compatibility with a multi-gpu setup, I plan on hunting down those numbers in "~$ nvidia-settings -q all"  I can also access memoryInterface (192bit) cuda cores, and much other info from nvidia-settings, however I am done for tonight.

the grey space on bottom right is off screen as my right monitor is only 1024x768 and main monitor is 1920x1080.
conkyinprogress.jpg

Offline

#6279 2013-09-30 13:03:45

ragamatrix
#! Junkie
From: Earth
Registered: 2012-12-05
Posts: 286

Re: Conky v1.9 Thread

Hi,
The evolution of multi "screens" and "backgrounds" must have the same style. what I'm working on:
mode1:
Capture_cran_mod1.jpg
mode2:
Capture_cran_mode2.jpg
mode3:
Capture_cran_mode3.jpg

Offline

#6280 2013-09-30 13:40:15

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

@ apsoul - very nice.

Colours are hard on my eyes, but otherwise -->> YEA!

I like the small monitor dedicated to conky/tint2 idea.


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#6281 2013-09-30 13:43:27

Sector11
#!'er to BL'er
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 15,667
Website

Re: Conky v1.9 Thread

@ ragamatrix

Now that's nice - especially with your choice of backgrounds.


·  ↓   ↓   ↓   ↓   ↓   ↓  ·
BunsenLabs Forums now Open for Registration
·  ↑   ↑   ↑   ↑   ↑   ↑  · BL ModSquad

Offline

#6282 2013-09-30 15:06:52

dk75
#! Junkie
Registered: 2012-06-14
Posts: 250

Re: Conky v1.9 Thread

spiritchaser wrote:

hi guys, is it possible to have colored background on part of text, i mean something like if you apply background-color:blue in css on header tag.

alternatively i could do a conky that draws said rectangle and put it just underneath that text, but isn't there a nicer way to do that?

You could check this: http://wlourf.deviantart.com/art/Text-w … -192574368


Debian Sid (Minted) x86_64/3.12-10, Conky 2.0_pre, Xorg 7.7/1.15.0, KDE 4.11.5, Intel X3100
Lenovo T61, HITACHI HTS722010K9SA00 100GB, WDC_WD5000BEVT 500GB
Linux user No.: 483055 | Conky Pitstop

Offline

#6283 2013-10-01 10:02:06

ragamatrix
#! Junkie
From: Earth
Registered: 2012-12-05
Posts: 286

Re: Conky v1.9 Thread

Hello,
Is it possible to add a "fade" effect transition in a conky slide-show ?

Offline

#6284 2013-10-02 14:23:46

boisei0
#! CrunchBanger
From: Gaanderen, Netherlands
Registered: 2013-07-16
Posts: 193

Re: Conky v1.9 Thread

My current Conky project: integrate a MoC front-end for Conky. I'm about to add shuffle and repeat buttons on the right and a volume slider on the left. I have to rethink the way the text is shown.

H8lEvYu.png


YAWS (cli weather script with conkyForecast syntax) | Bitbucket | Github | Blog
Member of the Unofficial #! Emergency Tinfoil Hat Distribution Center
Emergency Tinfoil Hat Conky Alert System development team

Offline

#6285 2013-10-03 10:40:54

ragamatrix
#! Junkie
From: Earth
Registered: 2012-12-05
Posts: 286

Re: Conky v1.9 Thread

I fouded an interesant script, but now I have to find a way to use it in conky...
slide_show_transition_morph_effect

Offline

#6286 2013-10-03 18:23:58

.devon
Member
From: Charlotte, NC
Registered: 2013-10-03
Posts: 21

Re: Conky v1.9 Thread

@ragamatrix
I like that, it'd look good spread out on 3 screens. Can i ask if those are 3 completely different wallpapers, or if they share the globe centered pattern and the moon on a separate layer or something?


"Wisdom begins in wonder." -Socrates

Offline

#6287 2013-10-03 22:08:46

.devon
Member
From: Charlotte, NC
Registered: 2013-10-03
Posts: 21

Re: Conky v1.9 Thread

Its been 4 days since i discovered #!, so this is what i've done with conky so far wink

2013_10_03_1380837760_1024x600_scrot.jpg

and here's my .conkyrc

# set to yes if you want Conky to be forked in the background
background yes

# Use Xft?
use_xft yes

# Xft font when Xft is enabled
#xftfont Trebuchet MS:size=10
xftfont Sans:size=8

# Text alpha when using Xft
xftalpha 1

# Update interval in seconds
update_interval 1.0

# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0

own_window yes
own_window_transparent yes
#own_window_type override
own_window_type desktop
#own_window_type normal #use this if you want a nice shadow to appear around conky

# If own_window is yes, these window manager hints may be used
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager

# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes

# Minimum size of text area
minimum_size 200 200

# Maximum width
maximum_width 220

# Draw shades?
draw_shades yes

# Draw outlines?
draw_outline no

# Draw borders around text
draw_borders no

# Draw borders around graphs
draw_graph_borders yes

# Stippled borders?
stippled_borders 8

# border margins
border_margin 6

# border width
# border_width 1

# Default colors and also border colors
default_color white
default_shade_color black
default_outline_color white

# Text alignment, other possible values are commented
#alignment top_left
alignment top_right
#alignment bottom_left
#alignment bottom_right
#alignment none

# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 12
gap_y 12

# Subtract file system buffers from used memory?
no_buffers yes

# set to yes if you want all text to be in uppercase
uppercase no

# number of cpu samples to average
# set to 1 to disable averaging
cpu_avg_samples 2

# Force UTF8? note that UTF8 support required XFT
override_utf8_locale yes

##############################################
##############################################

TEXT


${color 666666}SYSTEM INFO${color} ${color 666666}${hr}${color}
CrunchBang Linux  ${alignr}12.5.2010
Uptime:$alignr$uptime

${color 666666}${font sans-serif:normal:size=8}TIME AND DATE${color} ${color 666666}${hr}
${alignc}${font Arial Black:size:24}${color CCCCCC}${time %H:%M}${color}${font}
${alignc}${color CCCCCC}${Time %A %m %d %Y}${color}

${color 666666}PROCESSOR${color} ${color 666666}${hr}${color}
${font sans-serif:normal:size=8}${cpugraph cpuaverage}
Temps:$alignr${exec sensors | grep "Core 0" | awk '{print $3}' | cut -c2-3}°C / ${exec sensors | grep "Core 1" | awk '{print $3}' | cut -c2-3}°C
Frequency:$alignr${freq_g} Ghz
Core1: ${cpu cpu1}% ${cpubar cpu1}
Core2: ${cpu cpu2}% ${cpubar cpu2}
Core3: ${cpu cpu3}% ${cpubar cpu3}
Core4: ${cpu cpu4}% ${cpubar cpu4}

${color 666666}MEMORY${color} ${color 666666}${hr}${color}
${font sans-serif:normal:size=8}RAM $alignc $mem / $memmax $alignr $memperc%
$membar
${color 666666}DRIVE SPACE${color} ${color 666666}${hr}${color}
${font sans-serif:normal:size=8}SSD $alignc ${fs_used /} / ${fs_size /} $alignr ${fs_used_perc /}%
${fs_bar /}

${color 666666}PROCESS${color} ${color 666666}${hr}${color}
${color 666666}NAME${color} $alignr PID    CPU
${top name 1} $alignr ${top pid 1} ${top cpu 1}
${top name 2} $alignr ${top pid 2} ${top cpu 2}
${top name 3} $alignr ${top pid 3} ${top cpu 3}
${top name 4} $alignr ${top pid 4} ${top cpu 4}
${top name 5} $alignr ${top pid 5} ${top cpu 5}

${color 666666}NETWORK${color} ${color 666666}${hr}${color}${if_existing /proc/net/route eth0}

ESSID: $alignr ${wireless_essid eth0}     ${color 666666}Ethernet$color
IP address: $alignr ${addr eth0}
Up: ${upspeed eth0} kb/s ${alignr}${upspeedgraph eth0 8,70 99CCFF 6666FF}
Down: ${downspeed eth0} kb/s ${alignr}${downspeedgraph eth0 8,70 99CCFF 6666FF}
Upload: ${alignr}${totalup eth0}
Download: ${alignr}${totaldown eth0}
${gw_ip}${else}${if_existing /proc/net/route wlan0}
ESSID: $alignr ${wireless_essid wlan0}     ${color 666666}Wireless$color
IP address: $alignr ${addr wlan0}
Down: ${downspeed wlan0} kb/s ${alignr}${downspeedgraph wlan0 15,70 99CCFF 6666FF}
Up: ${upspeed wlan0} kb/s ${alignr}${upspeedgraph wlan0 15,70 99CCFF 6666FF}

"Wisdom begins in wonder." -Socrates

Offline

#6288 2013-10-03 22:22:48

arclance
#! Die Hard
Registered: 2012-03-29
Posts: 987

Re: Conky v1.9 Thread

apsoul wrote:

I have found that nvidia-smi doesn't seem to give me gpu frequency, so for sake of compatibility with a multi-gpu setup,

nvidia-smi is broken for all but a very small set of Nivdias most expensive gpus (no geforces are supported) partly due to Nvidia dropping real support for all but the models listed at the beginning of a "nvidia-smi -h" command.

Supported products:
- Full Support
    - NVIDIA Tesla Line:
            S2050, C2050, C2070, C2075,
            M2050, M2070, M2075, M2090,
            X2070, X2090,
            K10, K20, K20X, K20Xm, K20c, K20m, K20s
    - NVIDIA Quadro Line:
            410, 600, 2000, 4000, 5000, 6000, 7000, M2070-Q
            K2000, K2000D, K4000, K5000, K6000
    - NVIDIA GRID Line:
            K1, K2, K340, K520
    - NVIDIA GeForce Line: None
- Limited Support
    - NVIDIA Tesla Line:   S1070, C1060, M1060 and all other previous generation Tesla-branded parts
    - NVIDIA Quadro Line:  All other current and previous generation Quadro-branded parts
    - NVIDIA GeForce Line: All current and previous generation GeForce-branded parts

There is also a bug in the nvml library used by nvidia-smi that causes it to incorrectly report that other devices do not support some of the data checked by nvidia-smi causing those fields to incorrectly show a "N/A" value for that device.

There is a fix for the nvml library here that you can compile yourself to get all the data possible for your card.
In my case I get data for the Clocks, Utilization, and Performance State sections when using this fix with my GTX 560 Ti and GT 240 cards but not without it.
This allows me to get frequency data with nvidia-smi which I previously had to use nvidia-settings to get.
I can also get GPU and GPU Memory Utilization which was impossible to get in Linux before.

I have noticed that if you try to access a field that your card does not support with the nvml library when using this fix it can cause a short hang in things rendered with opengl.
To avoid that problem I now use the nvidia-ml-py python bindings for the nvml library to get only the data I want.
The example for using the library is actually nvidia-smi written in python so it is easy to see what python code you need to use to get the same thing shown in a nvidia-smi call.

This is the python script I wrote to do that.

#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
"""
Name: nvmlConky.py
Author: arclance
Date_Created:2013-08-21
Date_Updated:2013-08-21

python script to query data about nvidia a nvidia gpu using the nvidia-ml-py nvml library wrapper.
This intends to be test if not querying data not supported by the gpu does not cause the driver to block opengl output during the query which results in a visible stick in opengl output when the query is made.

Required: nvidia-ml-py | https://pypi.python.org/pypi/nvidia-ml-py

v1.0
"""

from pynvml import *
#########################

def queryGPU():
	# Load nvml library
	nvmlInit()
	#####################
	GPU_DriverVersion = nvmlSystemGetDriverVersion()
	## get gpu handle (If you have multiple GPUs you need one for each)
	GPU_Handle = nvmlDeviceGetHandleByIndex(0)
	# Temp in C
	GPU_Temp = nvmlDeviceGetTemperature(GPU_Handle, NVML_TEMPERATURE_GPU)
	GPU_FanSpeed = nvmlDeviceGetFanSpeed(GPU_Handle)
	## Mem Info in bytes
	GPU_MemInfo = nvmlDeviceGetMemoryInfo(GPU_Handle)
	GPU_MemTotal = GPU_MemInfo.total
	GPU_MemUsed = GPU_MemInfo.used
	GPU_PowerState = nvmlDeviceGetPowerState(GPU_Handle)
	GPU_Util = nvmlDeviceGetUtilizationRates(GPU_Handle)
	GPU_Utilization = GPU_Util.gpu
	#MEM_Utilization = GPU_Util.mem # This is a measure of how saturated the gpu memory read/write capability is not how much memory is being used.
	## Clocks in MHz
	GPU_GraphicsClock = nvmlDeviceGetClockInfo(GPU_Handle, NVML_CLOCK_GRAPHICS)
	GPU_SMClock = nvmlDeviceGetClockInfo(GPU_Handle, NVML_CLOCK_SM)
	GPU_MemClock = nvmlDeviceGetClockInfo(GPU_Handle, NVML_CLOCK_MEM)
	#####################
	# Unload nvml library
	nvmlShutdown()
	#####################
	#print(str(GPU_GraphicsClock))
	GPU_MemPercent = (float(GPU_MemUsed)/float(GPU_MemTotal))*100
	### Format data into string that can be compiled into a lua table with "assert(loadstring(sensorData))" in a lua script
	luaOutput = "return {version='" + str(GPU_DriverVersion) + "', temp=" + str(GPU_Temp) + ", fanSpeed=" + str(GPU_FanSpeed) + ", memTotal=" + str(GPU_MemTotal/1024/1024) + ", memUsed=" + str(GPU_MemUsed/1024/1024) + ", memPercent=" + str.format("{:0.2f}", GPU_MemPercent) + ", gpuUtilization=" + str(GPU_Utilization) + ", powerState='" + str(GPU_PowerState) + "', gpuClock=" + str(GPU_GraphicsClock) + ", SMClock=" + str(GPU_SMClock) + ", memClock=" + str(GPU_MemClock) + "}"
	print(luaOutput)
#enddef

queryGPU()

It only supports one gpu but all you need to do if you have more is make a GPU_Handle for each one and then get the data for each individual gpu using it's respective handle.

You can see this data displayed in my conky here.

Last edited by arclance (2013-10-03 23:02:56)

Offline

#6289 2013-10-04 07:57:42

ragamatrix
#! Junkie
From: Earth
Registered: 2012-12-05
Posts: 286

Re: Conky v1.9 Thread

.devon wrote:

@ragamatrix
I like that, it'd look good spread out on 3 screens. Can i ask if those are 3 completely different wallpapers, or if they share the globe centered pattern and the moon on a separate layer or something?

I'm using a script "supposed to be" which display weather forecast on the background with accuweather (it's in French) but i'm using it for create frames, transparents backgrouds, because it's using imagemagick-convert, can also display rss feeds, mails, (things doesn't need to be often actualised)For processes machine, times, music and slides-show I use conky...
It's displayed on only background at a time, the script displays only on one.

slideshow2.jpg

Offline

#6290 2013-10-04 21:53:32

Naik
#! Die Hard
From: Leipzig
Registered: 2012-11-16
Posts: 595

Re: Conky v1.9 Thread

Hey @all!

amazing things are happening here a allways. thumbs up!

i have a small question right now: Why is it, that everytime i call a second sesion of conky from within the first one, like:

${if_running mocp}${exec conky -c .mocconkyrc &}$endif

the second one works great while the firt sesion kind of dissapears? (only a small square of the default color is shown in the top left of the "window")

Edit: Sorry! reading man conky again taught me that using -o flag forces a new window.
using ${exec conky -o -c .mocconkyrc &} solved my problem!

thanks, naik

Last edited by Naik (2013-10-04 22:01:46)


*kaum macht man es richtig, funktioniert es sofort*

Offline

#6291 2013-10-04 22:02:54

.devon
Member
From: Charlotte, NC
Registered: 2013-10-03
Posts: 21

Re: Conky v1.9 Thread

im a week old noob, but i'd try getting rid of that "&"
or if its a part of the file name get rid of that space, ive had good results with "...\ ..." and such

Last edited by .devon (2013-10-04 22:04:33)


"Wisdom begins in wonder." -Socrates

Offline

#6292 2013-10-04 22:44:18

Naik
#! Die Hard
From: Leipzig
Registered: 2012-11-16
Posts: 595

Re: Conky v1.9 Thread

^ thanks! yeah, this was part of my first aatempts to make this work, like in the autostart.
as it looks now, it makes no difference but i cleaned this off!


*kaum macht man es richtig, funktioniert es sofort*

Offline

#6293 2013-10-04 23:00:15

.devon
Member
From: Charlotte, NC
Registered: 2013-10-03
Posts: 21

Re: Conky v1.9 Thread

Im still perfecting my right panel conky, lol eventually ill get another panel started with some better weather stuff, an interactive music thing and possibly pack some more system specifications or monitoring tools in there smile
I'd love to see a screen shot of your conky setup
keep on #!'in


"Wisdom begins in wonder." -Socrates

Offline

#6294 2013-10-05 07:10:40

Naik
#! Die Hard
From: Leipzig
Registered: 2012-11-16
Posts: 595

Re: Conky v1.9 Thread

UPDATE2: well, it still won`t work as expected!
intead parent window just freezes and there is no way to make it work again but making the {if_running}condition false and restarting.
did i miss something?
Thanks , naik


*kaum macht man es richtig, funktioniert es sofort*

Offline

#6295 2013-10-05 12:10:14

dk75
#! Junkie
Registered: 2012-06-14
Posts: 250

Re: Conky v1.9 Thread

Yup.
You miss one basic fact - Conky is single threaded and everything that you run from it steals that thread from it, so it hang, until child process ends.

If you make loader script, in Python for example, that starts other scripts/Conkys in separate process then maybe...

Last edited by dk75 (2013-10-05 12:11:49)


Debian Sid (Minted) x86_64/3.12-10, Conky 2.0_pre, Xorg 7.7/1.15.0, KDE 4.11.5, Intel X3100
Lenovo T61, HITACHI HTS722010K9SA00 100GB, WDC_WD5000BEVT 500GB
Linux user No.: 483055 | Conky Pitstop

Offline

#6296 2013-10-05 13:53:49

Naik
#! Die Hard
From: Leipzig
Registered: 2012-11-16
Posts: 595

Re: Conky v1.9 Thread

^ thanks for that dk75!
but starting a mocconky.sh to run the new conky doesn`t work either..

${if_running mocp}${exec sh ~/scripts/mocconky.sh}$endif
#!/bin/bash
#launch another session of conky to display mocp --info

conky -o -c .mocconkyrc
exit

*kaum macht man es richtig, funktioniert es sofort*

Offline

#6297 2013-10-05 14:00:06

arclance
#! Die Hard
Registered: 2012-03-29
Posts: 987

Re: Conky v1.9 Thread

^^ You can start and stop another program with conky depending on if a certain program is running or not with a lua script.

Here is a example of how I start my cover art python script when deadbeef starts and kill it when deadbeef closes.

if tonumber(conky_parse('${updates}')) < 2 then --# don't reset these global variables when changes are made to the lua script
	deadbeefRunning = 0
elseif deadbeefRunning == nil then --# recreate variable if .conkyrc is edited (will break functionality if you do it while program is running though)
	deadbeefRunning = 0
end --# if tonumber(conky_parse('${updates}')) < 2 then

local deadbeef_state = conky_parse("${if_running deadbeef-main}1${else}0${endif}")
if deadbeef_state == "1" then
	if deadbeefRunning < 5 then
		deadbeefRunning = deadbeefRunning + 1
		if deadbeefRunning == 5 then
			os.execute("python ~/deadbeefCovers_many.py &")
		end --# if deadbeefRunning == 5 then
	elseif deadbeefRunning >= 5 then
	--# display stuff here
	end --# if deadbeefRunning < 5 then
else
	if deadbeefRunning ~= 0 then
		os.execute('pkill -f ".*deadbeefCovers_many.py"')
		deadbeefRunning = 0
	end --# if deadbeefRunning ~= 0 then
end --# if deadbeef_state == 1 then

Offline

#6298 2013-10-05 16:04:08

dk75
#! Junkie
Registered: 2012-06-14
Posts: 250

Re: Conky v1.9 Thread

Naik wrote:

^ thanks for that dk75!
but starting a mocconky.sh to run the new conky doesn`t work either..

${if_running mocp}${exec sh ~/scripts/mocconky.sh}$endif
#!/bin/bash
#launch another session of conky to display mocp --info

conky -o -c .mocconkyrc
exit

Because shell process uses parent thread by default.


Debian Sid (Minted) x86_64/3.12-10, Conky 2.0_pre, Xorg 7.7/1.15.0, KDE 4.11.5, Intel X3100
Lenovo T61, HITACHI HTS722010K9SA00 100GB, WDC_WD5000BEVT 500GB
Linux user No.: 483055 | Conky Pitstop

Offline

#6299 2013-10-05 16:42:49

Naik
#! Die Hard
From: Leipzig
Registered: 2012-11-16
Posts: 595

Re: Conky v1.9 Thread

^Oh, ok! i didnt know that!
@arclance: Thanks for that! but it brings up another question: Is it possible to add this to an existing lua-script (like the following)? because otherwise i`d have to cope with multiple luas running and this would be merely the same problem i sugest...

--[[
Clock Rings by londonali1010 (2009) Edited by jpope

This script draws percentage meters as rings, and also draws clock hands if you want! It is fully customisable; all options are described in the script. This script is based off a combination of my clock.lua script and my rings.lua script.

IMPORTANT: if you are using the 'cpu' function, it will cause a segmentation fault if it tries to draw a ring straight away. The if statement on line 145 uses a delay to make sure that this doesn't happen. It calculates the length of the delay by the number of updates since Conky started. Generally, a value of 5s is long enough, so if you update Conky every 1s, use update_num>5 in that if statement (the default). If you only update Conky every 2s, you should change it to update_num>3; conversely if you update Conky every 0.5s, you should use update_num>10. ALSO, if you change your Conky, is it best to use "killall conky; conky" to update it, otherwise the update_num will not be reset and you will get an error.

To call this script in Conky, use the following (assuming that you save this script to ~/scripts/rings.lua):
    lua_load ~/scripts/clock_rings.lua
    lua_draw_hook_pre clock_rings
    
Changelog:
+ v1.0 -- Original release (30.09.2009)
   v1.1p -- Jpope edit (05.10.2009)
]]

settings_table = {
    {
        -- Edit this table to customise your rings.
        -- You can create more rings simply by adding more elements to settings_table.
        -- "name" is the type of stat to display; you can choose from 'cpu', 'memperc', 'fs_used_perc', 'battery_used_perc'.
        name='cpu',
        -- "arg" is the argument to the stat type, e.g. if in Conky you would write ${cpu cpu0}, 'cpu0' would be the argument. If you would not use an argument in the Conky variable, use ''.
        arg='cpu0',
        -- "max" is the maximum value of the ring. If the Conky variable outputs a percentage, use 100.
        max=100,
        -- "bg_colour" is the colour of the base ring.
        bg_colour=0x24242E,
        -- "bg_alpha" is the alpha value of the base ring.
        bg_alpha=0.0,
        -- "fg_colour" is the colour of the indicator part of the ring.
        fg_colour=0x24242E,
        -- "fg_alpha" is the alpha value of the indicator part of the ring.
        fg_alpha=0.6,
        -- "x" and "y" are the x and y coordinates of the centre of the ring, relative to the top left corner of the Conky window.
        x=401, y=87,
        -- "radius" is the radius of the ring.
        radius=27,
        -- "thickness" is the thickness of the ring, centred around the radius.
        thickness=12,
        -- "start_angle" is the starting angle of the ring, in degrees, clockwise from top. Value can be either positive or negative.
        start_angle=191,
        -- "end_angle" is the ending angle of the ring, in degrees, clockwise from top. Value can be either positive or negative, but must be larger than start_angle.
        end_angle=450
    },

    {
        name='memperc',
        arg='',
        max=100,
        bg_colour=0x24242E,
        bg_alpha=0.1,
        fg_colour=0x24242E,
        fg_alpha=0.6,
        x=401, y=87,
        radius=13,
        thickness=7,
        start_angle=155,
        end_angle=490
    },
    {
        name='downspeedf',
        arg='wlan0',
        max=1536,
        bg_colour=0x24242E,
        bg_alpha=0.1,
        fg_colour=0x24242E,
        fg_alpha=0.6,
        x=401, y=87,
        radius=52,
        thickness=11,
        start_angle=222,
        end_angle=580
    },
    {
        name='upspeedf',
        arg='wlan0',
        max=423,
        bg_colour=0x24242E,
        bg_alpha=0.1,
        fg_colour=0x24242E,
        fg_alpha=0.6,
        x=401, y=87,
        radius=42,
        thickness=6,
        start_angle=222,
        end_angle=580
    },

}

-- Use these settings to define the origin and extent of your clock.

clock_r=97

-- "clock_x" and "clock_y" are the coordinates of the centre of the clock, in pixels, from the top left of the Conky window.

clock_x=401
clock_y=87

show_seconds=true

require 'cairo'

function rgb_to_r_g_b(colour,alpha)
    return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end

function draw_ring(cr,t,pt)
    local w,h=conky_window.width,conky_window.height
    
    local xc,yc,ring_r,ring_w,sa,ea=pt['x'],pt['y'],pt['radius'],pt['thickness'],pt['start_angle'],pt['end_angle']
    local bgc, bga, fgc, fga=pt['bg_colour'], pt['bg_alpha'], pt['fg_colour'], pt['fg_alpha']

    local angle_0=sa*(2*math.pi/360)-math.pi/2
    local angle_f=ea*(2*math.pi/360)-math.pi/2
    local t_arc=t*(angle_f-angle_0)

    -- Draw background ring

    cairo_arc(cr,xc,yc,ring_r,angle_0,angle_f)
    cairo_set_source_rgba(cr,rgb_to_r_g_b(bgc,bga))
    cairo_set_line_width(cr,ring_w)
    cairo_stroke(cr)
    
    -- Draw indicator ring

    cairo_arc(cr,xc,yc,ring_r,angle_0,angle_0+t_arc)
    cairo_set_source_rgba(cr,rgb_to_r_g_b(fgc,fga))
    cairo_stroke(cr)        
end

function draw_clock_hands(cr,xc,yc)
    local secs,mins,hours,secs_arc,mins_arc,hours_arc
    local xh,yh,xm,ym,xs,ys
    
    secs=os.date("%S")    
    mins=os.date("%M")
    hours=os.date("%I")
        
    secs_arc=(2*math.pi/60)*secs
    mins_arc=(2*math.pi/60)*mins+secs_arc/60
    hours_arc=(2*math.pi/12)*hours+mins_arc/12
        
    -- Draw hour hand
    
    xh=xc+0.7*clock_r*math.sin(hours_arc)
    yh=yc-0.7*clock_r*math.cos(hours_arc)
    cairo_move_to(cr,xc,yc)
    cairo_line_to(cr,xh,yh)
    
    cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
    cairo_set_line_width(cr,5)
    cairo_set_source_rgba(cr,0.14,0.14,0.18,0.93)
    cairo_stroke(cr)
    
    -- Draw minute hand
    
    xm=xc+clock_r*math.sin(mins_arc)
    ym=yc-clock_r*math.cos(mins_arc)
    cairo_move_to(cr,xc,yc)
    cairo_line_to(cr,xm,ym)
    
    cairo_set_line_width(cr,3)
    cairo_stroke(cr)
    
    -- Draw seconds hand
    
    if show_seconds then
        xs=xc+clock_r*math.sin(secs_arc)
        ys=yc-clock_r*math.cos(secs_arc)
        cairo_move_to(cr,xc,yc)
        cairo_line_to(cr,xs,ys)
    
        cairo_set_line_width(cr,1)
        cairo_stroke(cr)
    end
end

function conky_clock_rings()
    local function setup_rings(cr,pt)
        local str=''
        local value=0
        
        str=string.format('${%s %s}',pt['name'],pt['arg'])
        str=conky_parse(str)
        
        value=tonumber(str)
        pct=value/pt['max']
        
        draw_ring(cr,pct,pt)
    end
    
    -- Check that Conky has been running for at least 5s

    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 cr=cairo_create(cs)    
    
    local updates=conky_parse('${updates}')
    update_num=tonumber(updates)
    
    if update_num>5 then
        for i in pairs(settings_table) do
            setup_rings(cr,settings_table[i])
        end
    end
    
    draw_clock_hands(cr,clock_x,clock_y)
end

greetz -naik


*kaum macht man es richtig, funktioniert es sofort*

Offline

Help fund CrunchBang, donate to the project!

#6300 2013-10-05 17:06:43

arclance
#! Die Hard
Registered: 2012-03-29
Posts: 987

Re: Conky v1.9 Thread

^ Yes you can.
This section goes at the beginning where you setup global variables like "settings_table".

if tonumber(conky_parse('${updates}')) < 2 then --# don't reset these global variables when changes are made to the lua script
	deadbeefRunning = 0
elseif deadbeefRunning == nil then --# recreate variable if .conkyrc is edited (will break functionality if you do it while program is running though)
	deadbeefRunning = 0
end --# if tonumber(conky_parse('${updates}')) < 2 then

And this section goes in a new function that is called in the function called by "lua_draw_hook_pre" or in the function called by lua_draw_hook_pre".

local deadbeef_state = conky_parse("${if_running deadbeef-main}1${else}0${endif}")
if deadbeef_state == "1" then
	if deadbeefRunning < 5 then
		deadbeefRunning = deadbeefRunning + 1
		if deadbeefRunning == 5 then
			os.execute("python ~/deadbeefCovers_many.py &")
		end --# if deadbeefRunning == 5 then
	elseif deadbeefRunning >= 5 then
	--# display stuff here
	end --# if deadbeefRunning < 5 then
else
	if deadbeefRunning ~= 0 then
		os.execute('pkill -f ".*deadbeefCovers_many.py"')
		deadbeefRunning = 0
	end --# if deadbeefRunning ~= 0 then
end --# if deadbeef_state == 1 then

This is what it would look like put in the script you posted.

--[[
Clock Rings by londonali1010 (2009) Edited by jpope

This script draws percentage meters as rings, and also draws clock hands if you want! It is fully customisable; all options are described in the script. This script is based off a combination of my clock.lua script and my rings.lua script.

IMPORTANT: if you are using the 'cpu' function, it will cause a segmentation fault if it tries to draw a ring straight away. The if statement on line 145 uses a delay to make sure that this doesn't happen. It calculates the length of the delay by the number of updates since Conky started. Generally, a value of 5s is long enough, so if you update Conky every 1s, use update_num>5 in that if statement (the default). If you only update Conky every 2s, you should change it to update_num>3; conversely if you update Conky every 0.5s, you should use update_num>10. ALSO, if you change your Conky, is it best to use "killall conky; conky" to update it, otherwise the update_num will not be reset and you will get an error.

To call this script in Conky, use the following (assuming that you save this script to ~/scripts/rings.lua):
    lua_load ~/scripts/clock_rings.lua
    lua_draw_hook_pre clock_rings
    
Changelog:
+ v1.0 -- Original release (30.09.2009)
   v1.1p -- Jpope edit (05.10.2009)
]]

if tonumber(conky_parse('${updates}')) < 2 then --# don't reset these global variables when changes are made to the lua script
    mocRunning = 0
elseif mocRunning == nil then --# recreate variable if .conkyrc is edited (will break functionality if you do it while program is running though)
    mocRunning = 0
end --# if tonumber(conky_parse('${updates}')) < 2 then

settings_table = {
    {
        -- Edit this table to customise your rings.
        -- You can create more rings simply by adding more elements to settings_table.
        -- "name" is the type of stat to display; you can choose from 'cpu', 'memperc', 'fs_used_perc', 'battery_used_perc'.
        name='cpu',
        -- "arg" is the argument to the stat type, e.g. if in Conky you would write ${cpu cpu0}, 'cpu0' would be the argument. If you would not use an argument in the Conky variable, use ''.
        arg='cpu0',
        -- "max" is the maximum value of the ring. If the Conky variable outputs a percentage, use 100.
        max=100,
        -- "bg_colour" is the colour of the base ring.
        bg_colour=0x24242E,
        -- "bg_alpha" is the alpha value of the base ring.
        bg_alpha=0.0,
        -- "fg_colour" is the colour of the indicator part of the ring.
        fg_colour=0x24242E,
        -- "fg_alpha" is the alpha value of the indicator part of the ring.
        fg_alpha=0.6,
        -- "x" and "y" are the x and y coordinates of the centre of the ring, relative to the top left corner of the Conky window.
        x=401, y=87,
        -- "radius" is the radius of the ring.
        radius=27,
        -- "thickness" is the thickness of the ring, centred around the radius.
        thickness=12,
        -- "start_angle" is the starting angle of the ring, in degrees, clockwise from top. Value can be either positive or negative.
        start_angle=191,
        -- "end_angle" is the ending angle of the ring, in degrees, clockwise from top. Value can be either positive or negative, but must be larger than start_angle.
        end_angle=450
    },

    {
        name='memperc',
        arg='',
        max=100,
        bg_colour=0x24242E,
        bg_alpha=0.1,
        fg_colour=0x24242E,
        fg_alpha=0.6,
        x=401, y=87,
        radius=13,
        thickness=7,
        start_angle=155,
        end_angle=490
    },
    {
        name='downspeedf',
        arg='wlan0',
        max=1536,
        bg_colour=0x24242E,
        bg_alpha=0.1,
        fg_colour=0x24242E,
        fg_alpha=0.6,
        x=401, y=87,
        radius=52,
        thickness=11,
        start_angle=222,
        end_angle=580
    },
    {
        name='upspeedf',
        arg='wlan0',
        max=423,
        bg_colour=0x24242E,
        bg_alpha=0.1,
        fg_colour=0x24242E,
        fg_alpha=0.6,
        x=401, y=87,
        radius=42,
        thickness=6,
        start_angle=222,
        end_angle=580
    },

}

-- Use these settings to define the origin and extent of your clock.

clock_r=97

-- "clock_x" and "clock_y" are the coordinates of the centre of the clock, in pixels, from the top left of the Conky window.

clock_x=401
clock_y=87

show_seconds=true

require 'cairo'

function rgb_to_r_g_b(colour,alpha)
    return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end

function draw_ring(cr,t,pt)
    local w,h=conky_window.width,conky_window.height
    
    local xc,yc,ring_r,ring_w,sa,ea=pt['x'],pt['y'],pt['radius'],pt['thickness'],pt['start_angle'],pt['end_angle']
    local bgc, bga, fgc, fga=pt['bg_colour'], pt['bg_alpha'], pt['fg_colour'], pt['fg_alpha']

    local angle_0=sa*(2*math.pi/360)-math.pi/2
    local angle_f=ea*(2*math.pi/360)-math.pi/2
    local t_arc=t*(angle_f-angle_0)

    -- Draw background ring

    cairo_arc(cr,xc,yc,ring_r,angle_0,angle_f)
    cairo_set_source_rgba(cr,rgb_to_r_g_b(bgc,bga))
    cairo_set_line_width(cr,ring_w)
    cairo_stroke(cr)
    
    -- Draw indicator ring

    cairo_arc(cr,xc,yc,ring_r,angle_0,angle_0+t_arc)
    cairo_set_source_rgba(cr,rgb_to_r_g_b(fgc,fga))
    cairo_stroke(cr)        
end

function draw_clock_hands(cr,xc,yc)
    local secs,mins,hours,secs_arc,mins_arc,hours_arc
    local xh,yh,xm,ym,xs,ys
    
    secs=os.date("%S")    
    mins=os.date("%M")
    hours=os.date("%I")
        
    secs_arc=(2*math.pi/60)*secs
    mins_arc=(2*math.pi/60)*mins+secs_arc/60
    hours_arc=(2*math.pi/12)*hours+mins_arc/12
        
    -- Draw hour hand
    
    xh=xc+0.7*clock_r*math.sin(hours_arc)
    yh=yc-0.7*clock_r*math.cos(hours_arc)
    cairo_move_to(cr,xc,yc)
    cairo_line_to(cr,xh,yh)
    
    cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
    cairo_set_line_width(cr,5)
    cairo_set_source_rgba(cr,0.14,0.14,0.18,0.93)
    cairo_stroke(cr)
    
    -- Draw minute hand
    
    xm=xc+clock_r*math.sin(mins_arc)
    ym=yc-clock_r*math.cos(mins_arc)
    cairo_move_to(cr,xc,yc)
    cairo_line_to(cr,xm,ym)
    
    cairo_set_line_width(cr,3)
    cairo_stroke(cr)
    
    -- Draw seconds hand
    
    if show_seconds then
        xs=xc+clock_r*math.sin(secs_arc)
        ys=yc-clock_r*math.cos(secs_arc)
        cairo_move_to(cr,xc,yc)
        cairo_line_to(cr,xs,ys)
    
        cairo_set_line_width(cr,1)
        cairo_stroke(cr)
    end
end

function conky_clock_rings()
    local function setup_rings(cr,pt)
        local str=''
        local value=0
        
        str=string.format('${%s %s}',pt['name'],pt['arg'])
        str=conky_parse(str)
        
        value=tonumber(str)
        pct=value/pt['max']
        
        draw_ring(cr,pct,pt)
    end
    
    -- Check that Conky has been running for at least 5s

    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 cr=cairo_create(cs)    
    
    local updates=conky_parse('${updates}')
    update_num=tonumber(updates)
    
    if update_num>5 then
        for i in pairs(settings_table) do
            setup_rings(cr,settings_table[i])
        end
    end
    
    draw_clock_hands(cr,clock_x,clock_y)
    
    --# run another conky only when moc is running
    local moc_state = conky_parse("${if_running mocp}1${else}0${endif}")
    if moc_state == "1" then
        if mocRunning < 5 then
            mocRunning = mocRunning + 1
            if mocRunning == 5 then
                os.execute("conky -c .mocconkyrc &")
            end --# if mocRunning == 5 then
        elseif mocRunning >= 5 then
            local pass = nil --# display stuff here
        end --# if mocRunning < 5 then
    else
        if mocRunning ~= 0 then
            os.execute('pkill -f "conky -c .mocconkyrc"')
            mocRunning = 0
        end --# if mocRunning ~= 0 then
    end --# if moc_state == 1 then
    --# clear memory used by cairo
    cairo_destroy(cr)
    cairo_surface_destroy(cs)
end

You do need to change the ".mocconkyrc" in

os.execute("conky -c .mocconkyrc &")

and

os.execute('pkill -f "conky -c .mocconkyrc"')

to the full path to the ".mocconkyrc" file to make sure it works.


You script is also missing

cairo_destroy(cr)
cairo_surface_destroy(cs)

which causes the lua script to leak memory so I added those for you.

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat

Debian Logo