commit
e065742352
4 changed files with 29 additions and 130 deletions
|
|
@ -270,7 +270,7 @@ PanelWindow {
|
|||
smooth: true
|
||||
cache: false
|
||||
asynchronous: true
|
||||
source: modelData.isCalculator ? "qrc:/icons/calculate.svg" : Quickshell.iconPath(modelData.icon, "")
|
||||
source: modelData.isCalculator ? "qrc:/icons/calculate.svg" : Quickshell.iconPath(modelData.icon, "application-x-executable")
|
||||
visible: modelData.isCalculator || parent.iconLoaded
|
||||
}
|
||||
Text {
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ Item {
|
|||
localWorkspaces.append(ws);
|
||||
}
|
||||
}
|
||||
|
||||
workspaceRepeater.model = localWorkspaces;
|
||||
updateWorkspaceFocus();
|
||||
}
|
||||
|
|
@ -176,9 +177,6 @@ Item {
|
|||
scale: model.isFocused ? 1.0 : 0.9
|
||||
z: 0
|
||||
|
||||
ToolTip.visible: pillMouseArea.containsMouse
|
||||
ToolTip.text: `${model.output}:${model.idx} (ID: ${model.id})`
|
||||
ToolTip.delay: 500
|
||||
MouseArea {
|
||||
id: pillMouseArea
|
||||
anchors.fill: parent
|
||||
|
|
|
|||
|
|
@ -10,14 +10,10 @@ Singleton {
|
|||
|
||||
property var workspaces: []
|
||||
property var windows: []
|
||||
property var outputs: []
|
||||
property int focusedWindowIndex: -1
|
||||
property bool inOverview: false
|
||||
|
||||
// Reactive property for focused window title
|
||||
property string focusedWindowTitle: "(No active window)"
|
||||
|
||||
// Update the focusedWindowTitle whenever relevant properties change
|
||||
function updateFocusedWindowTitle() {
|
||||
if (focusedWindowIndex >= 0 && focusedWindowIndex < windows.length) {
|
||||
focusedWindowTitle = windows[focusedWindowIndex].title || "(Unnamed window)";
|
||||
|
|
@ -25,57 +21,53 @@ Singleton {
|
|||
focusedWindowTitle = "(No active window)";
|
||||
}
|
||||
}
|
||||
// Call updateFocusedWindowTitle on changes
|
||||
|
||||
onWindowsChanged: updateFocusedWindowTitle()
|
||||
onFocusedWindowIndexChanged: updateFocusedWindowTitle()
|
||||
|
||||
Component.onCompleted: {
|
||||
eventStream.running = true;
|
||||
outputsProcess.running = true;
|
||||
}
|
||||
|
||||
|
||||
Process {
|
||||
id: outputsProcess
|
||||
id: workspaceProcess
|
||||
running: false
|
||||
command: ["niri", "msg", "--json", "outputs"]
|
||||
command: ["niri", "msg", "--json", "workspaces"]
|
||||
|
||||
stdout: SplitParser {
|
||||
onRead: function(line) {
|
||||
try {
|
||||
const outputsData = JSON.parse(line);
|
||||
const outputsList = [];
|
||||
const workspacesData = JSON.parse(line);
|
||||
const workspacesList = [];
|
||||
|
||||
// Process each output
|
||||
for (const [connector, data] of Object.entries(outputsData)) {
|
||||
const logical = data.logical || {};
|
||||
outputsList.push({
|
||||
connector: connector,
|
||||
name: data.name || connector,
|
||||
make: data.make || "",
|
||||
model: data.model || "",
|
||||
x: logical.x || 0,
|
||||
y: logical.y || 0,
|
||||
width: logical.width || 1920,
|
||||
height: logical.height || 1080,
|
||||
scale: logical.scale || 1.0,
|
||||
transform: logical.transform || "Normal"
|
||||
for (const ws of workspacesData) {
|
||||
workspacesList.push({
|
||||
id: ws.id,
|
||||
idx: ws.idx,
|
||||
name: ws.name || "",
|
||||
output: ws.output || "",
|
||||
isFocused: ws.is_focused === true,
|
||||
isActive: ws.is_active === true,
|
||||
isUrgent: ws.is_urgent === true,
|
||||
activeWindowId: ws.active_window_id
|
||||
});
|
||||
}
|
||||
|
||||
// Sort outputs by position (left to right, top to bottom)
|
||||
outputsList.sort((a, b) => {
|
||||
if (a.x !== b.x) return a.x - b.x;
|
||||
return a.y - b.y;
|
||||
workspacesList.sort((a, b) => {
|
||||
if (a.output !== b.output) {
|
||||
return a.output.localeCompare(b.output);
|
||||
}
|
||||
return a.id - b.id;
|
||||
});
|
||||
|
||||
root.outputs = outputsList;
|
||||
root.workspaces = workspacesList;
|
||||
} catch (e) {
|
||||
console.error("Failed to parse outputs:", e, line);
|
||||
console.error("Failed to parse workspaces:", e, line);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Process {
|
||||
id: eventStream
|
||||
running: false
|
||||
|
|
@ -85,45 +77,13 @@ Singleton {
|
|||
onRead: data => {
|
||||
try {
|
||||
const event = JSON.parse(data.trim());
|
||||
|
||||
// Handle different event types
|
||||
|
||||
if (event.WorkspacesChanged) {
|
||||
try {
|
||||
const workspacesData = event.WorkspacesChanged.workspaces;
|
||||
const workspacesList = [];
|
||||
|
||||
// Process each workspace
|
||||
for (const ws of workspacesData) {
|
||||
workspacesList.push({
|
||||
id: ws.id,
|
||||
idx: ws.idx,
|
||||
name: ws.name || "",
|
||||
output: ws.output || "",
|
||||
isFocused: ws.is_focused === true,
|
||||
isActive: ws.is_active === true,
|
||||
isUrgent: ws.is_urgent === true,
|
||||
activeWindowId: ws.active_window_id
|
||||
});
|
||||
}
|
||||
|
||||
// Sort workspaces by output name and then by ID
|
||||
workspacesList.sort((a, b) => {
|
||||
if (a.output !== b.output) {
|
||||
return a.output.localeCompare(b.output);
|
||||
}
|
||||
return a.id - b.id;
|
||||
});
|
||||
|
||||
root.workspaces = workspacesList;
|
||||
} catch (e) {
|
||||
console.error("Error parsing workspaces event:", e);
|
||||
}
|
||||
workspaceProcess.running = true;
|
||||
} else if (event.WindowsChanged) {
|
||||
try {
|
||||
const windowsData = event.WindowsChanged.windows;
|
||||
const windowsList = [];
|
||||
|
||||
// Process each window
|
||||
for (const win of windowsData) {
|
||||
windowsList.push({
|
||||
id: win.id,
|
||||
|
|
@ -134,12 +94,8 @@ Singleton {
|
|||
});
|
||||
}
|
||||
|
||||
// Sort windows by ID
|
||||
windowsList.sort((a, b) => a.id - b.id);
|
||||
|
||||
root.windows = windowsList;
|
||||
|
||||
// Find focused window index
|
||||
for (let i = 0; i < windowsList.length; i++) {
|
||||
if (windowsList[i].isFocused) {
|
||||
root.focusedWindowIndex = i;
|
||||
|
|
@ -150,19 +106,7 @@ Singleton {
|
|||
console.error("Error parsing windows event:", e);
|
||||
}
|
||||
} else if (event.WorkspaceActivated) {
|
||||
try {
|
||||
const focusedId = parseInt(event.WorkspaceActivated.id);
|
||||
|
||||
// Update isFocused flag on all workspaces
|
||||
for (let i = 0; i < root.workspaces.length; i++) {
|
||||
// Set isFocused to true only for the activated workspace
|
||||
root.workspaces[i].isFocused = (root.workspaces[i].id === focusedId);
|
||||
}
|
||||
|
||||
root.workspacesChanged();
|
||||
} catch (e) {
|
||||
console.error("Error parsing workspace activation event:", e);
|
||||
}
|
||||
workspaceProcess.running = true;
|
||||
} else if (event.WindowFocusChanged) {
|
||||
try {
|
||||
const focusedId = event.WindowFocusChanged.id;
|
||||
|
|
|
|||
|
|
@ -128,49 +128,6 @@ Singleton {
|
|||
});
|
||||
}
|
||||
|
||||
const tempArray = [];
|
||||
for (let i = 0; i < workspaces.count; i++) {
|
||||
tempArray.push({
|
||||
id: workspaces.get(i).id,
|
||||
idx: workspaces.get(i).idx,
|
||||
name: workspaces.get(i).name,
|
||||
output: workspaces.get(i).output,
|
||||
isActive: workspaces.get(i).isActive,
|
||||
isFocused: workspaces.get(i).isFocused,
|
||||
isUrgent: workspaces.get(i).isUrgent
|
||||
});
|
||||
}
|
||||
|
||||
const outputPositions = {};
|
||||
if (isNiri && Niri.outputs) {
|
||||
for (let i = 0; i < Niri.outputs.length; i++) {
|
||||
const output = Niri.outputs[i];
|
||||
outputPositions[output.connector] = output.x;
|
||||
}
|
||||
}
|
||||
|
||||
tempArray.sort((a, b) => {
|
||||
if (a.output !== b.output) {
|
||||
if (isNiri && Niri.outputs && Niri.outputs.length > 0) {
|
||||
const outputA = Niri.outputs.find(o => o.connector === a.output);
|
||||
const outputB = Niri.outputs.find(o => o.connector === b.output);
|
||||
|
||||
if (outputA && outputB) {
|
||||
return outputA.x - outputB.x;
|
||||
}
|
||||
}
|
||||
|
||||
return a.output.localeCompare(b.output);
|
||||
}
|
||||
|
||||
return a.id - b.id;
|
||||
});
|
||||
|
||||
workspaces.clear();
|
||||
for (let i = 0; i < tempArray.length; i++) {
|
||||
const ws = tempArray[i];
|
||||
workspaces.append(ws);
|
||||
}
|
||||
workspacesChanged();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue