SEARCH

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

You are not logged in.

#1651 2011-06-21 20:43:11

kruijf
#! Member
From: Soest, Netherlands
Registered: 2011-06-12
Posts: 76
Website

Re: Conky Help

i think i put it in the wrong place becaus sleep 30 && conky wont work the conky stays away.
I put in startup application but that dont work, and in the .conkyrc maby the wrong place.


Acer Aspire 5749: Debian Testing

Offline

Help fund CrunchBang, donate to the project!

#1652 2011-06-21 21:51:42

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,041
Website

Re: Conky Help

@ mrpeachy

The...

lua_load ~/path to/time_bar.lua
TEXT
${lua draw_boxes()}

doesn't work...

thmb_lines.jpg

conky

# To use #! in a conky use: ${exec echo '#!'}

 background no
 own_window yes
 own_window_type override
 own_window_transparent yes
# own_window_colour DarkBlue
 own_window_hints skip_taskbar,skip_pager
 own_window_title OB_TimeBar
 own_window_class OB_TimeBar

 use_xft yes
 xftalpha 1
 xftfont DejaVu Sans Mono:bold:size=8

 override_utf8_locale yes
 total_run_times 0

 double_buffer yes
 draw_shades no
 draw_outline no
 draw_borders no
 draw_graph_borders no

 short_units yes
 pad_percents 2
 top_name_width 9

 no_buffers yes
 uppercase no

 cpu_avg_samples 1
 net_avg_samples 1
 use_spacer right

# Colors
 default_color DCDCDC #Gainsboro
 color0 FFFFF0 #Ivory
 color1 FFA07A #LightSalmon
 color2 7095BB #Mark's Blue
 color3 C6FF8E #Light Green #FFF00 #Chartreuse
 color4 778899 #LightSlateGrey
 color5 FFDEAD #NavajoWhite
 color6 00BFFF #DeepSkyBlue #000080 #Navy
 color7 48D1CC #MediumTurquoise
 color8 FFFF00 #Yellow
 color9 FF0000 #Red


 alignment tl
 update_interval 1
 gap_x 192           ### left &right
 gap_y 55           ### up & down

# text_buffer_size 2048
 minimum_size 900 0
 maximum_width 900

 border_outer_margin 2
 border_inner_margin 0

 imlib_cache_size 0

 lua_load ~/Conky/LUA/time_bar.lua
# lua_draw_hook_post draw_boxes
# lua_draw_hook_pre draw_boxes

# TEXT
# ${lua draw_boxes()}HH:blah-blah

TEXT
${lua draw_boxes()}HH: ${time %H}${goto 96}|${goto 146}|${goto 196}|${goto 247}|${goto 297}|${goto 347}|${goto 397}|${goto 455}DD: ${time %d}${goto 586}|${goto 677}|${goto 768}|${goto 859}|
MM: ${time %M}${goto 113}|${goto 180}|${goto 247}|${goto 313}|${goto 380}|${goto 455}MM: ${time %m}${goto 596}|${goto 696}|${goto 797}|
SS: ${time %S}${goto 113}|${goto 180}|${goto 247}|${goto 313}|${goto 380}|${goto 455}YY: ${time %y}${goto 536}|${goto 576}|${goto 617}|${goto 656}|${goto 697}|${goto 737}|${goto 777}|${goto 817}|${goto 857}|

time_bar.lua

--[[Time Bar
19 June 2011 Original by: mrpeachy
20 June 2011 by: Sector11
 - added HOURS, MINUTES & SECONDS
 - days changed to 31 for all months - easier to scale.
21 June 2011
 - with mrp's help added the background

call as follows in conky
lua_load ~/path to/time_bar.lua
lua_draw_hook_pre draw_boxes

]]
require 'cairo'
function rgb_to_r_g_b(color, alpha)
return ((color / 0x10000) % 0x100) / 255., ((color / 0x100) % 0x100) / 255., (color % 0x100) / 255., alpha
end

function conky_draw_boxes()
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)
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
if updates>5 then
-- #############################################################################
-- CONKY BACKGROUND SETUP -- make sure this comes first --
settings={
corner_r=20,             -- corner radius
bg_color=0x000000,       -- set color 
bg_alpha=0.4,            -- set alpha = mrpeachy's test  :D
bg_height=-0,            -- negative number reduces height of bg
w=conky_window.width,
h=conky_window.height,
};background(settings)
-- end background setup --
-- #############################################################################
-- USER SETTINGS -- USER SETTINGS -- USER SETTINGS -- USER SETTINGS -- 
----------------------------
-- day box settings
----------------------------
local day_start_x=500           -- left &right
local day_start_y=3             -- up & down
local day_height=12             -- height of boxes
local day_total_length=400      -- total length of all boxes and gaps
local day_bg_color=0xFFFFFF     -- background color of box
local day_fg_color=0xE0FFFF     -- foreground color
local day_gap=2                 -- if display shows no divisions this is probably set too high
----------------------------
--month box settings
----------------------------
local month_start_x=500         -- left &right
local month_start_y=16          -- up & down
local month_height=12           -- height of boxes
local month_total_length=400    -- total length of all boxes and gaps
local month_bg_color=0xFFFFFF   -- background color of box
local month_fg_color=0xE0FFFF   -- foreground color
local month_gap=2               -- if display shows no divisions this is probably set too high
----------------------------
--year box settings
----------------------------
local year_start_x=500          -- left &right
local year_start_y=29           -- up & down
local year_height=12            -- height of boxes
local year_total_length=400     -- total length of all boxes and gaps
local year_bg_color=0xFFFFFF    -- background color of box
local year_fg_color=0xE0FFFF    -- foreground color
local year_gap=2                -- if display shows no divisions this is probably set too high
----------------------------
--hour box settings
----------------------------
local hour_start_x=50           -- left &right
local hour_start_y=3            -- up & down
local hour_height=12            -- height of boxes
local hour_total_length=400     -- total length of all boxes and gaps
local hour_bg_color=0xFFFFFF    -- background color of box
local hour_fg_color=0xE0FFFF    -- foreground color
local hour_gap=2                -- if display shows no divisions this is probably set too high
----------------------------
--minute box settings
----------------------------
local minute_start_x=50         -- left &right
local minute_start_y=16         -- up & down
local minute_height=12          -- height of boxes
local minute_total_length=400   -- total length of all boxes and gaps
local minute_bg_color=0xFFFFFF  -- background color of box
local minute_fg_color=0xE0FFFF  -- foreground color
local minute_gap=2              -- if display shows no divisions this is probably set too high
----------------------------
--second box settings
----------------------------
local second_start_x=50         -- left &right
local second_start_y=29         -- up & down
local second_height=12          -- height of boxes
local second_total_length=400   -- total length of all boxes and gaps
local second_bg_color=0xFFFFFF  -- background color of box
local second_fg_color=0xE0FFFF  -- foreground color
local second_gap=2              -- if display shows no divisions this is probably set too high
----------------------------
-- END USER SETTINGS -- END USER SETTINGS -- END USER SETTINGS --
--##############################################################################
-- STATIC SETTINGS -- STATIC SETTINGS -- STATIC SETTINGS -- STATIC SETTINGS -- 
----------------------------
-- YEAR Settings
----------------------------
local year_bits=100
local year2num=tonumber(os.date("%y"))
-------------------------------------------------
local box_total=year_total_length-(year_gap*(year_bits-1))
local box_len=box_total/year_bits
cairo_set_source_rgba(cr,rgb_to_r_g_b(year_bg_color,0.2))
for i=1,year_bits do
if i<=tonumber(year2num) then
cairo_set_source_rgba(cr,rgb_to_r_g_b(year_fg_color,0.7))
else
cairo_set_source_rgba(cr,rgb_to_r_g_b(year_bg_color,0.2))
end
cairo_rectangle(cr,year_start_x+(box_len*(i-1))+(year_gap*(i-1)),year_start_y, box_len, year_height)
cairo_fill (cr)
end
----------------------------
-- Month Settings
----------------------------
local month_bits=12
local month2num=tonumber(os.date("%m"))
-------------------------------------------------
local box_total=month_total_length-(month_gap*(month_bits-1))
local box_len=box_total/month_bits
cairo_set_source_rgba(cr,rgb_to_r_g_b(month_bg_color,0.2))
for i=1,month_bits do
if i<=tonumber(month2num) then
cairo_set_source_rgba(cr,rgb_to_r_g_b(month_fg_color,0.3))
else
cairo_set_source_rgba(cr,rgb_to_r_g_b(month_bg_color,0.2))
end
cairo_rectangle(cr,month_start_x+(box_len*(i-1))+(month_gap*(i-1)),month_start_y, box_len, month_height)
cairo_fill (cr)
end
----------------------------
-- Day Settings
----------------------------
local day_bits=31
local day2num=tonumber(os.date("%d"))
-------------------------------------------------
local box_total=day_total_length-(day_gap*(day_bits-1))
local box_len=box_total/day_bits
cairo_set_source_rgba(cr,rgb_to_r_g_b(day_bg_color,0.2))
for i=1,day_bits do
if i<=tonumber(day2num) then
cairo_set_source_rgba(cr,rgb_to_r_g_b(day_fg_color,0.7))
else
cairo_set_source_rgba(cr,rgb_to_r_g_b(day_bg_color,0.2))
end
cairo_rectangle(cr,day_start_x+(box_len*(i-1))+(day_gap*(i-1)),day_start_y, box_len, day_height)
cairo_fill (cr)
end
----------------------------
-- Hour Settings
----------------------------
local hour_bits=24
local hour2num=tonumber(os.date("%H"))
-------------------------------------------------
local box_total=hour_total_length-(hour_gap*(hour_bits-1))
local box_len=box_total/hour_bits
cairo_set_source_rgba(cr,rgb_to_r_g_b(hour_bg_color,0.2))
for i=1,hour_bits do
if i<=tonumber(hour2num) then
cairo_set_source_rgba(cr,rgb_to_r_g_b(hour_fg_color,0.7))
else
cairo_set_source_rgba(cr,rgb_to_r_g_b(hour_bg_color,0.2))
end
cairo_rectangle(cr,hour_start_x+(box_len*(i-1))+(hour_gap*(i-1)),hour_start_y, box_len, hour_height)
cairo_fill (cr)
end
----------------------------
-- Minute Settings
----------------------------
local minute_bits=60
local minute2num=tonumber(os.date("%M"))
-------------------------------------------------
local box_total=minute_total_length-(minute_gap*(minute_bits-1))
local box_len=box_total/minute_bits
cairo_set_source_rgba(cr,rgb_to_r_g_b(minute_bg_color,0.2))
for i=1,minute_bits do
if i<=tonumber(minute2num) then
cairo_set_source_rgba(cr,rgb_to_r_g_b(minute_fg_color,0.5))
else
cairo_set_source_rgba(cr,rgb_to_r_g_b(minute_bg_color,0.2))
end
cairo_rectangle(cr,minute_start_x+(box_len*(i-1))+(minute_gap*(i-1)),minute_start_y, box_len, minute_height)
cairo_fill (cr)
end
----------------------------
-- Second Settings
----------------------------
local second_bits=60
local second2num=tonumber(os.date("%S"))
-------------------------------------------------
local box_total=second_total_length-(second_gap*(second_bits-1))
local box_len=box_total/second_bits
cairo_set_source_rgba(cr,rgb_to_r_g_b(second_bg_color,0.2))
for i=1,second_bits do
if i<=tonumber(second2num) then
cairo_set_source_rgba(cr,rgb_to_r_g_b(second_fg_color,0.7))
else
cairo_set_source_rgba(cr,rgb_to_r_g_b(second_bg_color,0.2))
end
cairo_rectangle(cr,second_start_x+(box_len*(i-1))+(second_gap*(i-1)),second_start_y, box_len, second_height)
cairo_fill (cr)
end
-------------------------------------------------
-- #############################################################################
end -- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end -- end main function
-- #############################################################################
function background(t)
local corner_r=t.corner_r
local br,bg,bb,ba=rgb_to_r_g_b(t.bg_color,t.bg_alpha)
local v=t.bg_height
local h=t.h
local w=t.w
cairo_move_to(cr,corner_r,0)
cairo_line_to(cr,w-corner_r,0)
cairo_curve_to(cr,w,0,w,0,w,corner_r)
cairo_line_to(cr,w,h+v-corner_r)
cairo_curve_to(cr,w,h+v,w,h+v,w-corner_r,h+v)
cairo_line_to(cr,corner_r,h+v)
cairo_curve_to(cr,0,h+v,0,h+v,0,h+v-corner_r)
cairo_line_to(cr,0,corner_r)
cairo_curve_to(cr,0,0,0,0,corner_r,0)
cairo_close_path(cr)
cairo_set_source_rgba(cr,br,bg,bb,ba)
cairo_fill(cr)
end--function background

Last edited by Sector11 (2011-06-21 21:52:33)


#! Conky = 13 Threads & the Conky Archives | Conky PitStop | OHCG'er
#! Forum Moderator   |   StartPage -  protect your privacy   |   BBQ Linux

Online

#1653 2011-06-21 21:51:59

yuh_learn
#! CrunchBanger
Registered: 2009-09-02
Posts: 118

Re: Conky Help

I made this bash script for Conky that gets the window title of Iceweasel and prints it. It looks like this:

#!/bin/bash

if [ -z "$(pgrep firefox-bin)" ]; then
    echo ""
else
    id=$(xlsclients -al|grep "Command:  firefox-bin" -A1 -B4|head -n1|cut -d ' ' -f 2|tr -d ':')
    pid=$(xprop -id "$id"|awk '/_NET_WM_PID/ {print $3}')
    title=$(wmctrl -lp|grep "$pid"|awk -F 'steamroller' '{print $2}')
    title=${title%%' - Iceweasel'}

    echo "  ~  ${title:1:90}"
fi

Any suggestions for how I could do it better?

Offline

#1654 2011-06-21 21:57:46

mrpeachy
20% cooler
From: The Everfree Forest
Registered: 2009-11-08
Posts: 3,460

Re: Conky Help

@ sector11

try this instead

${lua draw_boxes}

i dont think it needs the brackets

Offline

#1655 2011-06-21 22:08:19

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,041
Website

Re: Conky Help

mrpeachy wrote:

@ sector11

try this instead

${lua draw_boxes}

i dont think it needs the brackets

Done ... it doesn't ... doesn't need the () that is ... it works.  cool
Thanks, now to play with something else.

Last edited by Sector11 (2011-06-21 22:12:18)


#! Conky = 13 Threads & the Conky Archives | Conky PitStop | OHCG'er
#! Forum Moderator   |   StartPage -  protect your privacy   |   BBQ Linux

Online

#1656 2011-06-21 22:09:24

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,041
Website

Re: Conky Help

yuh_learn wrote:

I made this bash script for Conky that gets the window title of Iceweasel and prints it. It looks like this:

Any suggestions for how I could do it better?

Not me, maybe I can coax mobilediesel over for a look at it.


#! Conky = 13 Threads & the Conky Archives | Conky PitStop | OHCG'er
#! Forum Moderator   |   StartPage -  protect your privacy   |   BBQ Linux

Online

#1657 2011-06-22 05:54:44

mobilediesel
#! Member
Registered: 2010-08-19
Posts: 73

Re: Conky Help

yuh_learn wrote:

I made this bash script for Conky that gets the window title of Iceweasel and prints it. It looks like this:

#!/bin/bash

if [ -z "$(pgrep firefox-bin)" ]; then
    echo ""
else
    id=$(xlsclients -al|grep "Command:  firefox-bin" -A1 -B4|head -n1|cut -d ' ' -f 2|tr -d ':')
    pid=$(xprop -id "$id"|awk '/_NET_WM_PID/ {print $3}')
    title=$(wmctrl -lp|grep "$pid"|awk -F 'steamroller' '{print $2}')
    title=${title%%' - Iceweasel'}

    echo "  ~  ${title:1:90}"
fi

Any suggestions for how I could do it better?

Sector11 wrote:

Not me, maybe I can coax mobilediesel over for a look at it.

Since you are already using wmctrl and awk it can be way simplified:

if pid=$(pgrep firefox-bin); then
    title=$(wmctrl -lp | awk -F "$(uname -n) " '/'$pid'/ {sub(/ - Iceweasel/,"");print $2}')
    echo "  ~  ${title:0:90}"
else
    echo ""
fi

The "$(uname -n) " instead of 'steamroller' is just so this could be easily used on other machines without having to edit the script.

Offline

#1658 2011-06-22 14:01:04

Dodge ram
#! CrunchBanger
Registered: 2011-04-26
Posts: 140

Re: Conky Help

Screenshot.png

YAHOO! I'm getting closer. Thanks Sector11! What I had to do is use your code to make another conky and added it to my startup. So now all I have to do is make my adjustments. When I tried what you said the radar and my main conky was together in the center. Thanks mrpeachy for the radar code. Nighty night

Last edited by Dodge ram (2011-06-22 14:03:29)

Offline

#1659 2011-06-22 14:41:53

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,041
Website

Re: Conky Help

Dodge ram wrote:

YAHOO! I'm getting closer. Thanks Sector11! What I had to do is use your code to make another conky and added it to my startup. So now all I have to do is make my adjustments. When I tried what you said the radar and my main conky was together in the center. Thanks mrpeachy for the radar code. Nighty night

Yes, a new separate conky is what I said: called conky-radar
Play with the gap_x (left,right) gap_y (up,down) values  to get the top left corner of the map where you want it.

Then play with the size, set the minimum sizes first, then set the max width to match and  uncomment it:

minimum_size 400 200 # width, height
# maximum_width 400

Last edited by Sector11 (2011-06-22 16:02:37)


#! Conky = 13 Threads & the Conky Archives | Conky PitStop | OHCG'er
#! Forum Moderator   |   StartPage -  protect your privacy   |   BBQ Linux

Online

#1660 2011-06-22 16:10:05

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,041
Website

Re: Conky Help

@ mrpeachy

I need more help, I've struggled with this....
Today I fired it up via the terminal and I'm getting an error:

  13:00:54 ~
         $ conky -c ~/Conky/OB_TimeBar
Conky: desktop window (1ad) is root window
Conky: window type - override
Conky: drawing to created window (0x1800001)
Conky: drawing to double buffer
Conky: llua_getstring: function conky_draw_boxes didn't return a string, result discarded
Conky: llua_getstring: function conky_draw_boxes didn't return a string, result discarded
Conky: llua_getstring: function conky_draw_boxes didn't return a string, result discarded
Conky: received SIGINT or SIGTERM to terminate. bye!

  13:01:05 ~
         $ 

Conky parts that apply:

 lua_load ~/Conky/LUA/time_bar.lua
# lua_draw_hook_post draw_boxes
# lua_draw_hook_pre draw_boxes

# TEXT
# ${lua draw_boxes()}HH:blah-blah

TEXT
${lua draw_boxes}HH: ${time %H}

OH and it does work with brackets () - just needs a space:

TEXT
${lua draw_boxes ()}HH: ${time %H}

Neither way helps

And using:

 lua_load ~/Conky/LUA/time_bar.lua
# lua_draw_hook_post draw_boxes
 lua_draw_hook_pre draw_boxes

# TEXT
# ${lua draw_boxes()}HH:blah-blah

TEXT
HH: ${time %H}

gives the same error seen above.

Same LUA as yesterday:

--[[Time Bar
19 June 2011 Original by: mrpeachy
20 June 2011 by: Sector11
 - added HOURS, MINUTES & SECONDS
 - days changed to 31 for all months - easier to scale.
21 June 2011
 - with mrp's help added the background

call as follows in conky
lua_load ~/path to/time_bar.lua
lua_draw_hook_pre draw_boxes

]]
require 'cairo'
function rgb_to_r_g_b(color, alpha)
return ((color / 0x10000) % 0x100) / 255., ((color / 0x100) % 0x100) / 255., (color % 0x100) / 255., alpha
end

function conky_draw_boxes()
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)
cr = cairo_create(cs)
local updates=tonumber(conky_parse('${updates}'))
if updates>5 then
-- #############################################################################
-- CONKY BACKGROUND SETUP -- make sure this comes first --
settings={
corner_r=20,             -- corner radius
bg_color=0x000000,       -- set color 
bg_alpha=0.4,            -- set alpha = mrpeachy's test  :D
bg_height=-0,            -- negative number reduces height of bg
w=conky_window.width,
h=conky_window.height,
};background(settings)
-- end background setup --
-- #############################################################################
-- USER SETTINGS -- USER SETTINGS -- USER SETTINGS -- USER SETTINGS -- 
----------------------------
-- day box settings
----------------------------
local day_start_x=500           -- left &right
local day_start_y=3             -- up & down
local day_height=12             -- height of boxes
local day_total_length=400      -- total length of all boxes and gaps
local day_bg_color=0xFFFFFF     -- background color of box
local day_fg_color=0xE0FFFF     -- foreground color
local day_gap=2                 -- if display shows no divisions this is probably set too high
----------------------------
--month box settings
----------------------------
local month_start_x=500         -- left &right
local month_start_y=16          -- up & down
local month_height=12           -- height of boxes
local month_total_length=400    -- total length of all boxes and gaps
local month_bg_color=0xFFFFFF   -- background color of box
local month_fg_color=0xE0FFFF   -- foreground color
local month_gap=2               -- if display shows no divisions this is probably set too high
----------------------------
--year box settings
----------------------------
local year_start_x=500          -- left &right
local year_start_y=29           -- up & down
local year_height=12            -- height of boxes
local year_total_length=400     -- total length of all boxes and gaps
local year_bg_color=0xFFFFFF    -- background color of box
local year_fg_color=0xE0FFFF    -- foreground color
local year_gap=2                -- if display shows no divisions this is probably set too high
----------------------------
--hour box settings
----------------------------
local hour_start_x=50           -- left &right
local hour_start_y=3            -- up & down
local hour_height=12            -- height of boxes
local hour_total_length=400     -- total length of all boxes and gaps
local hour_bg_color=0xFFFFFF    -- background color of box
local hour_fg_color=0xE0FFFF    -- foreground color
local hour_gap=2                -- if display shows no divisions this is probably set too high
----------------------------
--minute box settings
----------------------------
local minute_start_x=50         -- left &right
local minute_start_y=16         -- up & down
local minute_height=12          -- height of boxes
local minute_total_length=400   -- total length of all boxes and gaps
local minute_bg_color=0xFFFFFF  -- background color of box
local minute_fg_color=0xE0FFFF  -- foreground color
local minute_gap=2              -- if display shows no divisions this is probably set too high
----------------------------
--second box settings
----------------------------
local second_start_x=50         -- left &right
local second_start_y=29         -- up & down
local second_height=12          -- height of boxes
local second_total_length=400   -- total length of all boxes and gaps
local second_bg_color=0xFFFFFF  -- background color of box
local second_fg_color=0xE0FFFF  -- foreground color
local second_gap=2              -- if display shows no divisions this is probably set too high
----------------------------
-- END USER SETTINGS -- END USER SETTINGS -- END USER SETTINGS --
--##############################################################################
-- STATIC SETTINGS -- STATIC SETTINGS -- STATIC SETTINGS -- STATIC SETTINGS -- 
----------------------------
-- YEAR Settings
----------------------------
local year_bits=100
local year2num=tonumber(os.date("%y"))
-------------------------------------------------
local box_total=year_total_length-(year_gap*(year_bits-1))
local box_len=box_total/year_bits
cairo_set_source_rgba(cr,rgb_to_r_g_b(year_bg_color,0.2))
for i=1,year_bits do
if i<=tonumber(year2num) then
cairo_set_source_rgba(cr,rgb_to_r_g_b(year_fg_color,0.7))
else
cairo_set_source_rgba(cr,rgb_to_r_g_b(year_bg_color,0.2))
end
cairo_rectangle(cr,year_start_x+(box_len*(i-1))+(year_gap*(i-1)),year_start_y, box_len, year_height)
cairo_fill (cr)
end
----------------------------
-- Month Settings
----------------------------
local month_bits=12
local month2num=tonumber(os.date("%m"))
-------------------------------------------------
local box_total=month_total_length-(month_gap*(month_bits-1))
local box_len=box_total/month_bits
cairo_set_source_rgba(cr,rgb_to_r_g_b(month_bg_color,0.2))
for i=1,month_bits do
if i<=tonumber(month2num) then
cairo_set_source_rgba(cr,rgb_to_r_g_b(month_fg_color,0.3))
else
cairo_set_source_rgba(cr,rgb_to_r_g_b(month_bg_color,0.2))
end
cairo_rectangle(cr,month_start_x+(box_len*(i-1))+(month_gap*(i-1)),month_start_y, box_len, month_height)
cairo_fill (cr)
end
----------------------------
-- Day Settings
----------------------------
local day_bits=31
local day2num=tonumber(os.date("%d"))
-------------------------------------------------
local box_total=day_total_length-(day_gap*(day_bits-1))
local box_len=box_total/day_bits
cairo_set_source_rgba(cr,rgb_to_r_g_b(day_bg_color,0.2))
for i=1,day_bits do
if i<=tonumber(day2num) then
cairo_set_source_rgba(cr,rgb_to_r_g_b(day_fg_color,0.7))
else
cairo_set_source_rgba(cr,rgb_to_r_g_b(day_bg_color,0.2))
end
cairo_rectangle(cr,day_start_x+(box_len*(i-1))+(day_gap*(i-1)),day_start_y, box_len, day_height)
cairo_fill (cr)
end
----------------------------
-- Hour Settings
----------------------------
local hour_bits=24
local hour2num=tonumber(os.date("%H"))
-------------------------------------------------
local box_total=hour_total_length-(hour_gap*(hour_bits-1))
local box_len=box_total/hour_bits
cairo_set_source_rgba(cr,rgb_to_r_g_b(hour_bg_color,0.2))
for i=1,hour_bits do
if i<=tonumber(hour2num) then
cairo_set_source_rgba(cr,rgb_to_r_g_b(hour_fg_color,0.7))
else
cairo_set_source_rgba(cr,rgb_to_r_g_b(hour_bg_color,0.2))
end
cairo_rectangle(cr,hour_start_x+(box_len*(i-1))+(hour_gap*(i-1)),hour_start_y, box_len, hour_height)
cairo_fill (cr)
end
----------------------------
-- Minute Settings
----------------------------
local minute_bits=60
local minute2num=tonumber(os.date("%M"))
-------------------------------------------------
local box_total=minute_total_length-(minute_gap*(minute_bits-1))
local box_len=box_total/minute_bits
cairo_set_source_rgba(cr,rgb_to_r_g_b(minute_bg_color,0.2))
for i=1,minute_bits do
if i<=tonumber(minute2num) then
cairo_set_source_rgba(cr,rgb_to_r_g_b(minute_fg_color,0.5))
else
cairo_set_source_rgba(cr,rgb_to_r_g_b(minute_bg_color,0.2))
end
cairo_rectangle(cr,minute_start_x+(box_len*(i-1))+(minute_gap*(i-1)),minute_start_y, box_len, minute_height)
cairo_fill (cr)
end
----------------------------
-- Second Settings
----------------------------
local second_bits=60
local second2num=tonumber(os.date("%S"))
-------------------------------------------------
local box_total=second_total_length-(second_gap*(second_bits-1))
local box_len=box_total/second_bits
cairo_set_source_rgba(cr,rgb_to_r_g_b(second_bg_color,0.2))
for i=1,second_bits do
if i<=tonumber(second2num) then
cairo_set_source_rgba(cr,rgb_to_r_g_b(second_fg_color,0.7))
else
cairo_set_source_rgba(cr,rgb_to_r_g_b(second_bg_color,0.2))
end
cairo_rectangle(cr,second_start_x+(box_len*(i-1))+(second_gap*(i-1)),second_start_y, box_len, second_height)
cairo_fill (cr)
end
-------------------------------------------------
-- #############################################################################
end -- if updates>5
cairo_destroy(cr)
cairo_surface_destroy(cs)
cr=nil
end -- end main function
-- #############################################################################
function background(t)
local corner_r=t.corner_r
local br,bg,bb,ba=rgb_to_r_g_b(t.bg_color,t.bg_alpha)
local v=t.bg_height
local h=t.h
local w=t.w
cairo_move_to(cr,corner_r,0)
cairo_line_to(cr,w-corner_r,0)
cairo_curve_to(cr,w,0,w,0,w,corner_r)
cairo_line_to(cr,w,h+v-corner_r)
cairo_curve_to(cr,w,h+v,w,h+v,w-corner_r,h+v)
cairo_line_to(cr,corner_r,h+v)
cairo_curve_to(cr,0,h+v,0,h+v,0,h+v-corner_r)
cairo_line_to(cr,0,corner_r)
cairo_curve_to(cr,0,0,0,0,corner_r,0)
cairo_close_path(cr)
cairo_set_source_rgba(cr,br,bg,bb,ba)
cairo_fill(cr)
end--function background

Last edited by Sector11 (2011-06-22 16:12:03)


#! Conky = 13 Threads & the Conky Archives | Conky PitStop | OHCG'er
#! Forum Moderator   |   StartPage -  protect your privacy   |   BBQ Linux

Online

#1661 2011-06-22 18:12:02

kruijf
#! Member
From: Soest, Netherlands
Registered: 2011-06-12
Posts: 76
Website

Re: Conky Help

Sector11 wrote:
kruijf wrote:
Sector11 wrote:

However you start your conky in Mint - give it a sleep time of 20 to 30 seconds to allow GNOME to start first:

sleep 30 && conky -c /path/to/conky

See:  ssc.sh

So i must make i script like the ssc.sh, i dont have that one yet.

If you have more than one conky a script is the best.
If you only have one conky  then add this to the start:

sleep 30 &&

if you use ~/.conkyrc it would be simple:

sleep 30 && conky

I'm  not finding the place to ad this ~/.conkyrc, sleep 30 && conky
Is it in the conky or in startup aplications?.
Sorry for my lot of questions.


Acer Aspire 5749: Debian Testing

Offline

#1662 2011-06-22 19:23:13

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,041
Website

Re: Conky Help

kruijf wrote:

I'm  not finding the place to ad this ~/.conkyrc, sleep 30 && conky
Is it in the conky or in startup aplications?.
Sorry for my lot of questions.

Do not worry about the questions, keep asking.  I'll keep answering.

Start up applications - start your conky like this:

sleep 30 && conky -c ~/conky/kruijf

Now if you want 2 conkys use the "ssc.sh" I showed you and make it like this:

#!/bin/sh
# click to start, click to stop

if pidof conky | grep [0-9] > /dev/null
  then
    exec killall conky
  else
    sleep 30 &&
    conky -c ~/conky/kruijf &&
    conky -c ~/conky/kruijf2 &&
  exit
fi

Make ssc.sh executable and in your start up applications - start your conky like this:

ssc.sh

That's it.


#! Conky = 13 Threads & the Conky Archives | Conky PitStop | OHCG'er
#! Forum Moderator   |   StartPage -  protect your privacy   |   BBQ Linux

Online

#1663 2011-06-22 20:20:57

yuh_learn
#! CrunchBanger
Registered: 2009-09-02
Posts: 118

Re: Conky Help

mobilediesel wrote:

Since you are already using wmctrl and awk it can be way simplified:

if pid=$(pgrep firefox-bin); then
    title=$(wmctrl -lp | awk -F "$(uname -n) " '/'$pid'/ {sub(/ - Iceweasel/,"");print $2}')
    echo "  ~  ${title:0:90}"
else
    echo ""
fi

The "$(uname -n) " instead of 'steamroller' is just so this could be easily used on other machines without having to edit the script.

Thanks a lot, mobilediesel! Do you have any idea how I can fetch the currently active window title? roll

I noticed a problem with using the PID. When I have two instances of IW running, both titles are printed. The same goes for the "Downloads" window, etc. I therefore changed my previous script to look like this:

if [ -z "$(pgrep firefox-bin)" ]; then
    echo ""
else
    id=$(xlsclients -al|grep "Command:  firefox-bin" -A1 -B4|head -n1|cut -d ' ' -f 2|tr -d ':')
    id=${id:2:5}
    title=$(wmctrl -l|grep "$id"|awk -F 'steamroller' '{print $2}')
    title=${title%%' - Iceweasel'}
    
    echo "${title:1:100}"
fi

It only gets the first instance of IW, which seems to be the window that was opened first. This is better for me since I want the title to be printed on a single line.


-----------------


More questions! Is it possible to get Conky to display a fixed height? I want my Conky bar to be exactly 15px high (at least only show the 15px of Conky that is important). I want to put it at the top of the desktop, but there is a gap that can't remove.

tOTZvbQ

alignment top_left
background yes
use_xft yes
xftfont sans:size=9
xftalpha 1.0
update_interval 1
total_run_times 0
own_window yes
own_window_type desktop
own_window_transparent no
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
own_window_argb_visual yes
own_window_argb_value 153
double_buffer yes
minimum_size 1361 0
maximum_width 1361
border_margin 0
use_spacer none
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
default_color FFFFFF
default_shade_color 000000
default_outline_color 000000
default_bar_size 40 7
gap_x 0
gap_y 0
no_buffers no
uppercase no
cpu_avg_samples 2
net_avg_samples 1
override_utf8_locale yes
use_spacer yes
text_buffer_size 256

TEXT
${voffset 0}${color FFFFFF}${font sans:size=8}  ${desktop}  ::${execi 60 python /home/apan/bin/imap/imap.py}  ::  ${exec /home/apan/bin/get_iceweasel_title/get_iceweasel_title.sh}${alignr}${exec /home/apan/bin/get_muine_track/get_track.sh}  ::  ${execbar /home/apan/bin/get_muine_track/draw_bar.sh}   ::  ${time}

Last edited by yuh_learn (2011-06-22 21:03:56)

Offline

#1664 2011-06-22 20:35:24

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,041
Website

Re: Conky Help

yuh_learn wrote:

Thanks a lot, mobilediesel! Do you have any idea how I can fetch the currently active window title? roll

Fetch! bash, fetch!

Oh wait, that only works with "Rover"!  big_smile

OH MD!!!!!


#! Conky = 13 Threads & the Conky Archives | Conky PitStop | OHCG'er
#! Forum Moderator   |   StartPage -  protect your privacy   |   BBQ Linux

Online

#1665 2011-06-22 21:09:01

yuh_learn
#! CrunchBanger
Registered: 2009-09-02
Posts: 118

Re: Conky Help

Sector11 wrote:
yuh_learn wrote:

Thanks a lot, mobilediesel! Do you have any idea how I can fetch the currently active window title? roll

Fetch! bash, fetch!

Oh wait, that only works with "Rover"!  big_smile

OH MD!!!!!

Try "grep! bash, grep!"

Bash replies, "awk! awk! awk!" lol

Offline

#1666 2011-06-22 21:27:31

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,041
Website

Re: Conky Help

yuh_learn wrote:
Sector11 wrote:
yuh_learn wrote:

Thanks a lot, mobilediesel! Do you have any idea how I can fetch the currently active window title? roll

Fetch! bash, fetch!

Oh wait, that only works with "Rover"!  big_smile

OH MD!!!!!

Try "grep! bash, grep!"

Bash replies, "awk! awk! awk!" lol

lol lol lol Now that's good!
Warning: waiting for MD can take a day or to - super busy guy.


#! Conky = 13 Threads & the Conky Archives | Conky PitStop | OHCG'er
#! Forum Moderator   |   StartPage -  protect your privacy   |   BBQ Linux

Online

#1667 2011-06-22 22:09:22

mobilediesel
#! Member
Registered: 2010-08-19
Posts: 73

Re: Conky Help

yuh_learn wrote:

Thanks a lot, mobilediesel! Do you have any idea how I can fetch the currently active window title? roll

I noticed a problem with using the PID. When I have two instances of IW running, both titles are printed. The same goes for the "Downloads" window, etc. I therefore changed my previous script to look like this:

if [ -z "$(pgrep firefox-bin)" ]; then
    echo ""
else
    id=$(xlsclients -al|grep "Command:  firefox-bin" -A1 -B4|head -n1|cut -d ' ' -f 2|tr -d ':')
    id=${id:2:5}
    title=$(wmctrl -l|grep "$id"|awk -F 'steamroller' '{print $2}')
    title=${title%%' - Iceweasel'}
    
    echo "${title:1:100}"
fi

It only gets the first instance of IW, which seems to be the window that was opened first. This is better for me since I want the title to be printed on a single line.

if pid=$(pgrep -o firefox-bin); then
    title=$(wmctrl -lp | awk -F "$(uname -n) " '/'$pid'/ {sub(/ - Iceweasel/,"");print $2}')
    echo "  ~  ${title:0:90}"
else
    echo ""
fi

The -o after pgrep makes it only show the oldest PID that matches. -n would show the newest.
For the current active window title:

Name=$(uname -n)
Window=$(xprop _NET_ACTIVE_WINDOW -root)
Window=${Window/0x/0x0}
Current_Active_Title=$(wmctrl -l | awk -F "$Name " '/'${Window##* }'/ {print $2}')
echo "  ~ $Current_Active_Title"

Offline

#1668 2011-06-23 11:09:59

yuh_learn
#! CrunchBanger
Registered: 2009-09-02
Posts: 118

Re: Conky Help

mobilediesel wrote:
if pid=$(pgrep -o firefox-bin); then
    title=$(wmctrl -lp | awk -F "$(uname -n) " '/'$pid'/ {sub(/ - Iceweasel/,"");print $2}')
    echo "  ~  ${title:0:90}"
else
    echo ""
fi

The -o after pgrep makes it only show the oldest PID that matches. -n would show the newest.
For the current active window title:

Name=$(uname -n)
Window=$(xprop _NET_ACTIVE_WINDOW -root)
Window=${Window/0x/0x0}
Current_Active_Title=$(wmctrl -l | awk -F "$Name " '/'${Window##* }'/ {print $2}')
echo "  ~ $Current_Active_Title"

Thanks a bunch! You are a wizard in my eyes. I only made some minor changes to the active window title script because it wouldn't catch some titles, like Thunar's. Is it because it's runs as a daemon that it's given different looking id's?

Name=$(uname -n)
Window=$(xprop _NET_ACTIVE_WINDOW -root)
Window=${Window/0x}
Window=${Window##* }
if [ "$Window" != "0" ]; then
    Current_Active_Title=$(wmctrl -l | awk -F "$Name " '/'${Window}'/ {print $2}')
    echo "$Current_Active_Title"
else
    echo ""
fi

The Window stuff in the beginning could probably be done in a simpler fashion, but my bash knowledge is limited to this. Seems to work without problem now, though! smile

Offline

#1669 2011-06-23 17:57:23

kruijf
#! Member
From: Soest, Netherlands
Registered: 2011-06-12
Posts: 76
Website

Re: Conky Help

Thnaks Sector11 i whil keep asking, becaus i want to learn more about this.
I tried sleep 30 && conky -c ~/conky/kruijf in my startup applications in the section command, but it wont work.
I also tried sleep 30 && conky -c ~/conky/bas my account on my systeem is bas, and is not working to.
What the problem is i dont know i tried serveral commands, nothing works for me.


Acer Aspire 5749: Debian Testing

Offline

#1670 2011-06-23 21:48:40

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,041
Website

Re: Conky Help

kruijf wrote:

Thnaks Sector11 i whil keep asking, becaus i want to learn more about this.
I tried sleep 30 && conky -c ~/conky/kruijf in my startup applications in the section command, but it wont work.
I also tried sleep 30 && conky -c ~/conky/bas my account on my systeem is bas, and is not working to.
What the problem is i dont know i tried serveral commands, nothing works for me.


OK, lets try this:  Where are the conky files (if more than one) you want to start?

Mine are here:

~/Conky/OB_Time_Up
~/Conky/OB_Top3
~/Conky/OB_366
~/Conky/OB_Email
~/Conky/OB_Email2
~/Conky/OB_Remind-Cal-R
~/Conky/OB_Remind-Cal-L

seven different conkys.

So I can start them in a terminal like this:

conky -c ~/Conky/OB_Time_Up
conky -c ~/Conky/OB_Top3
conky -c ~/Conky/OB_366
conky -c ~/Conky/OB_Email
conky -c ~/Conky/OB_Email2
conky -c ~/Conky/OB_Remind-Cal-R
conky -c ~/Conky/OB_Remind-Cal-L

or as one command:

conky -c ~/Conky/OB_Time_Up & conky -c ~/Conky/OB_Top3 & conky -c ~/Conky/OB_366 & conky -c ~/Conky/OB_Email & conky -c ~/Conky/OB_Email2 & conky -c ~/Conky/OB_Remind-Cal-R & conky -c ~/Conky/OB_Remind-Cal-L

and a bash script file would look like this  (make it executable):

#!/bin/sh
conky -c ~/Conky/OB_Time_Up &
conky -c ~/Conky/OB_Top3 &
conky -c ~/Conky/OB_366 &
conky -c ~/Conky/OB_Email &
conky -c ~/Conky/OB_Email2 &
conky -c ~/Conky/OB_Remind-Cal-R &
conky -c ~/Conky/OB_Remind-Cal-L &
exit

To add a delay:

#!/bin/sh

sleep 30 &
conky -c ~/Conky/OB_Time_Up &
conky -c ~/Conky/OB_Top3 &
conky -c ~/Conky/OB_366 &
conky -c ~/Conky/OB_Email &
conky -c ~/Conky/OB_Email2 &
conky -c ~/Conky/OB_Remind-Cal-R &
conky -c ~/Conky/OB_Remind-Cal-L &
exit

So show me
1. where your conky file is - or are if more than one
2. your autostart file
3. how you start your conky now.

The bash script I use today is this:

#!/bin/sh
if [ "$(pidof conky)" ]; then
    killall conky
conky -c ~/Conky/OB_Top3 &
conky -c ~/Conky/OB_Email &
conky -c ~/Conky/OB_Email2 &
conky -c ~/Conky/OB_Time_Up &
conky -c ~/Conky/OB_366 &
conky -c ~/Conky/OB_Remind-Cal-R &
conky -c ~/Conky/OB_Remind-Cal-L &
    exit

else
conky -c ~/Conky/OB_Top3 &
conky -c ~/Conky/OB_Email &
conky -c ~/Conky/OB_Email2 &
conky -c ~/Conky/OB_Time_Up &
conky -c ~/Conky/OB_366 &
conky -c ~/Conky/OB_Remind-Cal-R &
conky -c ~/Conky/OB_Remind-Cal-L &
    exit
fi

Last edited by Sector11 (2011-06-23 21:49:42)


#! Conky = 13 Threads & the Conky Archives | Conky PitStop | OHCG'er
#! Forum Moderator   |   StartPage -  protect your privacy   |   BBQ Linux

Online

#1671 2011-06-24 18:23:05

kruijf
#! Member
From: Soest, Netherlands
Registered: 2011-06-12
Posts: 76
Website

Re: Conky Help

My conky is here ~/.conkyrc
And iff i start the conky whit the terminal i do the command conky
For start up i use now this:
conkystartup.th.png


Acer Aspire 5749: Debian Testing

Offline

#1672 2011-06-24 21:40:12

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,041
Website

Re: Conky Help

kruijf wrote:

My conky is here ~/.conkyrc
And iff i start the conky whit the terminal i do the command conky
For start up i use now this:
conkystartup.th.png

Easy way - where it says

Command: conky

change it to:

Command: conky -p 30

"Log out" and come back.  Conky should be delayed 30 seconds allowing GNOME to start and setup before conky starts.


conky by itself will always start the default conky found at:

/etc/conky/conky.conf

However, if you have the file:

~/.conkyrc

it will start that.

Last edited by Sector11 (2011-06-24 21:41:55)


#! Conky = 13 Threads & the Conky Archives | Conky PitStop | OHCG'er
#! Forum Moderator   |   StartPage -  protect your privacy   |   BBQ Linux

Online

#1673 2011-06-25 18:42:28

kruijf
#! Member
From: Soest, Netherlands
Registered: 2011-06-12
Posts: 76
Website

Re: Conky Help

Command: conky -p 30

This one works for me thanks.


Acer Aspire 5749: Debian Testing

Offline

#1674 2011-06-25 20:03:25

Sector11
77345 ¡#
From: SR11 Cockpit
Registered: 2010-05-05
Posts: 11,041
Website

Re: Conky Help

kruijf wrote:
Command: conky -p 30

This one works for me thanks.

No problem.  Glad it finally worked out.


#! Conky = 13 Threads & the Conky Archives | Conky PitStop | OHCG'er
#! Forum Moderator   |   StartPage -  protect your privacy   |   BBQ Linux

Online

Be excellent to each other!

#1675 2011-06-25 20:12:08

kruijf
#! Member
From: Soest, Netherlands
Registered: 2011-06-12
Posts: 76
Website

Re: Conky Help

I learnd a lot of this.
And find out that scripting is fun but not easy, and that not easy is good i like to learn.


Acer Aspire 5749: Debian Testing

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