Skip to content

[Proposal] Support simple functions for conky; including storing them in other files than the conkyrc file #2310

@rubyFeedback

Description

@rubyFeedback

I would like to suggest to add functions to conky.

With this I do not mean lua; I mean functions definitions and function calls in conkyrc.

Let me explain this with an example next.

Right now I have this to show the top 4 processes:

${color grey}Name              PID     CPU%   MEM%
${color #eee} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
${color #ccc} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
${color #aaa} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
${color #888} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}

I would like to actually bundle this in a function such as:

show_the_top_four_processes

For instance:

def show_the_top_four_processes()
  ${color grey}Name              PID     CPU%   MEM%
  ${color #eee} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
  ${color #ccc} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
  ${color #aaa} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
  ${color #888} ${top name 4} ${top pid 4} ${top cpu 4} ${top mem 4}
end

This could be treated as simple macro-expansion, so not really a "full"
function. Though, a full function including passing arguments, may be
nice to have - but my idea here is solely for cleaning up the conkyrc
file, so that I have fewer # and $ variables to look at.

I don't care if a () is mandatory or not; if it is mandatory we can then call
it like this:

show_the_top_four_processes()

My idea here is to have my conkyrc file very clean. Rather than a gazillion
$ variables, I would like to group this more logically, so that I can simply
re-arrange the function calls that are more descriptive to me.

The benefit would be that I could simplify my conkyrc a LOT.

Also, I would like to be able to store these functions elsewhere on my
filesystem. Right now I think we must store everything in a single
(or mostly one) conkyrc file. I'd like to be able to call any local file
actually - at the least for such a conkyrc file.

Anyway - I don't know how other people see this, so perhaps please
comment, even if this proposal is closed. I'd like to know what other
people think about this - or perhaps my ideas are very off, right now
I don't know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions