Giter VIP home page Giter VIP logo

mjolnir.tiling's Introduction

mjolnir.tiling

Add tiling window management powers to your mjolnir.

Features

  • Different layouts per space (with this magic)
  • Multi-monitor supported
  • Custom layouts

Quick start

First up, install Mjolnir if you haven't already.

Then install mjolnir.tiling using luarocks: luarocks install mjolnir.tiling

In your ~/.mjolnir/init.lua:

local tiling = require "mjolnir.tiling"
local mash = {"ctrl", "cmd"}

hotkey.bind(mash, "c", function() tiling.cyclelayout() end)
hotkey.bind(mash, "j", function() tiling.cycle(1) end)
hotkey.bind(mash, "k", function() tiling.cycle(-1) end)
hotkey.bind(mash, "space", function() tiling.promote() end)
hotkey.bind(mash, "f", function() tiling.gotolayout("fullscreen") end)

-- If you want to set the layouts that are enabled
tiling.set('layouts', {
  'fullscreen', 'main-vertical'
})

Updating

To update to the latest mjolnir.tiling, just run: luarocks install mjolnir.tiling

Using custom layouts

You can define your own layouts like so (please see layouts.lua for definition examples:)

tiling.addlayout('custom', function(windows)
  fnutils.each(windows, function(window)
    window:maximize()
  end)
end)

Floating Windows

Using tiling.togglefloat you can toggle whether or not a window that is on your desktop will be included in your tiling calculations. You can optionally pass in a function as a callback to process the window if it was tiled.

-- Push the window into the exact center of the screen
local function center(window)
  frame = window:screen():frame()
  frame.x = (frame.w / 2) - (frame.w / 4)
  frame.y = (frame.h / 2) - (frame.h / 4)
  frame.w = frame.w / 2
  frame.h = frame.h / 2
  window:setframe(frame)
end

hotkey.bind(mash, "f", function() tiling.togglefloat(center) end)

Layouts

These are the layouts that come with mjolnir.tiling:

Name Screenshot
fullscreen fullscreen
main-vertical main-vertical
main-horizontal main-horizontal
rows rows
columns columns
gp-vertical gp-vertical
gp-horizontal gp-horizontal

Contributing

Yes! Please :)

git clone https://github.com/nathankot/mjolnir.tiling.git
cd mjolnir.tiling
luarocks make <latest .rockspec name>

Contributors

Thanks <3

To-do

  • Better documentation
  • More layouts
  • Allow globally enabling/disabling layouts
  • Functions to move windows across spaces
  • Event-based tiling, although requires sdegutis/mjolnir#72

License

The MIT License (MIT)

Copyright (c) 2015 Nathan Kot

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

mjolnir.tiling's People

Contributors

acmcelwee avatar csaunders avatar iveney avatar jiblits avatar mavant avatar nathankot avatar orbaruk avatar peterjcaulfield avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mjolnir.tiling's Issues

Some apps are "immune" to tiling

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.

Incorrect behavior when there are multiple screens

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.

Floating Windows

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?

Tile cycling does not compensate for "blank" Window

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:

yh_muu7dtssu

And here is what my patched version of main-vertical-tiling looks like:

x46sa4g6q91b

luarocks install fails

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.

mjolnir.tiling is very slow

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.