Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/IdleMonitors.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Scope {
else if (action === "unlock")
lock.lock.locked = false;
else if (typeof action === "string")
Hypr.dispatch(action);
Hypr.dispatch(Hypr.usingLua && ["dpms off", "dpms on"].includes(action) ? `hl.dsp.dpms({ action = "${action === "dpms off" ? "disable" : "enable"}" })` : action);
else
Quickshell.execDetached(action);
}
Expand Down
4 changes: 2 additions & 2 deletions modules/bar/Bar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ ColumnLayout {
const mon = (GlobalConfig.bar.workspaces.perMonitorWorkspaces ? Hypr.monitorFor(screen) : Hypr.focusedMonitor);
const specialWs = mon?.lastIpcObject.specialWorkspace.name;
if (specialWs?.length > 0)
Hypr.dispatch(`togglespecialworkspace ${specialWs.slice(8)}`);
Hypr.dispatch(Hypr.usingLua ? `hl.dsp.workspace.toggle_special("${specialWs.slice(8)}")` : `togglespecialworkspace ${specialWs.slice(8)}`);
else if (angleDelta.y < 0 || (GlobalConfig.bar.workspaces.perMonitorWorkspaces ? mon.activeWorkspace?.id : Hypr.activeWsId) > 1)
Hypr.dispatch(`workspace r${angleDelta.y > 0 ? "-" : "+"}1`);
Hypr.dispatch(Hypr.usingLua ? `hl.dsp.focus({ workspace = "r${angleDelta.y > 0 ? "-" : "+"}1" })` : `workspace r${angleDelta.y > 0 ? "-" : "+"}1`);
} else if (y < screen.height / 2 && Config.bar.scrollActions.volume) {
// Volume scroll on top half
if (angleDelta.y > 0)
Expand Down
4 changes: 2 additions & 2 deletions modules/bar/components/workspaces/SpecialWorkspaces.qml
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ Item {

const ws = view.itemAt(event.x, event.y) as SpecialWsDelegate;
if (ws?.modelData)
Hypr.dispatch(`togglespecialworkspace ${ws.modelData.name.slice(8)}`);
Hypr.dispatch(Hypr.usingLua ? `hl.dsp.workspace.toggle_special("${ws.modelData.name.slice(8)}")` : `togglespecialworkspace ${ws.modelData.name.slice(8)}`);
else
Hypr.dispatch("togglespecialworkspace special");
Hypr.dispatch(Hypr.usingLua ? 'hl.dsp.workspace.toggle_special("special")' : "togglespecialworkspace special");
}
}

Expand Down
6 changes: 4 additions & 2 deletions modules/bar/components/workspaces/Workspaces.qml
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ StyledClippingRect {
anchors.fill: layout
onClicked: event => {
const ws = (layout.childAt(event.x, event.y) as Workspace)?.ws;
if (!ws)
return;
if (Hypr.activeWsId !== ws)
Hypr.dispatch(`workspace ${ws}`);
Hypr.dispatch(Hypr.usingLua ? `hl.dsp.focus({ workspace = "${ws}" })` : `workspace ${ws}`);
else
Hypr.dispatch("togglespecialworkspace special");
Hypr.dispatch(Hypr.usingLua ? 'hl.dsp.workspace.toggle_special("special")' : "togglespecialworkspace special");
}
}

Expand Down
8 changes: 4 additions & 4 deletions modules/windowinfo/Buttons.qml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ ColumnLayout {
readonly property bool isCurrent: root.client?.workspace.id === wsId

onClicked: {
Hypr.dispatch(`movetoworkspace ${wsId},address:0x${root.client?.address}`);
Hypr.dispatch(Hypr.usingLua ? `hl.dsp.window.move({ window = "address:0x${root.client?.address}", workspace = "${wsId}", follow = true })` : `movetoworkspace ${wsId},address:0x${root.client?.address}`);
}

color: isCurrent ? Colours.tPalette.m3surfaceContainerHighest : Colours.palette.m3tertiaryContainer
Expand All @@ -118,7 +118,7 @@ ColumnLayout {
color: Colours.palette.m3secondaryContainer
onColor: Colours.palette.m3onSecondaryContainer
text: root.client?.lastIpcObject.floating ? qsTr("Tile") : qsTr("Float")
onClicked: Hypr.dispatch(`togglefloating address:0x${root.client?.address}`)
onClicked: Hypr.dispatch(Hypr.usingLua ? `hl.dsp.window.float({ window = "address:0x${root.client?.address}" })` : `togglefloating address:0x${root.client?.address}`)
}

Loader {
Expand All @@ -132,15 +132,15 @@ ColumnLayout {
color: Colours.palette.m3secondaryContainer
onColor: Colours.palette.m3onSecondaryContainer
text: root.client?.lastIpcObject.pinned ? qsTr("Unpin") : qsTr("Pin")
onClicked: Hypr.dispatch(`pin address:0x${root.client?.address}`)
onClicked: Hypr.dispatch(Hypr.usingLua ? `hl.dsp.window.pin({ window = "address:0x${root.client?.address}" })` : `pin address:0x${root.client?.address}`)
}
}

Button {
color: Colours.palette.m3errorContainer
onColor: Colours.palette.m3onErrorContainer
text: qsTr("Kill")
onClicked: Hypr.dispatch(`killwindow address:0x${root.client?.address}`)
onClicked: Hypr.dispatch(Hypr.usingLua ? `hl.dsp.window.kill({ window = "address:0x${root.client?.address}" })` : `killwindow address:0x${root.client?.address}`)
}
}

Expand Down
9 changes: 8 additions & 1 deletion plugin/src/Caelestia/Internal/hyprextras.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,14 @@ void HyprExtras::applyOptions(const QVariantHash& options) {
request.reserve(12 + options.size() * 40);
request += QLatin1String("[[BATCH]]");
for (auto it = options.constBegin(); it != options.constEnd(); ++it) {
request += QLatin1String("keyword ") + it.key() + QLatin1Char(' ') + it.value().toString() + QLatin1Char(';');
if (!m_usingLua) {
request +=
QLatin1String("keyword ") + it.key() + QLatin1Char(' ') + it.value().toString() + QLatin1Char(';');
} else {
auto parts = it.key().split(':');
request += "eval hl.config({ " + parts.join(" = { ") + " = " + it.value().toString() +
QString(" }").repeated(parts.size() - 1) + " });";
}
}

makeRequest(request, [this](bool success, const QByteArray& res) {
Expand Down
3 changes: 3 additions & 0 deletions plugin/src/Caelestia/Internal/hyprextras.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class HyprExtras : public QObject {

Q_PROPERTY(QVariantHash options READ options NOTIFY optionsChanged)
Q_PROPERTY(caelestia::internal::hypr::HyprDevices* devices READ devices CONSTANT)
Q_PROPERTY(bool usingLua MEMBER m_usingLua NOTIFY usingLuaChanged)

public:
explicit HyprExtras(QObject* parent = nullptr);
Expand All @@ -33,6 +34,7 @@ class HyprExtras : public QObject {

signals:
void optionsChanged();
void usingLuaChanged();

private:
using SocketPtr = QSharedPointer<QLocalSocket>;
Expand All @@ -41,6 +43,7 @@ class HyprExtras : public QObject {
QString m_eventSocket;
QLocalSocket* m_socket;
bool m_socketValid;
bool m_usingLua = false;

QVariantHash m_options;
HyprDevices* const m_devices;
Expand Down
9 changes: 7 additions & 2 deletions services/Colours.qml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,13 @@ Singleton {
}

function reloadHyprRules(): void {
const str = "keyword layerrule %1 %2, match:namespace caelestia-drawers";
Hypr.extras.batchMessage([str.arg("blur").arg(transparency.enabled ? 1 : 0), str.arg("ignore_alpha").arg(transparency.base - 0.03)]);
if (Hypr.usingLua) {
const rule = `eval hl.layer_rule({ match = { namespace = "caelestia-drawers" }, %1 })`;
Hypr.extras.batchMessage([rule.arg(`blur = ${transparency.enabled}`), rule.arg(`ignore_alpha = ${transparency.base - 0.03}`)]);
} else {
const str = "keyword layerrule %1 %2, match:namespace caelestia-drawers";
Hypr.extras.batchMessage([str.arg("blur").arg(transparency.enabled ? 1 : 0), str.arg("ignore_alpha").arg(transparency.base - 0.03)]);
}
}

function requestReloadHyprRules(): void {
Expand Down
15 changes: 11 additions & 4 deletions services/Hypr.qml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Singleton {
readonly property var toplevels: Hyprland.toplevels
readonly property var workspaces: Hyprland.workspaces
readonly property var monitors: Hyprland.monitors
readonly property bool usingLua: Hyprland.usingLua

readonly property HyprlandToplevel activeToplevel: {
const t = Hyprland.activeToplevel;
Expand Down Expand Up @@ -57,11 +58,11 @@ Singleton {
if (lastSpecialWorkspace) {
const workspace = workspaces.values.find(w => w.name === lastSpecialWorkspace);
if (workspace && workspace.lastIpcObject.windows > 0) {
dispatch(`workspace ${lastSpecialWorkspace}`);
dispatch(usingLua ? `hl.dsp.focus({ workspace = "${lastSpecialWorkspace}" })` : `workspace ${lastSpecialWorkspace}`);
return;
}
}
dispatch(`workspace ${openSpecials[0].name}`);
dispatch(usingLua ? `hl.dsp.focus({ workspace = "${openSpecials[0].name}" })` : `workspace ${openSpecials[0].name}`);
return;
}

Expand All @@ -75,7 +76,7 @@ Singleton {
nextIndex = (currentIndex - 1 + openSpecials.length) % openSpecials.length;
}

dispatch(`workspace ${openSpecials[nextIndex].name}`);
dispatch(usingLua ? `hl.dsp.focus({ workspace = "${openSpecials[nextIndex].name}" })` : `workspace ${openSpecials[nextIndex].name}`);
}

function monitorNames(): list<string> {
Expand All @@ -87,7 +88,11 @@ Singleton {
}

function reloadDynamicConfs(): void {
extras.batchMessage(["keyword bindlni ,Caps_Lock,global,caelestia:refreshDevices", "keyword bindlni ,Num_Lock,global,caelestia:refreshDevices"]);
if (usingLua) {
extras.batchMessage(['eval hl.bind("Caps_Lock", hl.dsp.global("caelestia:refreshDevices"), { locked = true, non_consuming = true, ignore_mods = true, release = true })', 'eval hl.bind("Num_Lock", hl.dsp.global("caelestia:refreshDevices"), { locked = true, non_consuming = true, ignore_mods = true, release = true })']);
} else {
extras.batchMessage(["keyword bindlni ,Caps_Lock,global,caelestia:refreshDevices", "keyword bindlni ,Num_Lock,global,caelestia:refreshDevices"]);
}
}

Component.onCompleted: reloadDynamicConfs()
Expand Down Expand Up @@ -218,5 +223,7 @@ Singleton {

HyprExtras {
id: extras

usingLua: Hyprland.usingLua
}
}