Skip to content

Commit

Permalink
Merge pull request #27 from codyduong/dev
Browse files Browse the repository at this point in the history
* Adds label widget
* Perf improvements
  * Resolves #24 
* Adds initial work for unsafe.reactive
  • Loading branch information
codyduong authored Aug 10, 2024
2 parents e4c5855 + 61adf3f commit d4cbd31
Show file tree
Hide file tree
Showing 37 changed files with 1,641 additions and 355 deletions.
18 changes: 18 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ features = [
"async",
"unstable",
"send",
"macros"
]

[workspace.dependencies.lua-src]
Expand Down
30 changes: 22 additions & 8 deletions example/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ local monitors = hitokage.monitor.get_all()
--- @type BarArray
local bars = {}

local reactives = {}

for _, monitor in ipairs(monitors) do
if monitor.model == "LG SDQHD" then
goto continue
Expand All @@ -17,6 +19,9 @@ for _, monitor in ipairs(monitors) do
-- }
-- })

local reactive_format = hitokage.unsafe.reactive.create("%a %b %u %r")
table.insert(reactives, reactive_format)

table.insert(
bars,
hitokage.bar.create(monitor, {
Expand All @@ -26,13 +31,11 @@ for _, monitor in ipairs(monitors) do
widgets = {
{
Box = {
widgets = {},
class = "red",
},
},
{
Box = {
widgets = {},
class = "green",
},
},
Expand All @@ -44,11 +47,13 @@ for _, monitor in ipairs(monitors) do
},
{
Box = {
widgets = {},
class = {
"red",
"green",
"blue",
class = { "red", "green blue" },
widgets = {
{
Label = {
label = "foo",
},
},
},
},
},
Expand All @@ -57,7 +62,7 @@ for _, monitor in ipairs(monitors) do
},
-- { Box = {} },
{ Workspace = { halign = "Center", item_height = 22, item_width = 22 } },
{ Clock = { format = "%a %b %u %r", halign = "End" } },
{ Clock = { format = reactive_format, halign = "End" } },
},
width = monitor.geometry.width - 16,
offset = {
Expand Down Expand Up @@ -143,4 +148,13 @@ local css_boxes_test = hitokage.timeout(0, function()
end
end)

local clockers = hitokage.timeout(500, function()
local current_format = reactives[1]:get()
if current_format == "%a %b %u %r" then
reactives[1]:set("reactive demo")
else
reactives[1]:set("%a %b %u %r")
end
end)

-- hitokage.dispatch(css_boxes_test)
2 changes: 2 additions & 0 deletions hitokage-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ komorebi-client = {workspace = true}
win32-display-data = { workspace = true }
chrono = "0.4.38"
indexmap = { version = "2.3.0", features = ["serde"] }
rustc-hash = "2.0.0"
serde-value = "0.7.0"

[dependencies.windows]
workspace = true
Expand Down
Loading

0 comments on commit d4cbd31

Please sign in to comment.