mirror of
https://github.com/JakeStanger/ironbar.git
synced 2026-07-11 07:15:19 +01:00
[PR #497] [MERGED] feat: new cairo module #3573
Labels
No labels
A:Build
A:CI
A:Client
A:Config
A:Core
A:Documentation
A:Documentation
A:IPC
A:Testing
A:UX/UI
blocked
BREAKING CHANGE
duplicate
good first issue
GTK4
help wanted
invalid
M:Battery
M:Battery
M:Bindmode
M:Bluetooth
M:Brightness
M:Cairo
M:Clipboard
M:Clock
M:Clock
M:Custom
M:Focused
M:Keyboard
M:Launcher
M:Menu
M:Music
M:Music
M:Music
M:Network Manager
M:Notifications
M:SysInfo
M:Tray
M:Volume
M:Workspaces
partially resolved
P:Critical
P:High
P:Low
P:Medium
pull-request
T:Bug
T:Bug
T:Core Enhancement
T:Module Enhancement
T:New Module
T:Question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
JakeStanger/ironbar#3573
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/JakeStanger/ironbar/pull/497
Author: @JakeStanger
Created: 3/14/2024
Status: ✅ Merged
Merged: 4/17/2024
Merged by: @JakeStanger
Base:
master← Head:feat/cairo📝 Commits (4)
7b08949build: remove some unused features/depsb0a05b7feat: new cairo module653d1d6ci(setup): add luajit depa62010ebuild(nix): add luajit and lgi support📊 Changes
17 files changed (+621 additions, -23 deletions)
View changed files
📝
.github/scripts/ubuntu_setup.sh(+2 -1)📝
Cargo.lock(+54 -2)📝
Cargo.toml(+8 -0)📝
docs/Compiling.md(+3 -2)📝
docs/_Sidebar.md(+1 -0)➕
docs/modules/Cairo.md(+215 -0)📝
flake.nix(+6 -0)➕
lua/draw.lua(+4 -0)➕
lua/init.lua(+4 -0)📝
nix/default.nix(+26 -3)📝
shell.nix(+2 -0)➕
src/clients/lua.rs(+41 -0)📝
src/clients/mod.rs(+13 -0)📝
src/config/mod.rs(+6 -0)📝
src/main.rs(+36 -15)➕
src/modules/cairo.rs(+198 -0)📝
src/modules/mod.rs(+2 -0)📄 Description
This is an early working draft of the Cairo module, which allows you to write custom Lua scripts to draw whatever you like to a region of the bar. It's pretty rough around the edges but just about good enough to start playing with.
Currently this cannot be used in popups, however that will change fairly soon once #131 is resolved (that's been brought forward specifically because of this).
You need LuaJIT installed along with the LGI package (
lua-lgion Arch). This needs to be installed to theLUA_PATHandLUA_CPATHrespectively. If installing system-wide, this should Just Werk as it's in/usr.I have played around with the idea of vendoring but suspect I will need to write bindings to statically link
lua-lgiand its scripts into the Ironbar binary, so unless anybody has any better ideas we'll roll with it like this for now.Example usage
In your config you can define eg:
Where:
path- path to Lua scriptintervalnumber of milliseconds between updateswidth- canvas widthheight- canvas heightGTK's sizing rules mean if the canvas height (or width for vertical bars) is less than the bar height, it will automatically expand to the bar height.
At the specified path, define a Lua script. The script must contain a function called
draw, which takes the Cairo context as a parameter. Other than that, you have free reign.You can optionally create an
init.luafile in your config directory, which is executed once on bar startup. This can house any required initialization code, as well as shared functions.The most basic example, which draws a red square, can be shown below:
A more complex example is included on the wiki page.
OLD
Currently there are some hard rules you need to keep in mind:local cr = cairo.Context(ptr)to get a usable object.0.cairoglobal is available everywhere. This gives full access to the Cairo library, although some constructors may not work yet.I've included a proof-of-concept example script below, which results in a kinda nifty clock I wrote for Conky about 5 years ago.
OLD Lua script
I want to try and polish this up and sort most of those gotchas out before this gets merged. Any and all help/ideas welcome.
Resolves #105
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.