daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Mar 18th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local gears = require 'gears';
  2. local awful = require 'awful';
  3.  
  4. --- Move a client to a location within a grid
  5. -- @param c the client to move
  6. -- @param sx the number of columns in the grid
  7. -- @param sy the number of rows in the grid
  8. -- @param px the zero-indexed destination column
  9. -- @param py the zero-indexed destination row
  10. function client_move_to_grid(c, sx, sy, px, py)
  11.   local workarea = awful.screen.focused().workarea;
  12.   local gx = workarea.width / sx;
  13.   local gy = workarea.height / sy;
  14.  
  15.   local geometry = {
  16.     width = gx,
  17.     height = gy,
  18.     x = workarea.x + px * gx,
  19.     y = workarea.y + py * gy,
  20.   };
  21.   c:geometry(geometry);
  22. end
  23.  
  24. function move_to_grid(sx, sy, px, py)
  25.   return function()
  26.     if client.focus then
  27.       client_move_to_grid(client.focus, sx, sy, px, py);
  28.     end
  29.   end;
  30. end
  31.  
  32. local gtile_mod = { 'Mod1', 'Shift', 'Control' };
  33. local gtile_keys = gears.table.join(
  34.   root.keys(),
  35.   -- full screen
  36.   awful.key(gtile_mod, 'g', move_to_grid(1, 1, 0, 0),
  37.             {description = 'Maximize', group = 'gTile'}),
  38.  
  39.   -- vertical halves
  40.   awful.key(gtile_mod, 'Left', move_to_grid(2, 1, 0, 0),
  41.     {description = '2x1 0:0 Left half', group = 'gTile'}),
  42.   awful.key(gtile_mod, 'Right', move_to_grid(2, 1, 1, 0),
  43.     {description = '2x1 1:0 Right half', group = 'gTile'}),
  44.  
  45.   -- four corners
  46.   awful.key(gtile_mod, 'a', move_to_grid(2, 2, 0, 0),
  47.            {description = '2x2 0:0 Top-left', group = 'gTile'}),
  48.   awful.key(gtile_mod, 's', move_to_grid(2, 2, 0, 1),
  49.            {description = '2x2 0:1 Bottom-left', group = 'gTile'}),
  50.   awful.key(gtile_mod, 'd', move_to_grid(2, 2, 1, 0),
  51.            {description = '2x2 1:0 Top-right', group = 'gTile'}),
  52.   awful.key(gtile_mod, 'f', move_to_grid(2, 2, 1, 1),
  53.            {description = '2x2 1:1 Bottom-right', group = 'gTile'}),
  54.  
  55.   -- top 4
  56.   awful.key(gtile_mod, 'q', move_to_grid(4, 2, 0, 0),
  57.            { description = 'Top 4', group = 'gTile' }),
  58.   awful.key(gtile_mod, 'w', move_to_grid(4, 2, 1, 0),
  59.            { description = 'Top 4', group = 'gTile' }),
  60.   awful.key(gtile_mod, 'e', move_to_grid(4, 2, 2, 0),
  61.            { description = 'Top 4', group = 'gTile' }),
  62.   awful.key(gtile_mod, 'r', move_to_grid(4, 2, 3, 0),
  63.            { description = 'Top 4', group = 'gTile' }),
  64.  
  65.   -- bottom 4
  66.   awful.key(gtile_mod, 'z', move_to_grid(4, 2, 0, 1),
  67.            { description = 'Bottom 4', group = 'gTile' }),
  68.   awful.key(gtile_mod, 'x', move_to_grid(4, 2, 1, 1),
  69.            { description = 'Bottom 4', group = 'gTile' }),
  70.   awful.key(gtile_mod, 'c', move_to_grid(4, 2, 2, 1),
  71.            { description = 'Bottom 4', group = 'gTile' }),
  72.   awful.key(gtile_mod, 'v', move_to_grid(4, 2, 3, 1),
  73.            { description = 'Bottom 4', group = 'gTile' }),
  74.  
  75.   -- top 8
  76.   awful.key(gtile_mod, '1', move_to_grid(4, 4, 0, 0),
  77.             { description = 'Top 8', group = 'gTile' }),
  78.   awful.key(gtile_mod, '2', move_to_grid(4, 4, 0, 1),
  79.             { description = 'Top 8', group = 'gTile' }),
  80.   awful.key(gtile_mod, '3', move_to_grid(4, 4, 1, 0),
  81.             { description = 'Top 8', group = 'gTile' }),
  82.   awful.key(gtile_mod, '4', move_to_grid(4, 4, 1, 1),
  83.             { description = 'Top 8', group = 'gTile' }),
  84.   awful.key(gtile_mod, '5', move_to_grid(4, 4, 2, 0),
  85.             { description = 'Top 8', group = 'gTile' }),
  86.   awful.key(gtile_mod, '6', move_to_grid(4, 4, 2, 1),
  87.             { description = 'Top 8', group = 'gTile' }),
  88.   awful.key(gtile_mod, '7', move_to_grid(4, 4, 3, 0),
  89.             { description = 'Top 8', group = 'gTile' }),
  90.   awful.key(gtile_mod, '8', move_to_grid(4, 4, 3, 1),
  91.             { description = 'Top 8', group = 'gTile' })
  92.  
  93. );
  94. root.keys(gtile_keys);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top