其基本思想就像平铺窗口管理器,具有固定相同的网格系统。
我不希望窗口堆积在同一个桌面(工作区)。
我们可以拥有一个巨大的虚拟桌面,例如设置 4x4(=16) 个工作区,并且每次启动窗口时都会在每个工作区中放置一个新窗口。使用 Unity-Expo,它的行为就像缩放的平铺窗口/桌面。
如果有空的工作区,新启动的窗口会被推送到那里,如果工作区已满,它会堆积在一些已经使用的工作区上,等等。
当然,我知道有统一的ScaleWindows / WindowPicker,但它只是一个选择器或堆叠窗口的展示,并且根据情况,它们每次在缩放级别和位置上出现的非常不同。
有人知道实现这一目标的方法,或者有任何可用的插件吗?
谢谢。
答案1
好的,我自己开发了一个。
var log = console.log;
var exec = require('child_process').exec;
var spawn = require('child_process').spawn;
var lq = require('linq');
var wlist = [];
var wIDlist0 = lq.empty();
var wIDlist = lq.empty();
var wIDlistD = lq.empty();
var wIDlistE = lq.empty();
var sw;
var sh;
var tw;
var th;
var nx;
var ny;
var nxy;
var vx;
var vy;
var wused = [];
var firstrun = true;
var c1 = exec("xrandr | grep Screen | awk '{ print $8 }'", function (err, stdout, stderr)
{
sw = stdout * 1;
var c2 = exec("xrandr | grep Screen | awk '{ print $10 }' | cut -d ',' -f1", function (err, stdout, stderr)
{
sh = stdout * 1;
var c3 = exec("wmctrl -d | awk '{ print $4 }' | cut -d 'x' -f1", function (err, stdout, stderr)
{
tw = stdout * 1;
var c4 = exec("wmctrl -d | awk '{ print $4 }' | cut -d 'x' -f2", function (err, stdout, stderr)
{
th = stdout * 1;
console.log(sw);
console.log(sh);
console.log(tw);
console.log(th);
nx = tw / sw;
ny = th / sh;
nxy = nx * ny;
console.log(nx);
console.log(ny);
console.log(nxy);
main();
})
})
})
})
var main = function ()
{
setInterval(f1, 250);
}
var f1 = function ()
{
var c5 = exec("wmctrl -d | awk '{ print $6 }' | cut -d ',' -f1", function (err, stdout, stderr)
{
vx = stdout * 1;
var c6 = exec("wmctrl -d | awk '{ print $6 }' | cut -d ',' -f2", function (err, stdout, stderr)
{
vy = stdout * 1;
f2();
})
})
var f2 = function ()
{
var listWindows = spawn('wmctrl', ['-l', '-G', '-x']);
listWindows.stdout.on('data', function (data)
{
wIDlist = lq.empty();
// wlist = [];
var dataS = '' + data;
var wlistA = dataS.split('\n');
lq.from(wlistA)
.forEach(function (x)
{
// log(x);
var sA = x.split(/\s+/g);
var id = sA[0];
if (sA[1] == '0')
if (sA[6] != 'N/A')
{
// log(x);
wIDlist = wIDlist.union([id]);
wlist[id] = [sA[2], sA[3], sA[4], sA[5]];
}
});
wIDlistD = wIDlist.except(wIDlist0);
wIDlistE = wIDlist.except(wIDlistD);
wIDlist0 = wIDlist;
log(wIDlistD.toArray());
var wcount = wIDlistD.toLookup().count();
log(wcount);
log('------------------');
if (firstrun)
{
wcount = 0;
firstrun = false;
}
if (wcount > 0) //new windows
{
//-------------------
for (var i = 1; i <= nxy; i++)
{
wused[i] = false;
}
wIDlistE.forEach(function (id)
{
var g = wlist[id];
var x = g[0] * 1;// log(x);
var y = g[1] * 1;//log(y);
var w = g[2] * 1;//log(w);
var h = g[3] * 1;//log(h);
var cx = (vx + x + w / 2 + tw) % tw;
var cy = (vy + y + h / 2 + th) % th;
var wx = Math.floor(cx / sw);
var wy = Math.floor(cy / sh);
console.log('@@-----------');
console.log('@@' + wx);
console.log('@@' + wy);
var n = wy * ny + wx + 1;
wused[n] = true;
});
var filled = true;
for (var j = 1; j <= nxy; j++)
{
log(wused[j]);
if (wused[j] == false)
filled = false;
}
//-------------
if (filled == false)
{
wIDlistD.forEach(function (id)
{
var loop = true;
var i = 1;
while (loop)
{
if (wused[i] == false)
{
wused[i] = true;
var x1 = (i - 1) % nx;
log('!!!' + x1);
var y1 = Math.floor((i - 1) / nx);
log('!!!' + y1);
var px = (x1 * sw + 200 - vx + tw) % tw;
var py = (y1 * sh + 200 - vy + th) % th;
log(px);
log(py);
var c = spawn('wmctrl', ['-ir', id, '-e', '0' + ',' + px + ',' + py + ',' + '-1' + ',' + '-1']);
c.stdout.on('data', function (data)
{
log(data);
});
c.stderr.on('data', function (data)
{
log('stderr: ' + data);
});
c.on('exit', function (code)
{
log('child process exited with code ' + code);
});
var x2 = x1 * sw;
var y2 = y1 * sh;
log('@@@@@@')
log(x2);
log(y2);
var c2 = spawn('wmctrl', ['-o', '' + x2 + ',' + y2 ]);
c2.stdout.on('data', function (data)
{
log(data);
});
c2.stderr.on('data', function (data)
{
log('stderr: ' + data);
});
c2.on('exit', function (code)
{
log('child process exited with code ' + code);
});
loop = false;
}
else
{
if (i == nxy)
loop = false
else
i++
}
}
});
}
}
});
listWindows.stderr.on('data', function (data)
{
log('stderr: ' + data);
});
listWindows.on('exit', function (code)
{
log('child process exited with code ' + code);
});
}
}