'First time using cairo in AwesomeWM
This is for anyone who's having trouble getting started with cairo.
The documentation didn't give a good, complete example. That's why I wanted to share this.
Solution 1:[1]
I created a concrete example which you can put in your rc.lua and play with it.
local wibox = require('wibox')
local cairo = require("lgi").cairo
local surface = cairo.ImageSurface(cairo.Format.RGB24,20,20)
local cr = cairo.Context(surface)
my_wbox = wibox()
my_wbox.visible = true
my_wbox:set_bg("#ff0000")
cairo_widget = wibox.widget.base.make_widget()
cairo_widget.fit = function(context, width, height)
return 100, 100
end
cairo_widget.draw = function(self, my_wbox, cr, width, height)
cr:translate(100, 100)
cr:set_source_rgb(0,0,0)
cr:rectangle(0, 0, 100, 100)
cr:fill()
end
my_wbox:set_widget(cairo_widget)
my_wbox:geometry({x=50, y=50, width=500, height=500})
Solution 2:[2]
There is https://awesomewm.org/apidoc/documentation/04-new-widgets.md.html, but I guess that page does not have a "here is everything in one copy-able chunk" at the end.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | FluffyDango |
| Solution 2 | Uli Schlachter |
