nathankot / mjolnir.tiling Goto Github PK
View Code? Open in Web Editor NEWAdd tiling window management powers to your mjolnir
Add tiling window management powers to your mjolnir
Edit: Ah. It looks like Creative Cloud was keeping a hidden nameless window around. So I guess this patch is more for applications that are misbehaving than anything.
I'm not sure if this is just a problem with my system or not, but for whatever reason while trying to tile my windows I end up with this blank Window that ends up consuming some of my tiling area.
I've managed to patch the issue although it's not the the best looking of things :(
While working on the patch I added the following to the main-vertical-tiling function so I could get an idea of what what mjolnir.tiling thinks my windows are:
layouts['main-vertical-tiling-debug'] = function(windows)
local wincount = #windows
if wincount == 1 then
return layouts['fullscreen'](windows)
end
print "----- Calculating Layouts -----"
for index, win in pairs(windows) do
local frame = win:screen():frame()
if index == 1 then
frame.x, frame.y = 0, 0
frame.w = frame.w / 2
else
frame.x = frame.w / 2
frame.w = frame.w / 2
frame.h = frame.h / (wincount - 1)
frame.y = frame.h * (index - 2)
end
print (win:title() .. " Frame H:" .. frame.h .. " Frame Y:" .. frame.y)
win:setframe(frame)
end
print "----- Calculation Complete -----"
end
This results in the following console output:
----- Calculating Layouts -----
init.lua — .mjolnir Frame H:1414 Frame Y:0
Frame H:353.5 Frame Y:0
New Issue · nathankot/mjolnir.tiling Frame H:353.5 Frame Y:353.5
Issues · nathankot/mjolnir.tiling · GitHub Frame H:353.5 Frame Y:707
Mjolnir Console Frame H:353.5 Frame Y:1060.5
----- Calculation Complete -----
If you look at the 3rd line, you'll notice that a nameless window is in there somehow. I'm somewhat new to Mjolnir so I don't know if there's a more useful function that can be used to get more details about what application is being naughty here.
The way I've patched it was by adding another layout function that simply skips over this window. The skipping logic could probably be rolled up into a function that simply collects all the valid windows before running the tiling functions. It might make things a bit cleaner than what I've done, which ends up needing to be applied to a few other functions as well.
layouts['my-vertical-tiling'] = function(windows)
local wincount = #windows
// This is basically the meat of the calculation
local decreaseCountsBy = 0
for index, win in pairs(windows) do
if #win:title() == 0 then
decreaseCountsBy = decreaseCountsBy + 1
end
end
if wincount == 1 then
return layouts['fullscreen'](windows)
end
for index, win in pairs(windows) do
local frame = win:screen():frame()
if index == 1 then
frame.x, frame.y = 0, 0
frame.w = frame.w / 2
else
frame.x = frame.w / 2
frame.w = frame.w / 2
// Just apply that decreaseCountsBy to ensure that the naughty window is skipped
frame.h = frame.h / (wincount - (1 + decreaseCountsBy))
frame.y = frame.h * (index - (2 + decreaseCountsBy))
end
win:setframe(frame)
end
end
Here is what a main-vertial-tiling-debug
looks like on my system:
And here is what my patched version of main-vertical-tiling
looks like:
Hi. I'm trying to use mjolnir.tiling on OS X 10.10.2 with Lua 5.2.3 and Mjolnir 0.4.3. Cycling through layouts takes a long time, around 5s every time I cycle. I've recorded a screencast - this is in real time, and I'm cycling as soon as a new layout shows. Here's my config:
local application = require "mjolnir.application"
local hotkey = require "mjolnir.hotkey"
local window = require "mjolnir.window"
local fnutils = require "mjolnir.fnutils"
local tiling = require "mjolnir.tiling"
local hyper = {"ctrl", "alt", "cmd"}
hotkey.bind(hyper, "c", function() tiling.cyclelayout() end)
hotkey.bind(hyper, "j", function() tiling.cycle(1) end)
hotkey.bind(hyper, "k", function() tiling.cycle(-1) end)
hotkey.bind(hyper, "space", function() tiling.promote() end)
Is this behaviour expected? Why could this be happening?
I wrote an extension that allows me to tag windows as floating or not. This allows me to have the window visible on my desktop but excluded from the tiling calculations.
Would you be interested in having a feature like this added to the tiling plugin?
Hi,
Thanks for your work on this, I'm coming from archlinux with i3 and being able to add tiling logic to OSX is really a lifesaver :-)
There are some (very few) apps that seem to be totally "immune" to tiling - they keep floating around. togglefloat()
also has no effect on them.
The biggest offender currently seems to be the HipChat app.
Are you aware about this? I'm guessing it's a problem with the app, not with mjolnir.tiling - but maybe there's something I can do to make it work? I'm able to move the app window around and resize it using grid.set
which feels kinda strange.
Apologies if the answer is obvious, I'm new to OSX and have no clue how the accessibility / windowing works under the hood.
Hey,
Thanks for writing this module. I'd really like to try it out, but I can't seem to install it with luarocks:
$ luarocks install mjolnir.tiling
Installing http://rocks.moonscript.org/mjolnir.tiling-0.1-1.rockspec...
Using http://rocks.moonscript.org/mjolnir.tiling-0.1-1.rockspec... switching to 'build' mode
Cloning into 'mjolnir.tiling'...
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 6 (delta 0), reused 2 (delta 0)
Receiving objects: 100% (6/6), done.
Checking connectivity... done.
cp: tiling.lua: No such file or directory
Error: Build error: Failed installing tiling.lua in /opt/boxen/homebrew/lib/luarocks/rocks/mjolnir.tiling/0.1-1/lua/mjolnir/tiling.lua
I am able to install other modules via luarocks, such as mjolnir.7bits.mjomatic. Is there a different installation method that I should use? I am quite unfamiliar with how luarocks works, so I don't know what the right solution is.
Thanks again.
The windows will jump to other screens when switching layouts, which is caused by always setting x and y to 0. E.g.,:
-- layouts.lua
frame.x, frame.y = 0, 0
When I have two screens stacked vertically, if I switch layout to main-vertical in the bottom screen, the window will jump to the upper screen.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.