Skip to content

Commit a8587c5

Browse files
authored
Merge pull request #463 from pir0c0pter0/update-niri-auto-tile
Update niri-auto-tile to v1.4.2
2 parents 7ef56c7 + 75558a6 commit a8587c5

17 files changed

Lines changed: 467 additions & 366 deletions

File tree

niri-auto-tile/BarWidget.qml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ Item {
5151
Row {
5252
id: columnIndicator
5353
anchors.centerIn: parent
54-
spacing: 2
54+
spacing: Style.marginXXS
5555
opacity: isEnabled ? 1.0 : 0.35
5656

5757
Repeater {
5858
model: root.maxVisible
5959

6060
Rectangle {
61-
width: 4
61+
width: Math.round(4 * Style.uiScaleRatio)
6262
height: root.capsuleHeight * 0.5
63-
radius: 1
63+
radius: Style.radiusXXXS
6464
color: mouseArea.containsMouse ? Color.mOnHover : Color.mOnSurface
6565
}
6666
}
@@ -71,10 +71,10 @@ Item {
7171
Rectangle {
7272
anchors.bottom: visualCapsule.bottom
7373
anchors.horizontalCenter: visualCapsule.horizontalCenter
74-
anchors.bottomMargin: 1
75-
width: 4
76-
height: 4
77-
radius: 2
74+
anchors.bottomMargin: Style.marginXXXS
75+
width: Math.round(4 * Style.uiScaleRatio)
76+
height: Math.round(4 * Style.uiScaleRatio)
77+
radius: Math.round(2 * Style.uiScaleRatio)
7878
visible: isEnabled
7979
color: isRunning ? Color.mPrimary : Color.mSecondary
8080
}
@@ -86,13 +86,13 @@ Item {
8686
var items = [];
8787
items.push({
8888
"label": isEnabled
89-
? (pluginApi?.tr("bar.disable") ?? "Disable Auto-Tile")
90-
: (pluginApi?.tr("bar.enable") ?? "Enable Auto-Tile"),
89+
? pluginApi?.tr("bar.disable")
90+
: pluginApi?.tr("bar.enable"),
9191
"action": "toggle",
9292
"icon": isEnabled ? "player-pause" : "player-play"
9393
});
9494
items.push({
95-
"label": pluginApi?.tr("bar.settings") ?? "Settings",
95+
"label": pluginApi?.tr("bar.settings"),
9696
"action": "widget-settings",
9797
"icon": "flask"
9898
});

niri-auto-tile/Main.qml

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Item {
1919
readonly property int maxEventsPerSecond: pluginApi?.pluginSettings?.maxEventsPerSecond ?? 20
2020

2121
readonly property string scriptPath: (pluginApi?.pluginDir ?? "") + "/auto-tile.py"
22+
readonly property string configFilePath: (pluginApi?.pluginDir ?? "/tmp") + "/runtime-config.json"
2223

2324
// Serialize workspace config as JSON string for CLI
2425
function workspaceConfigJson() {
@@ -37,15 +38,15 @@ Item {
3738
}
3839

3940
onMaxVisibleChanged: {
40-
if (running) restartDaemon();
41+
if (running) hotReloadConfig();
4142
}
4243

4344
onPerWorkspaceChanged: {
44-
if (running) restartDaemon();
45+
if (running) hotReloadConfig();
4546
}
4647

4748
onOnlyAtMaxChanged: {
48-
if (running) restartDaemon();
49+
if (running) hotReloadConfig();
4950
}
5051

5152
Component.onCompleted: {
@@ -72,6 +73,21 @@ Item {
7273
stopDaemon();
7374
}
7475

76+
function hotReloadConfig() {
77+
// Build command with current values, then write config + send SIGUSR1
78+
const config = JSON.stringify({
79+
maxVisible: maxVisible,
80+
onlyAtMax: onlyAtMax,
81+
perWorkspace: perWorkspace,
82+
workspaceMaxVisible: workspaceMaxVisible
83+
});
84+
configWriter.command = [
85+
"bash", "-c",
86+
"echo '" + config + "' > " + configFilePath
87+
];
88+
configWriter.running = true;
89+
}
90+
7591
function setMaxVisible(count) {
7692
if (count < 1 || count > 8) return;
7793
if (!pluginApi?.pluginSettings) return;
@@ -89,7 +105,7 @@ Item {
89105
updated[String(wsId)] = count;
90106
pluginApi.pluginSettings.workspaceMaxVisible = updated;
91107
pluginApi.saveSettings();
92-
if (running) restartDaemon();
108+
if (running) hotReloadConfig();
93109
}
94110

95111
function setPerWorkspace(value) {
@@ -114,13 +130,25 @@ Item {
114130
return maxVisible;
115131
}
116132

133+
readonly property Process configWriter: Process {
134+
running: false
135+
136+
onExited: {
137+
// Config file written, now send SIGUSR1 to daemon
138+
if (root.running) {
139+
root.daemonProcess.signal(10); // SIGUSR1
140+
}
141+
}
142+
}
143+
117144
readonly property Process daemonProcess: Process {
118145
command: {
119146
const args = [
120147
"python3", root.scriptPath,
121148
"--max-visible", String(root.maxVisible),
122149
"--debounce", String(root.debounceMs / 1000.0),
123-
"--max-events", String(root.maxEventsPerSecond)
150+
"--max-events", String(root.maxEventsPerSecond),
151+
"--config-file", root.configFilePath
124152
];
125153
if (root.onlyAtMax) {
126154
args.push("--only-at-max");

niri-auto-tile/Panel.qml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Item {
9797
}
9898

9999
NText {
100-
text: pluginApi?.tr("panel.title") ?? "Column Layout"
100+
text: pluginApi?.tr("panel.title")
101101
pointSize: Style.fontSizeL
102102
font.bold: true
103103
color: Color.mOnSurface
@@ -135,12 +135,12 @@ Item {
135135

136136
Layout.fillWidth: true
137137
Layout.fillHeight: true
138-
Layout.minimumHeight: 50
138+
Layout.minimumHeight: Math.round(50 * Style.uiScaleRatio)
139139

140140
radius: Style.iRadiusM
141141
color: isSelected ? Qt.alpha(Color.mPrimary, 0.15) : Color.mSurfaceVariant
142142
border.color: isSelected ? Color.mPrimary : (optionMouse.containsMouse ? Color.mOutline : "transparent")
143-
border.width: isSelected ? 2 : 1
143+
border.width: isSelected ? Style.borderM : Style.borderS
144144

145145
Behavior on color { ColorAnimation { duration: Style.animationFast } }
146146
Behavior on border.color { ColorAnimation { duration: Style.animationFast } }
@@ -157,18 +157,18 @@ Item {
157157

158158
Row {
159159
anchors.centerIn: parent
160-
spacing: 3
160+
spacing: Style.marginXXS
161161

162162
Repeater {
163163
model: layoutOption.columnCount
164164

165165
Rectangle {
166166
width: {
167-
const available = layoutOption.width - Style.marginS * 2 - (layoutOption.columnCount - 1) * 3;
168-
return Math.max(8, available / layoutOption.columnCount);
167+
const available = layoutOption.width - Style.marginS * 2 - (layoutOption.columnCount - 1) * Style.marginXXS;
168+
return Math.max(Math.round(8 * Style.uiScaleRatio), available / layoutOption.columnCount);
169169
}
170170
height: layoutOption.height * 0.45
171-
radius: 3
171+
radius: Style.iRadiusXXXS
172172
color: layoutOption.isSelected
173173
? Color.mPrimary
174174
: (optionMouse.containsMouse ? Qt.alpha(Color.mOnSurface, 0.4) : Qt.alpha(Color.mOnSurface, 0.25))
@@ -183,8 +183,8 @@ Item {
183183
NText {
184184
Layout.alignment: Qt.AlignHCenter
185185
text: layoutOption.columnCount === 1
186-
? (pluginApi?.tr("panel.single") ?? "Single")
187-
: (pluginApi?.tr("panel.columns") ?? "%1 Columns").arg(layoutOption.columnCount)
186+
? pluginApi?.tr("panel.single")
187+
: pluginApi?.tr("panel.columns", {"count": layoutOption.columnCount})
188188
pointSize: Style.fontSizeS
189189
font.bold: layoutOption.isSelected
190190
color: layoutOption.isSelected ? Color.mPrimary : Color.mOnSurface
@@ -211,9 +211,9 @@ Item {
211211
spacing: Style.marginS
212212

213213
Rectangle {
214-
width: 8
215-
height: 8
216-
radius: 4
214+
width: Math.round(8 * Style.uiScaleRatio)
215+
height: Math.round(8 * Style.uiScaleRatio)
216+
radius: Math.round(4 * Style.uiScaleRatio)
217217
color: {
218218
if (!root.isEnabled) return Color.mOutline;
219219
if (root.isRunning) return Color.mPrimary;
@@ -223,15 +223,14 @@ Item {
223223

224224
NText {
225225
text: {
226-
if (!root.isEnabled) return pluginApi?.tr("panel.status-disabled") ?? "Disabled";
226+
if (!root.isEnabled) return pluginApi?.tr("panel.status-disabled");
227227
if (root.isRunning) {
228-
const label = (pluginApi?.tr("panel.status-active") ?? "Active — %1 columns").arg(root.currentMaxVisible);
229228
if (root.perWorkspace && root.currentWorkspaceId > 0) {
230-
return label + " (WS " + root.currentWorkspaceId + ")";
229+
return pluginApi?.tr("panel.status-active-ws", {"count": root.currentMaxVisible, "ws": root.currentWorkspaceId});
231230
}
232-
return label;
231+
return pluginApi?.tr("panel.status-active", {"count": root.currentMaxVisible});
233232
}
234-
return pluginApi?.tr("panel.status-starting") ?? "Starting...";
233+
return pluginApi?.tr("panel.status-starting");
235234
}
236235
pointSize: Style.fontSizeS
237236
color: Qt.alpha(Color.mOnSurface, 0.6)

0 commit comments

Comments
 (0)