GithubHelp home page GithubHelp logo

philer / polycore Goto Github PK

View Code? Open in Web Editor NEW
79.0 3.0 5.0 5.34 MB

A conky config and library of Lua widgets

Home Page: https://philer.github.io/polycore

License: MIT License

Lua 100.00%
conky conky-theme conky-widget lua cairo lua-widgets conkyrc drive-temperature widgets cpu

polycore's Introduction

polycore

A conky config and library of Lua widgets

columns layout

Features

  • Stylish replacements for conky's default bars and graphs
  • Allows complex layouts with minimal effort
  • Minimal resource overhead through caching
  • Easy to extend

Requirements

  • conky 1.10+ (with Lua and cairo support)
  • basic understanding of conky and Lua
  • optional: lm_sensors to display CPU core temperature and fan rpm
  • optional: nvidia-smi to display NVIDIA video card stats

Getting started

The widget module provides a number of basic and specialized modules as well as grouping and rendering facilities. Their basic usage is best understood by inspecting the polycore.setup function in layout.lua. Modifying this function is also the easiest way to get started. More examples can be found in examples.

You can either use a single-file setup (see examples/columns.lua) or split the conky config and Widget layout into two files (see conkyrc.lua and layout.lua).

screenshot Wallpapers from pexels.com: 1, 2, 3, 4, 5 and the one above

Using Widgets

See philer.github.io/polycore/modules/widget.html for a full API reference.

Widgets are rendered by a widget.Renderer instance and can have a cached background. A widget.Rows or widget.Columns instance can serve as root of a complex layout of nested widgets. It makes sense to combine this with normal conky text rendering - in fact some Widgets (e.g. widget.Network and widget.Drive) assume this.

A widget can have fixed or flexible height and width. Fixed means that the widget's :init function sets the .width/.height property to an integer. If the respective property is not defined (nil) the layout engine will assign an automatic amount of space, split evenly between this and other flexible widgets.

The following Widget classes are currently available:

  • Widget the base class - Does nothing by itself.
  • Rows a container for multiple widgets to be rendered in a vertical stack - It can also be useful to subclass this in order to create composite widgets with a combined :update() (see the implementation of Drive as an example).
  • Columns like Rows but horizontal
  • Filler Leave some empty space. Can also wrap another widget to restrict its size.
  • Frame Provides background color, border, padding and margin for other Widgets.
  • Bar a basic bar similar to the one available in normal conky.
  • MemoryBar a bar visualizing RAM usage.
  • Graph a basic graph similar to the one available in normal conky.
  • LED a minimalistic indicator light with adjustable brightness and color.
  • StaticText Display some unchangeable text.
  • TextLine Display a dynamic line of text.
  • Cpu CPU usage indiciator in the form of a polygon one segment per core - You guessed it, that's how this theme got its name.
  • CpuRound A round CPU usage indicator best suited for high core counts.
  • CpuFrequencies Bar-like indicator of frequencies for individual cores
  • MemoryGrid visualization of used (and buffered/cached) RAM in a randomized grid
  • Gpu Bars for GPU and VRAM usage - requires nvidia-smi
  • GpuTop Show processes currently using the CPU.
  • Network Graphs for up- and download speed - with space for conky.text in between.
  • Drive Bar plus temperature indicator for a HDD or SSD.

Creating Widgets

In order to add your own Widget you should inherit the base class (local MyWidget = util.class(widget.Widget)). Look at widget.lua for examples.

The Widget API assumes the following functions. Note that only :layout is required.

  • MyWidget:init(…) Your widget's constructor. It can set fixed .width/.height properties (see above).
  • MyWidget:layout(width, height) This function will be called with arguments specifying the assigned space. If fixed .width and/or .height were specified the given arguments will be at least that value but may be greater. Note: For container Widgets this function must return a table of its children with relative coordinates and sizes. See the implementations of Columns and Frame.
  • MyWidget:render_background(cr) Allows you to draw some static background. This function will be called once at startup and again if the layout changes.
  • MyWidget:update(update_count) Called once per update before :render with the value of conky's ${updates} variable. Here you can fetch new data to update the information visualized by your widget. If your widget's size has changed this function should return true to trigger a layout reflow.
  • MyWidget:render(cr) Allows you to draw dynamic content once per update.

You can also create composite Widgets by subclassing Rows or Columns. See Drive as an example.

polycore's People

Contributors

ogrefish avatar philer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

polycore's Issues

Conky does not start using polycore conkyrc.lua

Hello there,
I'm having this error:

conky -c ~/.config/conky/polycore/conkyrc.lua -DDD
DEBUG(0) [/build/conky-USSzL9/conky-1.10.8/src/conky.cc:2740]: reading contents from config file '/home/blitux/.config/conky/polycore/conkyrc.lua'
DEBUG(0) [/build/conky-USSzL9/conky-1.10.8/src/x11.cc:494]: Fixed xinerama area to: 0 0 1920 1080
DEBUG(0) [/build/conky-USSzL9/conky-1.10.8/src/x11.cc:494]: Fixed xinerama area to: 0 0 1920 1080
conky: desktop window (1800011) is subwindow of root window (4db)
DEBUG(0) [/build/conky-USSzL9/conky-1.10.8/src/x11.cc:631]: Found ARGB Visual
conky: window type - override
conky: drawing to created window (0x6400002)
X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  1 (X_CreateWindow)
  Serial number of failed request:  135
  Current serial number in output stream:  139

I just removed the mounts part and nvidia related stuff on both, layout.lua and conkyrc.lua.

This is my conky version (installed with sudo apt install conky-all on elementary os 5.1.4 Hera):

conky -v                                          
conky 1.10.8 compiled Wed Feb 28 17:11:42 UTC 2018 for Linux 4.4.0-101-generic x86_64

Compiled in features:

System config file: /etc/conky/conky.conf
Package library path: /usr/lib/conky


 General:
  * math
  * hddtemp
  * portmon
  * IPv6
  * Curl
  * RSS
  * Weather (METAR)
  * Weather (XOAP)
  * wireless
  * support for IBM/Lenovo notebooks
  * nvidia
  * eve-online
  * builtin default configuration
  * old configuration syntax
  * Imlib2
  * apcupsd
  * iostats
  * ncurses
  * Internationalization support
  * PulseAudio

 Lua bindings:
  * Cairo
  * Imlib2
  * RSVG
 X11:
  * Xdamage extension
  * Xinerama extension (virtual display)
  * Xshape extension (click through)
  * XDBE (double buffer extension)
  * Xft
  * ARGB visual
  * Own window

 Music detection:
  * Audacious
  * MPD
  * MOC
  * XMMS2

 Default values:
  * Netdevice: eth0
  * Local configfile: $HOME/.conkyrc
  * Localedir: /usr/share/locale
  * Maximum netdevices: 64
  * Maximum text size: 16384
  * Size text buffer: 256

Any clues of what is failing? Thanks!

conky: X Error: type 0 Display

Hi,

Your conky setup is awesome, thanks for it!
I'm trying to use it on Solus Linux (conky version - 1.11.5), but:

 conky -c conkyrc.lua 
conky: desktop window (160004d) is subwindow of root window (1f0)
conky: window type - override
conky: drawing to created window (0x4a00002)
conky: X Error: type 0 Display 23ef1d0 XID 23068749 serial 135 error_code 8 request_code 1 minor_code 0 other Display: 23ef1d0

Aborted

Would you be so kind to help me fixing it ?

Best Regards,
PY

Tests failing on Manjaro Linux.

I really like the look of the Polycore graph, but have been unable to get it to work. I have removed any of the nvidia / drive sections. I did not modify the core count, and have more than 6 cores, in case that makes a difference.

Linux version: 5.4.0-2-MANJARO (Manjaro Testing Branch)
Conky version: 1.11.3 (conky-lua from AUR)

conky -c test/test_util.lua

test clamp passed
test CycleQueue passed

conky -c test/test_layout.lua

test columns passed
test frame passed
test/test_layout.lua:58: render of at /tmp/conky_test.png does not match expected result at test/expected_outputs/complex_layout.png
stack traceback:
	test/test_layout.lua:190: in function 
	[C]: in function 'assert'
	test/test_layout.lua:58: in upvalue 'check_renderer'
	test/test_layout.lua:178: in function 
	[C]: in function 'xpcall'
	test/test_layout.lua:197: in function 'conky_update'
test complex_layout failed
test group passed

conky -c conkyrc.lua

conky: desktop window (400010) is subwindow of root window (6b4)
conky: window type - normal
conky: drawing to created window (0x2c00002)
conky: drawing to double buffer
./layout.lua:25: invalid value (nil) at index 3 in table for 'concat'
stack traceback:
	./src/polycore.lua:50: in function <./src/polycore.lua:49>
	[C]: in function 'table.concat'
	./layout.lua:25: in method 'update'
	./src/widget.lua:138: in method 'update'
	./src/polycore.lua:30: in function <./src/polycore.lua:25>
	[C]: in function 'xpcall'
	./src/polycore.lua:60: in function 'conky_update'

The stack traceback repeats every 1 second, which makes sense given the update timer.

Note: if I used window_type override I get a completely different error, but I think that is from this conky issue: brndnmtthws/conky#424

Significantly Expanding Polycore.

Firstly, I think its worth explaining what i'm trying to solve, then how i'd like to adapt Polycore to solve these issues.

Currently I am looking at Conky from the perspective of a distro maintainer trying to provide the best possible out of the box experience when running Conky with a "Default" config. Currently there are three major issues with upstream Conky that I am trying to address, firstly the current conky config cannot adapt automatically to different system setups ie the number of CPU Cores, where drives are mounted, Network interface names etc. The second major issue I see is the out of the box styling is very dated and there are much better options out there. Thirdly if you want to do a custom config / layout its really painful in upstream conky.

I think the best solution to all of these issues is moving to a 100% lua based config. With that in mind I think that Polycore already solves 3 really well and with brndnmtthws/conky#1501 fixing the Lua text rendering issues when it is accepted I think it would be possible to move Polycore to 100% lua config. Polycore also can be adapted to help resolve the first issue by creating more advanced / higher level widgets that autodetect hardware where possible.

In terms of look Polycore already provides a great option, but i'd like to extend it with more inspired from

Once I have some of this done id like to approach other theme developers along with upstream about working together to create a more lua based "2.0 Config" for conky so we can all collaborate together in the same place, either in the upstream conky repo if they are happy with that or in some other form of "conky extended" repo. Long term I might even add a graphical tool for generating configs.

This is obviously a lot of new work so my first obvious question for you is would you like to be involved? and if so to what extent, for example I have a couple of small improvements to the core of your widget system and I could just send those as PR's or as I develop new widgets / modify the current widgets to use the new text rendering API I could send those, I guess the question is at the moment would you like me to send you everything? just the stuff that will make your Polycore theme function better or nothing? and I'll just keep working out of my repo.

I probably have other new questions around design / structure as well, an initial one being that having all the widgets in a single directory probably won't scale so i'm thinking of splitting them into lower level "Core" Widgets, text, graph etc and higher level based on type such as CPU Memory etc. and i'd like to know your thoughts on that if the answer to the previous question was keep sending stuff.

Thanks again for all the work you've put into polycore, initially when I started looking at doing this I thought i'd have to write my own widget and layout system.

Simon

Unexpected right margin not filled in by frame

I've been trying to use Polycore to replicate an existing setup I have that makes use of a Lua script to draw boxes (it's quite old, but I think I initially took the code from here.

My initial experimentation seems to be stuck because I'm trying to draw a text widget in a frame to fill the entire width - but it seems to leave 12 pixels on the right. While the settings for Conky specify a maximum width of 200, if I I print out the value of conky_window.width in cairo_helpers.create_cr, it prints out a value of 212. text_width is 200.

I don't know where the extra 12 pixels are coming from - I don't mind necessarily that it's bigger than I expected (I'm sure that's a Conky decision rather than a Polycore one), it would be good if Polycore could fill in the entire size of the Conky window. I know it must be doable (I don't have the same problem with the existing Lua script I use), but I can't figure out how to get Polycore to do it.

I've included a screenshot of what I'm getting, and a stripped down version of the text.lua example that produces it. Any idea how I could achieve what I'm after (either by stripping out those 12 pixels, or getting Polycore to fill it)?

Screenshot from 2023-02-09 13-54-39
baretext.lua.txt

Missing License file.

Hi,
I'd like to include this as part of a distro so its easier for more people to use, If your generally reasonably happy for people to use the lua code however then the MIT license is a good simple solution that's used with a number of other configs. All you'd need to do is copy the license text from here https://opensource.org/licenses/MIT into a copying or license file or maybe tot he bottom of your ReadMe.md if your happy with it, or pick any one of a number of other different licenses.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.