Need help to edit .lua file for next and previous month displays [SOLVED]

Add functionality to your desktop
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Need help to edit .lua file for next and previous month displays [SOLVED]

Post by Logansfury »

Hello all,

I would like to expand a single month calendar I got from Bleys into a 3 month prev/current/next calendar like one I got from BunsenLabs forum.

I think this spot in the .lua determines the month to display:

Code: Select all

-- Parameter Grid Berechnung Monat / Parameters grid calculation month
    local time=os.time{year=os.date("%Y"), month=os.date("%m"), day=1}
    local weekday=os.date("%w", time)
    local mon=tonumber(os.date("%m"))+1
    local time=os.time{year=os.date("%Y"), month=mon, day=0}
    local lastday=tonumber(os.date("%d", time))
    local day=tonumber(os.date("%d"))
    local weekday=tonumber(weekday)
    local start=1
    local posabsbg=0
    if weekday == 0 then
        start=-5
        posabsbg=day+6
    else
        start=(weekday-2)*-1
        posabsbg=day+weekday-1
    end
Can anyone please provide the edits that would convert this from current month to both previous and next months?

Thank you for reading,

Logan
Last edited by Logansfury on Thu Feb 01, 2024 8:17 pm, edited 2 times in total.
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Koentje
Level 7
Level 7
Posts: 1581
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: Need help to edit .lua file for next and previous month displays

Post by Koentje »

Has nothing to do with your script! You can close or delete this topic.
Image
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Need help to edit .lua file for next and previous month displays

Post by Logansfury »

Koentje wrote: Tue Jan 30, 2024 5:09 pm Has nothing to do with your script! You can close or delete this topic.
Actually this is the calendar from Bleys, which has a slightly different format of week starting with monday and a nice feature of a different color code for weekend days.

I was hoping to see if this could be a 3-month calendar as well, to have completed my calendar collection and perhaps to run on the second Linux box to give it it's own look
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Koentje
Level 7
Level 7
Posts: 1581
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: Need help to edit .lua file for next and previous month displays

Post by Koentje »

I'm not experienced enough with LUA to do some heavy altering of LUA code.. but you could make a copy and fiddling around a bit.

...or ask Bleys ;)
Image
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Need help to edit .lua file for next and previous month displays

Post by Logansfury »

Koentje wrote: Tue Jan 30, 2024 5:27 pm I'm not experienced enough with LUA to do some heavy altering of LUA code.. but you could make a copy and fiddling around a bit.

...or ask Bleys ;)
Far out, I will do that. I already tried frankenstiening part of Bleys' conky with part of your calendars.sh. I wouldnt have any idea what to do beside cutting and pasting what seemed logical, but I only got display of the single month after doing that, I am officially out of ideas.
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Koentje
Level 7
Level 7
Posts: 1581
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: Need help to edit .lua file for next and previous month displays

Post by Koentje »

Btw, is that the complete script what you posted?? If not, that's not helpful..
Image
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Need help to edit .lua file for next and previous month displays

Post by Logansfury »

Koentje wrote: Tue Jan 30, 2024 5:38 pm Btw, is that the complete script what you posted?? If not, that's not helpful..
That was a snippit that I suspected was the part that needed editing. My bad, I didn't post the entirety of the .lua

If anyone awesome at .lua is reading and has the time and desire to do this edit, here is the full

cal2.lua:

Code: Select all

--[[
2023 Bleys
Screenshot ist im ersten Kommentar. (gist.github)
Änderungen des Font (Ubuntu Mono) und/oder der Schriftgröße erfordern auch eine Anpassung der Berechnung der Hintergrund Berechnung!
Das sollte man nur machen wenn man weis was man tut...

Screenshot in first Comment
Changing the font (Ubuntu Mono) and font size also requires an adjustment of the background calculation for the current day!
Only change if you know what you are doing!

mainx, mainy innerhalb der Funktion calendar bestimmen die Position des Kalenders.
mainx, mainy within the calendar function determine the position of the calendar.

--    color=0xffffff   --weiß / white
--    color=0x000000   --schwarz / black
--    color=0x0000ff   --blau / blue
--    color=0xffff00   --gelb / yellow
--    color=0xff0000   --rot / red
--    color=0x00ff00   --grün / green

]]
require 'cairo'
require "math"
function rgb_to_rgba(color,alpha)
	return ((color / 0x10000) % 0x100) / 255., ((color / 0x100) % 0x100) / 255., (color % 0x100) / 255., alpha
end
function draw_day(cr,xx,yy,bcolor,balpha) -- zeichne Hintergrund für aktuellen Tag / draw current Day Background 
    local corner_r=20
    local bg_color=0x000000   --rot / red (Farbe/Color)) 
    local bg_alpha=0.5
	local w=15
	local h=12
    local x=xx
    local y=yy
	cairo_set_source_rgba(cr,rgb_to_rgba(bcolor,balpha))	
	cairo_move_to(cr,x,y)
	cairo_line_to(cr,x+w,y)
	cairo_line_to(cr,x+w,y+h)
	cairo_line_to(cr,x,y+h)
	cairo_line_to(cr,x,y)
	cairo_close_path(cr)
--	cairo_stroke(cr) -- Markierung "Heute" durch Umrandung / Marking today by border
	cairo_fill(cr) -- Markierung "Heute" durch Hintergrund / Marking today by background
end

function draw_bg(cr, color, alpha, typ)
    local corner_r = 0
    local bg_color = color
    local bg_alpha = 0

    local w = conky_window.width
    local h = conky_window.height

    cairo_set_source_rgba(cr, rgb_to_rgba(bg_color, bg_alpha))
    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 - corner_r)
    cairo_curve_to(cr, w, h, w, h, w - corner_r, h)
    cairo_line_to(cr, corner_r, h)
    cairo_curve_to(cr, 0, h, 0, h, 0, h - corner_r)
    cairo_line_to(cr, 0, corner_r)
    cairo_curve_to(cr, 0, 0, 0, 0, corner_r, 0)
    cairo_close_path(cr)

    if typ == 1 then
        cairo_fill(cr)
    else
        cairo_set_source_rgba(cr, rgb_to_rgba(bg_color, 0))  -- Set alpha to 0 for transparent border
        cairo_stroke(cr)
    end
end

function write_text(cr, x, y, text, f)
--write_text(cr, x, y, text, {})
--font attributes (Schriftattribute zuweisen oder default Werte annehmen)
      local font=f.font or "Neon 80s"
      local size=f.size or 10
      local align=f.align or 'l'
      local bold=f.bold or false
      local ital=f.italic or false
      local color=f.color or "0xffffff"
      local slant=CAIRO_FONT_SLANT_NORMAL
      if ital then slant=CAIRO_FONT_SLANT_ITALIC end
      local weight=CAIRO_FONT_WEIGHT_NORMAL
      if bold then weight=CAIRO_FONT_WEIGHT_BOLD end

--Text Size (Textgröße für die Plazierung bestimmen.)
      local x_a=0
      local y_a=0
      local te = cairo_text_extents_t:create()
      tolua.takeownership(te)
      cairo_select_font_face (cr, font, slant, weight)
      cairo_set_font_size (cr, size)
      cairo_text_extents (cr, text, te)

--Text Position
      if align=='c' then
        x_a = -(te.width/2+te.x_bearing)
        y_a = -(te.height/2+te.y_bearing)
      end
      if align=='r' then
        x_a = -(te.width+te.x_bearing)
        --y_a = -(te.height+te.y_bearing)
      end

--Schadow 1 Pixel (Schatten für den Text um 1 Pixel versetzt)
      cairo_set_source_rgba(cr, rgb_to_rgba(0x000000,1))

      cairo_move_to (cr, x+1+x_a, y+1+y_a)
      cairo_show_text (cr, text)
      cairo_stroke(cr)

-- Now Text on Top (nun den Text oben drauf)
      cairo_set_source_rgba(cr, rgb_to_rgba(color,1))
      cairo_move_to (cr, x+x_a, y+y_a)
      cairo_show_text (cr, text)
      cairo_stroke(cr)
end

function calendar(cr)
-- x, y Koordinaten für den Kalender (oben, links) / x, y coordinates for the calendar (top, left)
    local mainx=10
    local mainy=32
-- End(e) x,y
-- Parameter Grid Berechnung Monat / Parameters grid calculation month
    local time=os.time{year=os.date("%Y"), month=os.date("%m"), day=1}
    local weekday=os.date("%w", time)
    local mon=tonumber(os.date("%m"))+1
    local time=os.time{year=os.date("%Y"), month=mon, day=0}
    local lastday=tonumber(os.date("%d", time))
    local day=tonumber(os.date("%d"))
    local weekday=tonumber(weekday)
    local start=1
    local posabsbg=0
    if weekday == 0 then
        start=-5
        posabsbg=day+6
    else
        start=(weekday-2)*-1
        posabsbg=day+weekday-1
    end
    local count=0
    local week=1
    local wd={}
    local we={}
    local workdays=""
    local weekend=""
    local bcolor=0xff0000 -- Farbe aktueller Tag / Color current Day
    local balpha=0.5 -- Alpha aktueller Tag /Alpha current Day
-- Ende Berechnung / end Calculation
-- Berechnung aktueller Tag Hintergrund / calculate current day Background
    local yposbg=math.floor(((posabsbg-posabsbg%7)/7)*12+mainy+20)
    if math.floor(posabsbg%7)==0 then yposbg=math.floor(((posabsbg-posabsbg%7)/7-1)*12+mainy+20) end
    local xposbg=math.floor((posabsbg%7)*18+mainx-13)
    if math.floor(posabsbg%7)==0 then xposbg=math.floor((posabsbg%7+7)*18+mainx-13) end
    draw_day(cr,xposbg,yposbg,bcolor,balpha) -- Funktion Hintergrund aktueller Tag / Function Highlight current Day
-- Ende Berechnung aktueller Tag Hintergrund / calculate today Background
-- Monatsübersicht zusammenstellen / Compile monthly overview
    for i=start,lastday do
        if i<1 then -- old Month
            if (start==-5 and i==0) then -- Weekend
                weekend=weekend.."   "
            else -- Work Days
                workdays=workdays.."   "
            end
        else
            if i<10 then
                if count<5 then
                    workdays=workdays.."  "..i
                else
                    weekend=weekend.."  "..i
                end
            else
                if count<5 then
                    workdays=workdays.." "..i
                else
                    weekend=weekend.." "..i
                end
            end
        end
        count=count+1
        if ( count == 7 or i == lastday ) then
            wd[week]=workdays
            we[week]=weekend
            week=week+1
            workdays=""
            weekend=""
            count=0
        end
    end
-- Ende Monatsübersicht zusammenstellen / End Compile monthly overview
-- Schreiben... / write...
    write_text(cr, mainx+66, mainy-16, os.date("%B").." "..os.date("%Y"), {font="Dyuthi", size=14, align="c"}) 
    write_text(cr, mainx+1, mainy+17, " Mo Tu We Th Fr ", {font="Ubuntu Mono", size=12, bold=true, align="l"})     
    write_text(cr, mainx+91, mainy+17, " Sa Su", {font="Ubuntu Mono", size=12, bold=true, color="0xffff00", align="l"}) 
    for w=1,week do
        wy=mainy+30+((w-1)*12)
        wx=mainx+90
        write_text(cr, mainx, wy, wd[w], {font="Ubuntu Mono", size=12, align="l"})
        write_text(cr, wx, wy, we[w], {font="Ubuntu Mono", size=12, align="l", color="0xffff00"}) -- Farbe/Color WE
    end
-- Ende Schreiben / End write
end

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)		
	local updates=conky_parse('${updates}')
	update_num=tonumber(updates)
	if update_num>5 then
        color=0xffffff  alpha=0.1   typ=1
        draw_bg(cr,color,alpha,typ) -- Funktion Hintergrund Conky Bereich / Function Backgrounds Conky Area
        color=0xffffff  alpha=0.8   typ=2
--        draw_bg(cr,color,alpha,typ) --zeichne Linie um den Bereich / Draw line around Conky Area
        calendar(cr) -- Hauptfunktion erzeuge / Main
	end

   cairo_surface_destroy(cs)
   cairo_destroy(cr)
end
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Koentje
Level 7
Level 7
Posts: 1581
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: Need help to edit .lua file for next and previous month displays

Post by Koentje »

And how is the lua scipt called from within the conky script?
Image
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Need help to edit .lua file for next and previous month displays

Post by Logansfury »

Koentje wrote: Tue Jan 30, 2024 5:59 pm And how is the lua scipt called from within the conky script?
my newbness is shining like a beacon today. Here is the conkyrc:

Code: Select all

conky.config = {

	background = false,

	alignment = 'top_left',
	gap_x = 180,
	gap_y = 90,
	minimum_width = 130,
	minimum_height = 100, --ring

	border_inner_margin = 10,
	draw_graph_borders = true,
	draw_outline = false,
	double_buffer = true,
	no_buffers = true,

-- Window Settings --
  background = false,
  border_width = 0,
  draw_borders = false,
  draw_graph_borders = false,
  draw_outline = false,
  draw_shades = false,
  own_window = true,
  own_window_colour = '000000',
  own_window_class = 'Conky',
  own_window_argb_visual = true,
  own_window_argb_value = 0,
  own_window_type = 'dock',
  own_window_transparent = true,
  own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager',
  stippled_borders = 0,

	update_interval = 1,
	total_run_times = 0,

	lua_load = './cal2.lua',
	lua_draw_hook_post = 'main',

};
conky.text = [[

]];
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Koentje
Level 7
Level 7
Posts: 1581
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: Need help to edit .lua file for next and previous month displays

Post by Koentje »

And what's the problem with this one? I see a decent calendar with highlighted current day and even colored weekend days.
Schermafdruk van 2024-01-30 23-05-16.jpg
Schermafdruk van 2024-01-30 23-05-16.jpg (6.28 KiB) Viewed 522 times
Image
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Need help to edit .lua file for next and previous month displays

Post by Logansfury »

Koentje wrote: Tue Jan 30, 2024 6:06 pm And what's the problem with this one? I see a decent calendar with highlighted current day and even colored weekend days.

Schermafdruk van 2024-01-30 23-05-16.jpg
Yep It's beautiful which is why I wanted to see if it could be transformed into a 3 month display like the calendar from BunsenLabs (turns out it wasnt GitHub) I was going to have your's on the Dell box, put this if I could get it as a 3 month on the HP box and enjoy the best of both worlds :)

The Desklet im using for display of calendar events makes the 3 month calendar balance the desktop much nicer
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Need help to edit .lua file for next and previous month displays

Post by Bleys »

Just wait
the extension is in progress
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Need help to edit .lua file for next and previous month displays

Post by Logansfury »

Bleys wrote: Wed Jan 31, 2024 1:59 am Just wait
the extension is in progress
Wonderful news :D
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Need help to edit .lua file for next and previous month displays

Post by Bleys »

First Version
Screen Capture_select-area_20240131112502.jpg
cal.lua

Code: Select all

--[[
2023 Bleys
Screenshot ist im ersten Kommentar. (gist.github)
Änderungen des Font (Ubuntu Mono) und/oder der Schriftgröße erfordern auch eine Anpassung der Berechnung der Hintergrund Berechnung!
Das sollte man nur machen wenn man weis was man tut...

Screenshot in first Comment
Changing the font (Ubuntu Mono) and font size also requires an adjustment of the background calculation for the current day!
Only change if you know what you are doing!

mainx, mainy innerhalb der Funktion calendar bestimmen die Position des Kalenders.
mainx, mainy within the calendar function determine the position of the calendar.

--    color=0xffffff   --weiß / white
--    color=0x000000   --schwarz / black
--    color=0x0000ff   --blau / blue
--    color=0xffff00   --gelb / yellow
--    color=0xff0000   --rot / red
--    color=0x00ff00   --grün / green

]]
require 'cairo'
require "math"
function rgb_to_rgba(color,alpha)
	return ((color / 0x10000) % 0x100) / 255., ((color / 0x100) % 0x100) / 255., (color % 0x100) / 255., alpha
end
function draw_day(cr,xx,yy,bcolor,balpha) -- zeichne Hintergrund für aktuellen Tag / draw current Day Background 
    local corner_r=20
    local bg_color=0xff0000   --rot / red (Farbe/Color))
    local bg_alpha=0.5
	local w=15
	local h=12
    local x=xx
    local y=yy
	cairo_set_source_rgba(cr,rgb_to_rgba(bcolor,balpha))	
	cairo_move_to(cr,x,y)
	cairo_line_to(cr,x+w,y)
	cairo_line_to(cr,x+w,y+h)
	cairo_line_to(cr,x,y+h)
	cairo_line_to(cr,x,y)
	cairo_close_path(cr)
--	cairo_stroke(cr) -- Markierung "Heute" durch Umrandung / Marking today by border
	cairo_fill(cr) -- Markierung "Heute" durch Hintergrund / Marking today by background
end
function draw_bg(cr,color,alpha,typ) -- zeichne Hintergrund Conky Fenster / draw Conky Area Background
    local corner_r=0
    local bg_color=color 
    local bg_alpha=alpha
	local w=conky_window.width
	local h=conky_window.height
	cairo_set_source_rgba(cr,rgb_to_rgba(bg_color,bg_alpha))
	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-corner_r)
	cairo_curve_to(cr,w,h,w,h,w-corner_r,h)
	cairo_line_to(cr,corner_r,h)
	cairo_curve_to(cr,0,h,0,h,0,h-corner_r)
	cairo_line_to(cr,0,corner_r)
	cairo_curve_to(cr,0,0,0,0,corner_r,0)
	cairo_close_path(cr)
	
    if typ==1 then
	    cairo_fill(cr)
    else
        cairo_stroke(cr)
    end
end 

function write_text(cr, x, y, text, f)
--write_text(cr, x, y, text, {})
--font attributes (Schriftattribute zuweisen oder default Werte annehmen)
      local font=f.font or "Noto Sans"
      local size=f.size or 10
      local align=f.align or 'l'
      local bold=f.bold or false
      local ital=f.italic or false
      local color=f.color or "0xffffff"
      local slant=CAIRO_FONT_SLANT_NORMAL
      if ital then slant=CAIRO_FONT_SLANT_ITALIC end
      local weight=CAIRO_FONT_WEIGHT_NORMAL
      if bold then weight=CAIRO_FONT_WEIGHT_BOLD end

--Text Size (Textgröße für die Plazierung bestimmen.)
      local x_a=0
      local y_a=0
      local te = cairo_text_extents_t:create()
      tolua.takeownership(te)
      cairo_select_font_face (cr, font, slant, weight)
      cairo_set_font_size (cr, size)
      cairo_text_extents (cr, text, te)

--Text Position
      if align=='c' then
        x_a = -(te.width/2+te.x_bearing)
        y_a = -(te.height/2+te.y_bearing)
      end
      if align=='r' then
        x_a = -(te.width+te.x_bearing)
        --y_a = -(te.height+te.y_bearing)
      end

--Schadow 1 Pixel (Schatten für den Text um 1 Pixel versetzt)
      cairo_set_source_rgba(cr, rgb_to_rgba(0x000000,1))

      cairo_move_to (cr, x+1+x_a, y+1+y_a)
      cairo_show_text (cr, text)
      cairo_stroke(cr)

-- Now Text on Top (nun den Text oben drauf)
      cairo_set_source_rgba(cr, rgb_to_rgba(color,1))
      cairo_move_to (cr, x+x_a, y+y_a)
      cairo_show_text (cr, text)
      cairo_stroke(cr)
end

function calendar(cr,monat,xPos,yPos)
    local monoffset=tonumber(monat)
    local c_year=tonumber(os.date("%Y"))
    local c_mon=tonumber(os.date("%m"))
    local c_day=os.date("%d")
    if (monoffset<0 and c_mon==1) then
        c_year=c_year-1
        c_mon=12
    elseif (monoffset>0 and c_mon==12) then
        c_year=c_year+1
        c_mon=1
    else
        c_mon=c_mon+monoffset
    end 

-- x, y Koordinaten für den Kalender (oben, links) / x, y coordinates for the calendar (top, left)
    local mainx=xPos --10
    local mainy=yPos --32
-- End(e) x,y
-- Parameter Grid Berechnung Monat / Parameters grid calculation month
    local time=os.time{year=c_year, month=c_mon, day=1} --unixzeit 1. des Monats
    local monname=os.date("%B",time)
    local weekday=os.date("%w", time) --Wochentag des 1.
    local mon=c_mon+1 --Folgemonat
    local time=os.time{year=c_year, month=mon, day=0} --unixzeit letzter Tag aktueller monat
    local lastday=tonumber(os.date("%d", time)) --letzter Tag des Monats (28,29,30,31)
    local day=tonumber(os.date("%d")) -- aktueller Tag
    local weekday=tonumber(weekday)
    local start=1
    local posabsbg=0
    if weekday == 0 then
        start=-5
        posabsbg=day+6
    else
        start=(weekday-2)*-1
        posabsbg=day+weekday-1
    end
    local count=0
    local week=1
    local wd={}
    local we={}
    local workdays=""
    local weekend=""
    local bcolor=0xff0000 -- Farbe aktueller Tag / Color current Day
    local balpha=0.5 -- Alpha aktueller Tag /Alpha current Day
-- Ende Berechnung / end Calculation
-- Berechnung aktueller Tag Hintergrund / calculate current day Background
    local yposbg=math.floor(((posabsbg-posabsbg%7)/7)*12+mainy+20)
    if math.floor(posabsbg%7)==0 then yposbg=math.floor(((posabsbg-posabsbg%7)/7-1)*12+mainy+20) end
    local xposbg=math.floor((posabsbg%7)*18+mainx-13)
    if math.floor(posabsbg%7)==0 then xposbg=math.floor((posabsbg%7+7)*18+mainx-13) end
    if monat==0 then
        draw_day(cr,xposbg,yposbg,bcolor,balpha) -- Funktion Hintergrund aktueller Tag / Function Highlight current Day
    end
-- Ende Berechnung aktueller Tag Hintergrund / calculate today Background
-- Monatsübersicht zusammenstellen / Compile monthly overview
    for i=start,lastday do
        if i<1 then -- old Month
            if (start==-5 and i==0) then -- Weekend
                weekend=weekend.."   "
            else -- Work Days
                workdays=workdays.."   "
            end
        else
            if i<10 then
                if count<5 then
                    workdays=workdays.."  "..i
                else
                    weekend=weekend.."  "..i
                end
            else
                if count<5 then
                    workdays=workdays.." "..i
                else
                    weekend=weekend.." "..i
                end
            end
        end
        count=count+1
        if ( count == 7 or i == lastday ) then
            wd[week]=workdays
            we[week]=weekend
            week=week+1
            workdays=""
            weekend=""
            count=0
        end
    end
-- Ende Monatsübersicht zusammenstellen / End Compile monthly overview
-- Schreiben... / write...
    write_text(cr, mainx+66, mainy-16, monname.." "..c_year, {font="Dyuthi", size=14, align="c"}) 
    write_text(cr, mainx+1, mainy+17, " Mo Di Mi Do Fr ", {font="Ubuntu Mono", size=12, bold=true, align="l"})     
    write_text(cr, mainx+91, mainy+17, " Sa So", {font="Ubuntu Mono", size=12, bold=true, color="0x0ab1ff", align="l"}) 
    for w=1,week do
        wy=mainy+30+((w-1)*12)
        wx=mainx+90
        write_text(cr, mainx, wy, wd[w], {font="Ubuntu Mono", size=12, align="l"})
        write_text(cr, wx, wy, we[w], {font="Ubuntu Mono", size=12, align="l", color="0x1e90ff"}) -- Farbe/Color WE
    end
-- Ende Schreiben / End write
end

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)		
	local updates=conky_parse('${updates}')
	update_num=tonumber(updates)
	if update_num>5 then
        color=0xffffff  alpha=0.1   typ=1
        draw_bg(cr,color,alpha,typ) -- Funktion Hintergrund Conky Bereich / Function Backgrounds Conky Area
--        color=0xffffff  alpha=0.8   typ=2
--        draw_bg(cr,color,alpha,typ) --zeichne Linie um den Bereich / Draw line around Conky Area
          calendar(cr,-1,10,32) -- Hauptfunktion erzeuge / Main
          calendar(cr,0,140,32) -- Hauptfunktion erzeuge / Main
          calendar(cr,1,270,32) -- Hauptfunktion erzeuge / Main

	end

   cairo_surface_destroy(cs)
   cairo_destroy(cr)
end
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Need help to edit .lua file for next and previous month displays

Post by Logansfury »

That looks wonderful!!

What are your ideas for other versions?
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Need help to edit .lua file for next and previous month displays

Post by Bleys »

By changing x,y per month, a vertical view is of course also possible
Screen Capture_select-area_20240131113135.jpg
Screen Capture_select-area_20240131113135.jpg (17.6 KiB) Viewed 416 times
or add more month
Screen Capture_select-area_20240131113653.jpg
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Need help to edit .lua file for next and previous month displays

Post by Bleys »

As I said: first version! There could still be errors etc.
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Need help to edit .lua file for next and previous month displays

Post by Logansfury »

Bleys wrote: Wed Jan 31, 2024 6:41 am As I said: first version! There could still be errors etc.
They look amazing. I am going to load up the horizontal 3 month array and see how it looks!
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
User avatar
Bleys
Level 4
Level 4
Posts: 431
Joined: Wed Apr 20, 2022 4:17 am
Location: Essen, Germany

Re: Need help to edit .lua file for next and previous month displays

Post by Bleys »

Space between month name and Days. Change:
write_text(cr, mainx+66, mainy-16, monname.." "..c_year, {font="Dyuthi", size=14, align="c"})
to
write_text(cr, mainx+66, mainy-4, monname.." "..c_year, {font="Dyuthi", size=14, align="c"})
Ryzen 5 5600G, 16GB RAM, 2TB M.2 Crucial P3, Asrock Deskmeet X300, Samsung Odyssey 49", Linux Mint 21
User avatar
Logansfury
Level 6
Level 6
Posts: 1237
Joined: Fri Oct 27, 2023 4:08 pm
Location: Las Vegas NV, USA

Re: Need help to edit .lua file for next and previous month displays

Post by Logansfury »

My conkyrc is only displaying last month not current or next, using the .lua you just posted.

May I have the conkyrc you are working with please?
Image <-- Cick for sudo inxi --usb -Fxxxnmprz output, updated hourly!
Post Reply

Return to “Compiz, Conky, Docks & Widgets”