SEARCH

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

You are not logged in.

#4926 2013-03-09 10:15:56

Gordon
#! CrunchBanger
From: Blackpool, Lancashire, UK
Registered: 2012-05-22
Posts: 238

Re: The New Monster Conky Thread

Hi Folks

well I have got rid of the warning

WARNING: gnome-keyring:: couldn't connect to: /home/gordon/.cache/keyring-f9X7

by coping an existing basic conky that comes with the distro but won't mark this as solved as I have no idea what caused it.

still no luck with the lua script though  sad  but I will keep trying  smile


Cheers smile smile
Gordon
Using Janice Testing at present also sid and systemd and  VSIDO
A7N8X delux motherboard, 1 GB ram, AMD ATHLON XP 2800+ ( 2255 Mhz ), Nvidia Geforce PNY 62000 graphics card

Offline

Help fund CrunchBang, donate to the project!

#4927 2013-03-09 10:32:01

lionhead
#! Junkie
From: Dagobah / Germany
Registered: 2011-01-22
Posts: 449

Re: The New Monster Conky Thread

i have a little problem. i would like to display the status of the weather from this webpage:

if they show a specific image they display a special text, for example:

http://www.gco.org.au/weather/clearsky.gif               --->  shows the word: clear

this is the code from their wegpage:

<SCRIPT LANGUAGE="JavaScript">
var boltwood='1'
var icon
var bolttext 
if (boltwood == 0)
{icon = 'unknownsky.gif';bolttext='Unknown'}
else if (boltwood == 1)
{icon = 'clearsky.gif';bolttext='Clear'}
else if (boltwood == 2)
{icon = 'partcloudsky.gif';bolttext='Partly Cloudy'}
else if (boltwood == 3)
{icon = 'cloudsky.gif';bolttext='Very Cloudy'}
else if (boltwood == 4)
{icon = 'rainsky.gif';bolttext='Raining'}
document.write('<BR> <ALIGN=CENTER><IMG SRC=\"' + icon + '\" BORDER=0><BR>');
document.write('<ALIGN=CENTER><B><font color="yellow" face="Arial" size="2">' + bolttext + '</P></B>');
</SCRIPT>

Offline

#4928 2013-03-09 12:28:21

dk75
#! CrunchBanger
Registered: 2012-06-14
Posts: 244

Re: The New Monster Conky Thread

lionhead wrote:

i have a little problem. i would like to display the status of the weather from this webpage:

if they show a specific image they display a special text, for example:

http://www.gco.org.au/weather/clearsky.gif               --->  shows the word: clear

this is the code from their wegpage:

<SCRIPT LANGUAGE="JavaScript">
var boltwood='1'
var icon
var bolttext 
if (boltwood == 0)
{icon = 'unknownsky.gif';bolttext='Unknown'}
else if (boltwood == 1)
{icon = 'clearsky.gif';bolttext='Clear'}
else if (boltwood == 2)
{icon = 'partcloudsky.gif';bolttext='Partly Cloudy'}
else if (boltwood == 3)
{icon = 'cloudsky.gif';bolttext='Very Cloudy'}
else if (boltwood == 4)
{icon = 'rainsky.gif';bolttext='Raining'}
document.write('<BR> <ALIGN=CENTER><IMG SRC=\"' + icon + '\" BORDER=0><BR>');
document.write('<ALIGN=CENTER><B><font color="yellow" face="Arial" size="2">' + bolttext + '</P></B>');
</SCRIPT>

So, it's that "boltwood" variable is changing, rest is static.
Then you can hardwire your own table with both icon and text depending on this variable and search for this variable value only:

 --[[
 Sunrise and Sunset time from http://www.gco.org.au/weather/weather.html page
 
 usage:
 	default interval=3600 of conky updates (1h if conky_updates=1)
 		lua_load $HOME/path-to-script/sunriseset.lua
 		lua_draw_hook_pre conky_sunriseset
 
 	set custom interval=4000 of conky updates (1h 10m if conky_updates=1)
 		lua_load $HOME/path-to-script/sunriseset.lua
 		lua_draw_hook_pre conky_sunriseset 4000
 --]]
 
 local file_uri, file = "http://www.gco.org.au/weather/weather.html", "/tmp/weather.html"
 local def_sunrise, def_sunset, startup, def_interval, fTab = "06:00:00", "18:00:00", false, 3600, {}
 local sunrise, sunset, weatherNo = nil, nil, 0
 local weatherTab={ { icon="unknow.gif", text="Unknow" }, { icon="clearsky.gif", text="Clear" }, { icon="partcloudsky.gif", text="Partly Cloudy" }, { icon="cloudsky.gif", text="Very Cloudy" }, { icon="rainsky.gif", text="Raining" } }
 
 local function fetch_weather(updates, interval)
 	if startup then if (updates % interval) ~= 0 then return "100" end else startup=true end
 	os.execute("wget -q "..file_uri.." -O "..file.." &")
 end
 
 local function fetch_file(fw, updates, interval)
 	if ( fw ~= "100" and fTab[1] ~= nil ) or (updates % interval) ~= 0 then return "" end
 	i=0
 	local f=io.open(file, 'r')
 	if f then io.close(f) else return "200" end
 	for line in io.lines(file) do
 		i=i+1
 		fTab[i]=line
 	end
 end
 
 local function parse_table(ff)
 	if ff == "200" or fTab[1] == nil then return "300" end
 	local t, i, k, v = {}, 0, nil
 	for k, v in pairs(fTab) do
 		if string.find(v, ">Sunrise") then
 			for k in string.gmatch(v, "%d%d:%d%d:%d%d") do i=i+1; t[i]=k end
 		end
 		if string.find(v, "var boltwood") then t[0]=string.gsub(v, ".*(%d).*", "%1") end
 	end
 	if not t[0] or tonumber(t[0]) > 4 or tonumber(t[0]) < 0 then t[0]="0" end
 	if t[1] and t[2] then return "", t[1], t[2], t[0] else return "300", nil, nil, t[0] end
 end
 
 function conky_sunriseset(interval)
 	if conky_window == nil then return "0" end
 	local updates=tonumber(conky_parse('${updates}'))
 	if updates <= 5 then return "0" end
 	if not interval or tonumber(interval) < 3600 then interval=def_interval else interval=tonumber(interval) end
 	
 	fw=fetch_weather(updates, interval)
 	ff=fetch_file(fw, updates, 15)
 	pt, sunrise, sunset, weatherNo = parse_table(ff)
 	if not sunrise or pt == "300" then sunrise=def_sunrise end
 	if not sunset or pt == "300" then sunset=def_sunset end
 	if not weatherNo then weatherNo=1 else weatherNo=tonumber(weatherNo)+1 end
 	if fw ~= "100" then fTab={} end
 
 	print("Sunrise = "..sunrise,"Sunset = "..sunset, "Icon = "..weatherTab[weatherNo].icon, "Text = "..weatherTab[weatherNo].text)
 end

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

#4929 2013-03-09 13:10:15

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 9,901
Website

Re: The New Monster Conky Thread

Gordon wrote:

still no luck with the lua script though  sad  but I will keep trying  smile

Just a thought - maybe you've picked up on this already:

-- ####################################
ptint ('hello world')
-- ####################################

ptint = print <<-- I do the same all the time

Last edited by Sector11 (2013-03-09 13:10:57)

Offline

#4930 2013-03-09 14:26:18

lionhead
#! Junkie
From: Dagobah / Germany
Registered: 2011-01-22
Posts: 449

Re: The New Monster Conky Thread

lionhead wrote:

this is the code from their wegpage:

@Sector11

you are not alone smile

@dk75

thanks for your help. this is a really good-looking webcam. look at it wink

Last edited by lionhead (2013-03-09 14:28:23)

Offline

#4931 2013-03-09 18:53:57

ansem_of_nexus
#! CrunchBanger
Registered: 2012-09-19
Posts: 199

Re: The New Monster Conky Thread

I figure since I already posted the code when I was looking for help, I should just show what my new lua project looks like so far.

so here is your sneak preview.
2013_03_09_1362854625_1600x900_scrot.jpg

I think once I have finished making it, that I want to make it into an interactive conky... maybe, we shall see.


You can find my work here

Make everything ok button

Offline

#4932 2013-03-09 18:55:41

VastOne
#! Ranger
From: #! Fringe Division
Registered: 2011-04-26
Posts: 10,163
Website

Re: The New Monster Conky Thread

Very nice ansem_of_nexus!

Reminds me of an xBox controller...


VSIDO | SolusOS

Words That Build Or Destroy

Offline

#4933 2013-03-09 21:09:40

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

Re: The New Monster Conky Thread

Gordon wrote:

I get the following

WARNING: gnome-keyring:: couldn't connect to: /home/gordon/.cache/keyring-f9X7tR/pkcs11: No such file or directory

Where do I find the keyring mentioned or do I just go to the .cashe and make it ?

This is only a warning message and won't cause any problems if you ignore it.

You have to run

/usr/bin/gnome-keyring-daemon --start --components=pkcs11

with your window managers "run command at login" function to get rid of that warning.
There are more options that may need to be added to the "--components=" section (as a comma separated list) if you use programs that need them but conky wants the "pkcs11" option.

Offline

#4934 2013-03-10 11:16:45

Gordon
#! CrunchBanger
From: Blackpool, Lancashire, UK
Registered: 2012-05-22
Posts: 238

Re: The New Monster Conky Thread

Hi Folks,

Thanks for your help

@ Sector11,

Thanks for that but just for once I had actuall spotted that typo

@ arclance,

Thanks for the info. Not sure that I understand what you are saying when you say windows manager. Do you mean slim and if so how do I add that command or is it in oopenbox that it has to go ?


Cheers smile smile
Gordon
Using Janice Testing at present also sid and systemd and  VSIDO
A7N8X delux motherboard, 1 GB ram, AMD ATHLON XP 2800+ ( 2255 Mhz ), Nvidia Geforce PNY 62000 graphics card

Offline

#4935 2013-03-10 14:08:29

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 9,901
Website

Re: The New Monster Conky Thread

@ Gordon ...

OpenBox is the Window Manager of choice in #!

Probably need to put that command in ~/.config/openbox/autostart

Personally, I just deleted the keyring, I don't need it.

Last edited by Sector11 (2013-03-10 14:09:20)

Offline

#4936 2013-03-10 14:49:39

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

Re: The New Monster Conky Thread

^ I believe that is correct for openbox but it needs to be

/usr/bin/gnome-keyring-daemon --start --components=pkcs11 &

if your window manager uses a startup script.

Offline

#4937 2013-03-10 15:54:10

Gordon
#! CrunchBanger
From: Blackpool, Lancashire, UK
Registered: 2012-05-22
Posts: 238

Re: The New Monster Conky Thread

Hi arclance,

Thanks for the quick reply.

I have just opened openbox autostart and that line is already inserted, still not to worry as it causes no problems I'll just ignore it in future.

Next question if I can tag it on Iget this

Conky: llua_load: /home/gordon/lua/GordonsScripts/hello:5: '=' expected near 'yes'

I have nothing in the script that has a yes near it what is that about please ?


Cheers smile smile
Gordon
Using Janice Testing at present also sid and systemd and  VSIDO
A7N8X delux motherboard, 1 GB ram, AMD ATHLON XP 2800+ ( 2255 Mhz ), Nvidia Geforce PNY 62000 graphics card

Offline

#4938 2013-03-10 22:56:33

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

Re: The New Monster Conky Thread

Gordon wrote:

Hi arclance,

Thanks for the quick reply.

I have just opened openbox autostart and that line is already inserted, still not to worry as it causes no problems I'll just ignore it in future.

Post your whole "~/.config/openbox/autostart" file to see if there is anything that could cause it not to work in there.

Gordon wrote:

Next question if I can tag it on Iget this

Conky: llua_load: /home/gordon/lua/GordonsScripts/hello:5: '=' expected near 'yes'

I have nothing in the script that has a yes near it what is that about please ?

I would need to see your script as it is now to help you with that.

Offline

#4939 2013-03-10 23:27:18

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

Re: The New Monster Conky Thread

Hey! i used the wallbydesk-script (thanks to ragamatrix) and non-sticky conkys to build kind of an     command center on first desktop:

3wall_thumb_zpsb835e890.png

yes, for me there is a slight delay when switching desktops but only in combination with conky, which means the bg of the conkys changes about half a sec later than the rest, but this is not much of a problem and the mem-usage in idle increased by 2mb.
next step is to make the bottom-right conky clicky (i d love to only show the fs_bars on click) and to place a quarter ring launcher in the bottom left.

@ansem_of_nexus: love your new projekt!

@ all: thanks for all the knowladge and inspiration!

greetz -naik

Last edited by Naik (2013-03-10 23:31:35)


*kaum macht man es richtig, funktioniert es sofort* | my blog

Offline

#4940 2013-03-11 01:50:03

PackRat
#! Die Hard
From: USA
Registered: 2011-03-03
Posts: 1,097

Re: The New Monster Conky Thread

@naik - nice one.

and:

@ all: thanks for all the knowladge and inspiration!

ditto that.


"It does not require many words to speak the truth." - Chief Joseph, Nez Perce tribe

Offline

#4941 2013-03-11 21:14:27

Gordon
#! CrunchBanger
From: Blackpool, Lancashire, UK
Registered: 2012-05-22
Posts: 238

Re: The New Monster Conky Thread

Hi arclance,

Sorry about the long delays in posting but I am not around a lot at the moment, rather busy with other things.  neutral

Here is my autostart menu, I have done nothing to this at all.

(\
nitrogen --restore && \
cb-compositor --start && \
sleep 2s && \
conky -q && \
tint2 \
) &

## Enable hot corners
cb-hotcorners --daemon &

## FIXME: volumeicons requires an extra-long sleep,
## else it fails to start?!
(sleep 30s && volumeicon) &

## Enable power management
xfce4-power-manager &

## Start Thunar Daemon
thunar --daemon &

## Detect and configure touchpad. See 'man synclient' for more info.
if egrep -iq 'touchpad' /proc/bus/input/devices; then
    synclient VertEdgeScroll=1 &
    synclient TapButton1=1 &
fi

## Start xscreensaver
xscreensaver -no-splash &

## Start Clipboard manager
(sleep 3s && parcellite) &

## The following command runs hacks and fixes for #! LiveCD sessions.
## Safe to delete after installation.
cb-cowpowers &

## cb-welcome - post-installation script, will not run in a live session and
## only runs once. Safe to remove.
(sleep 10s && cb-welcome --firstrun) &

## cb-fortune - have Statler say a little adage
#(sleep 120s && cb-fortune) &

## GNOME PolicyKit and Keyring
(\
/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1 && \
/usr/bin/gnome-keyring-daemon --start --components=ssh && \
/usr/bin/gnome-keyring-daemon --start --components=secrets && \
/usr/bin/gnome-keyring-daemon --start --components=pkcs11 && \
/usr/bin/gnome-keyring-daemon --start --components=gpg \
) &

and here is my lua script

-- this is a lua script for use in conky

require 'cairo'

background yes
update_interval 1

cpu_avg_samples 2
net_avg_samples 2
temperature_unit celsius

double_buffer yes
no_buffers yes
text_buffer_size 2048

gap_x 100
gap_y 100
minimum_size 260 700
-- maximum_width 190
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
border_inner_margin 0
border_outer_margin 0
alignment top left

draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no

override_utf8_locale yes
use_xft yes
xftfont Comic Sans MS:size=8
xftalpha 0.5
uppercase no

default_color FFFFFF
color1 888888
color2 AAAAAA
color3 DDDDDD
color4 CC3333
color5 F09000

-- start of main function

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 cr=cairo_create(cs)

	if updates(conky_parse('${updates}'))>5 then
		-- ####################################
		text1='hello world'
        print (text1)
        -- ####################################
	end  --if updates

	cairo_destroy(cr)
	cairo_surface_destroy(cs)
	cr = nil
	
end  -- main function

I have tried it with just "print 'hello world'" as well as the way you see it now with the same result


Cheers smile smile
Gordon
Using Janice Testing at present also sid and systemd and  VSIDO
A7N8X delux motherboard, 1 GB ram, AMD ATHLON XP 2800+ ( 2255 Mhz ), Nvidia Geforce PNY 62000 graphics card

Offline

#4942 2013-03-12 01:06:41

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

Re: The New Monster Conky Thread

Gordon wrote:

Hi arclance,

Sorry about the long delays in posting but I am not around a lot at the moment, rather busy with other things.  neutral

Here is my autostart menu, I have done nothing to this at all.

## GNOME PolicyKit and Keyring
(\
/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1 && \
/usr/bin/gnome-keyring-daemon --start --components=ssh && \
/usr/bin/gnome-keyring-daemon --start --components=secrets && \
/usr/bin/gnome-keyring-daemon --start --components=pkcs11 && \
/usr/bin/gnome-keyring-daemon --start --components=gpg \
) &

This is wrong you can't call each component argument separately like that.
I think this was a error in a old version of #! when things were being tried to get rid of the "gnome-keyring" warning.
The correct command would be like this.

## GNOME PolicyKit and Keyring
(\
/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1 && \
/usr/bin/gnome-keyring-daemon --start --components=ssh,secrets,pkcs11,gpg \
) &

I don't know if you need the

/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1 && \

line or not in Openbox but I don't need it with Fluxbox.


All of this belongs in your .conkyrc not your Lua script, they are separate files.

Gordon wrote:
background yes
update_interval 1

cpu_avg_samples 2
net_avg_samples 2
temperature_unit celsius

double_buffer yes
no_buffers yes
text_buffer_size 2048

gap_x 100
gap_y 100
minimum_size 260 700
-- maximum_width 190
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
border_inner_margin 0
border_outer_margin 0
alignment top left

draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no

override_utf8_locale yes
use_xft yes
xftfont Comic Sans MS:size=8
xftalpha 0.5
uppercase no

default_color FFFFFF
color1 888888
color2 AAAAAA
color3 DDDDDD
color4 CC3333
color5 F09000

You load the lua script with "lua_load" in your .conkyrc and run it with "lua_draw_hook_pre" or "lua_draw_hook_post" most of the time.
There are other commands to run a script with but they are for more specialized scripts than the one you are working on.
You can find the documentation on those settings here.

Offline

#4943 2013-03-12 18:06:34

Gordon
#! CrunchBanger
From: Blackpool, Lancashire, UK
Registered: 2012-05-22
Posts: 238

Re: The New Monster Conky Thread

Hi arclance

Thanks for that. I will try all that out later, poss tomorrow, going out now for the night with the ball and chain for a meal etc.
will let you know how it all goes later on  smile


Cheers smile smile
Gordon
Using Janice Testing at present also sid and systemd and  VSIDO
A7N8X delux motherboard, 1 GB ram, AMD ATHLON XP 2800+ ( 2255 Mhz ), Nvidia Geforce PNY 62000 graphics card

Offline

#4944 2013-03-13 18:39:37

Gordon
#! CrunchBanger
From: Blackpool, Lancashire, UK
Registered: 2012-05-22
Posts: 238

Re: The New Monster Conky Thread

Hi arclance,

Well I have got there in the end. It is now working. I managed to find a couple of mistakes that I had made

The first one was I had pointed lua_draw_hook_pre to the wrong place / item ( main_box instead of conky_main ) in .conkyrc

The second one was a complete mess up of ' if updates ' which I had jumbled up with ' local updates '. All put ito one line of nothingness

Anyway thanks for all your time and efforts to sort me out without which I doubt that I would have got anywhere at all  big_smile

THANK YOU


Cheers smile smile
Gordon
Using Janice Testing at present also sid and systemd and  VSIDO
A7N8X delux motherboard, 1 GB ram, AMD ATHLON XP 2800+ ( 2255 Mhz ), Nvidia Geforce PNY 62000 graphics card

Offline

#4945 2013-03-14 10:57:46

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

Re: The New Monster Conky Thread

as the launcher wont launch and i am short in time i layed the control-center-thing aside for now and switched back to usual:

screenFetch-2013-03-14_11-30-19_thumb_zps35ac4851.png



thanks to Nerdchotics for submitting the foundation for the wall.

greetz -naik

Last edited by Naik (2013-03-15 10:33:35)


*kaum macht man es richtig, funktioniert es sofort* | my blog

Offline

#4946 2013-03-14 11:22:04

lionhead
#! Junkie
From: Dagobah / Germany
Registered: 2011-01-22
Posts: 449

Re: The New Monster Conky Thread

i made a function that displays several variables in conky and adds automatically custom endings.

the most variables that shows the unit 'percent' have the word 'perc' or 'percent within the name of the variable, for example

memperc

the variable 'cpu' also displays the unit % the problem is that this word doesn't use the word 'perc'. but there are also other variables that contain the word 'cpu' within, for example cpugauge

when i use this then it wont work

string.find(conky_variable, "cpu")~= nil

do u have an idea how i fix this?

Offline

#4947 2013-03-14 16:15:33

ansem_of_nexus
#! CrunchBanger
Registered: 2012-09-19
Posts: 199

Re: The New Monster Conky Thread

happy pi day

So I was wondering if anyone had tested out the Conky GUI editor, to find out if it is any good?
picture
link


You can find my work here

Make everything ok button

Offline

#4948 2013-03-14 22:12:45

dk75
#! CrunchBanger
Registered: 2012-06-14
Posts: 244

Re: The New Monster Conky Thread

lionhead wrote:

i made a function that displays several variables in conky and adds automatically custom endings.

the most variables that shows the unit 'percent' have the word 'perc' or 'percent within the name of the variable, for example

memperc

the variable 'cpu' also displays the unit % the problem is that this word doesn't use the word 'perc'. but there are also other variables that contain the word 'cpu' within, for example cpugauge

when i use this then it wont work

string.find(conky_variable, "cpu")~= nil

do u have an idea how i fix this?

dunno how you use it but this snippet works for me in LUA terminal:

test="acpugauge"; if string.find(test, "cpu") then print("it is") else print("it is not") end

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

#4949 2013-03-15 02:06:12

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

Re: The New Monster Conky Thread

@ansem_of_nexus:
I tryed to, but recently i can`t get it to work...

edit: as for my last post: is there by any means a chance to wrap the output of the conky to the surface of the tablet? maybe with lua?

Last edited by Naik (2013-03-15 10:35:38)


*kaum macht man es richtig, funktioniert es sofort* | my blog

Offline

Help fund CrunchBang, donate to the project!

#4950 2013-03-15 17:22:44

lionhead
#! Junkie
From: Dagobah / Germany
Registered: 2011-01-22
Posts: 449

Re: The New Monster Conky Thread

i hope that this works for all conky-variables:

function conky(cd)
-----------------------------
local conky_order=nil
local variable=nil
local device=nil
local del=nil
local cs = nil
local ms = nil
-----------------------------
variable=cd.variable
device=(cd.device or '')
del=(cd.del or '.')
-----------------------------
conky_order=conky_parse("${"..variable..' '..device.."}")

local value = conky_order:gsub(" ","") 

	---- short_units no ------------------------
	if ((string.find(value, "iB") == nil) and (string.find(value, "B") ~= nil)) then
		ms=(value:gsub("B",""))..' byte'	
	elseif string.find(value, 'KiB') ~= nil then
		ms=(value:gsub("KiB",""))..' kb'
	elseif string.find(value, 'MiB') ~= nil then
		ms=(value:gsub("MiB",""))..' mb'
	elseif string.find(value, 'GiB') ~= nil then
		ms=(value:gsub("GiB",""))..' gb'
	elseif string.find(value, "TiB") ~= nil then
		ms=(value:gsub("TiB","")).." tb"	
	elseif ((string.find(variable, "perc") ~= nil) or (string.find(variable, "percent") ~= nil)) then
		ms=conky_order.." %"
	elseif ((string.find(variable,"freq") ~= nil) and (string.find(variable,"_g") == nil)) then
		ms=conky_order.." Mhz"
	elseif ((string.find(variable,"downspeedf") ~= nil) or (string.find(variable,"upspeedf") ~= nil)) then
		ms=value:gsub(" ","").." kb/s"
	elseif string.find(variable,"time") ~= nil then
		ms=conky_order:gsub(" ","")
	elseif string.find(variable,"cpu") ~= nil then
		ms=conky_order.." %"
	---- short_units yes -----------------------
	elseif ((string.find(value, "iB") == nil) and (string.find(value, "B") ~= nil)) then
		ms=(value:gsub("B",""))..' byte'
	elseif string.find(value, "K") ~= nil then
		ms=(value:gsub("K",""))..' kb'
	elseif string.find(value, "M") ~= nil then
		ms=(value:gsub("M",""))..' mb'
	elseif string.find(value, "G") ~= nil then
		ms=(value:gsub("G",""))..' gb'
	elseif string.find(value, "T") ~= nil then
		ms=(value:gsub("T",""))..' tb'
	------------------------------------------------------
	else ms=value:gsub(" ","") end
	------------------------------------------------------
	cs=string.gsub(tostring(ms),"%.",del)
	
	return cs
end -- of function

if u see something to optimize then please pm me smile

edit: i still have problems when this code is behind the first line:

	elseif ((string.find(variable,"upspeed") ~= nil) and (string.find(variable,"f") == nil)) then
		ms=value:gsub(" ","")

Last edited by lionhead (2013-03-15 20:38:24)

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.

Debian Logo