Add iio-lock plugin for orientation locking (#13)

* Made a iio-hyprland plugin for noctalia
kill iio-hyprland and restart it depending on the locked setting.

The plugin has:
-control center toggle
-Bar wigdet for toggle of state
--If rigth clicked this wigdet will open the panel
-Panel for calling by msg
--Panel also added possibally to specify lock direction
-Bar wiget for open panel
--Useful for touch

- Tested with hyprland 0.55.4 and noctalia v5.0.0
- Should work with sway using iio-sway (not tested)

* add en.json to translation
unify settings keys for consistent naming
update names
add iio-service so tools work independently
refactor code for readability and remove unused logic
update readme
add thumbnail

* Updated plugin.toml names
Reworked panel code

* bump version

* Make arrow buttons apply relative orientation instead of fixed original
directions

* fixed wrong labels

* Delete iio_lock/iio_lock.luau

* Delete iio_lock/iio_panel.luau

* Delete iio_lock/shortcut.luau

* make noctalia.getConfig the sole config accessor

---------

Co-authored-by: Lemmy <studio@quadbyte.net>
This commit is contained in:
Nikolaj Holck Zwergius
2026-07-15 00:27:58 -04:00
committed by GitHub
co-authored by Lemmy
parent 2d637f9651
commit ae06d34fcb
9 changed files with 415 additions and 0 deletions
+136
View File
@@ -0,0 +1,136 @@
--!nonstrict
--config
local used_vm = noctalia.getConfig("vm")
local transform_order_string = noctalia.getConfig("transform-order")
local transform_order = {}
local function set_transform_order(order_string)
local index = 0
for i in string.gmatch(order_string, "%d+") do
transform_order[index] = tonumber(i)
index += 1
end
end
set_transform_order(transform_order_string)
--vm functions
function hl(value,screen)
screen = screen or "eDP-1"
local cmd = string.format([[hyprctl eval 'hl.monitor({ output = "%s", transform = %d })']], screen, value)
noctalia.runAsync(cmd)
cmd = string.format([[hyprctl eval 'hl.config({input = {touchdevice = { transform = %d },tablet= { transform = %d }}})']],value,value)
noctalia.runAsync(cmd)
cmd = string.format([[hyprctl eval 'hl.workspace_rule({workspace = "m[%s]"})']],screen)
noctalia.runAsync(cmd)
end
function sw(value,screen)
screen = screen or "eDP-1"
local cmd = string.format("swaymsg \"output %s transform %d\"",screen,value)
noctalia.runAsync(cmd)
end
local wm = {
hyprland = hl,
sway = sw,
}
--render and layout
local function section(title, control)
return ui.column({ gap = 8 }, {
ui.label({ text = title, fontWeight = "medium", color = "on_surface_variant" }),
control,
})
end
local function render()
panel.render(ui.column({ flexGrow = 1, gap = 12 }, {
ui.row({ align = "center", justify = "space_between", gap = 12 }, {
ui.label({ text = noctalia.tr("panel.title"), fontSize = 16, fontWeight = "bold", color = "on_surface", flexGrow = 1 }),
ui.button({ glyph = "close", onClick = "onCloseClicked" }),
}),
section("", ui.column({ gap = 12, align = "center" }, {
ui.button({width = 60 , height=100, onClick = "onUp",glyph="arrow-big-up-filled",glyphSize=50}),
section("", ui.row({ gap = 12, align = "center" }, {
ui.button({width = 100 , height=60, onClick = "onLeft",glyph="arrow-big-left-filled",glyphSize=50}),
ui.button({width = 100 , height=60, onClick = "onLock",glyph="lock",glyphSize=50}),
ui.button({width = 100 , height=60, onClick = "onRight",glyph="arrow-big-right-filled",glyphSize=50})
})),
ui.button({width = 60 , height=100, onClick = "onDown",glyph="arrow-big-down-filled",glyphSize=50}),
})),
}))
end
--actions
function onOpen(_context)
render()
end
function onLock()
local locked = noctalia.state.get("iio-state")
noctalia.state.set("iio-state",not locked)
panel.close()
end
function onUp()
wm[used_vm](transform_order[0])
noctalia.state.set("iio-state",true)
set_transform_order(table.concat({
transform_order[0],
transform_order[1],
transform_order[2],
transform_order[3],
}, ","))
panel.close()
end
function onLeft()
wm[used_vm](transform_order[1])
noctalia.state.set("iio-state",true)
set_transform_order(table.concat({
transform_order[1],
transform_order[2],
transform_order[3],
transform_order[0],
}, ","))
panel.close()
end
function onDown()
wm[used_vm](transform_order[2])
noctalia.state.set("iio-state",true)
set_transform_order(table.concat({
transform_order[2],
transform_order[3],
transform_order[0],
transform_order[1],
}, ","))
panel.close()
end
function onRight()
wm[used_vm](transform_order[3])
noctalia.state.set("iio-state",true)
set_transform_order(table.concat({
transform_order[3], --up
transform_order[0], --left
transform_order[1], --rig
transform_order[2], --down
}, ","))
panel.close()
end
function onCloseClicked()
panel.close()
end
noctalia.state.watch("iio-state", function (value)
if not value then
set_transform_order(transform_order_string)
end
end)