guys there is a json option actually for hyprctl

This commit is contained in:
Kopatz
2025-08-26 12:56:34 +02:00
parent da9967728b
commit 3ee59d16fb
2 changed files with 58 additions and 16 deletions

View File

@@ -28,23 +28,14 @@ async function execCommand(command) {
}
/** @type(String) */
let result = await execCommand('hyprctl monitors all');
let monitors = {};
let currentMonitor = null;
result.split('\n').forEach(line => {
if (line.includes('Monitor')) {
let parts = line.split(' ');
let name = parts[1];
monitors[name] = { name };
currentMonitor = name;
}
if (line.includes('availableModes:')) {
line = line.trim();
let start = line.indexOf(":") + 2;
let modes = line.substring(start).split(' ');
monitors[currentMonitor].availableModes = modes;
}
let result = await execCommand('hyprctl -j monitors all');
result = JSON.parse(result);
result.forEach(monitor => {
monitors[monitor.name] = {
name: monitor.name,
availableModes: monitor.availableModes
};
});
console.log(monitors);
let zenity_monitors = Object.keys(monitors).join(' \\\n');