layout-machi/README.md

152 lines
4.9 KiB
Markdown
Raw Normal View History

2019-07-13 06:57:13 +02:00
# ![](icon.png) layout-machi
2019-07-05 05:11:36 +02:00
A manual layout for Awesome with a rapid interactive editor.
2019-07-04 23:32:05 +02:00
2019-07-13 03:34:44 +02:00
Demos: https://imgur.com/a/OlM60iw
2019-07-04 23:32:05 +02:00
## Why?
2019-07-04 23:43:49 +02:00
TL;DR --- I want the control of my layout.
2019-07-04 23:43:24 +02:00
2019-07-04 23:32:05 +02:00
1. Dynamic tiling is an overkill, since tiling is only useful for persistent windows, and people extensively use hibernate/sleep these days.
2. I don't want to have all windows moving around whenever a new window shows up.
2019-07-04 23:39:05 +02:00
3. I want to have a flexible layout such that I can quickly adjust to whatever I need.
2019-07-04 23:32:05 +02:00
2019-07-14 18:46:06 +02:00
## Compatibilities
I developed it with Awesome 4.3.
Please let me know if it does not work in other versions.
2019-07-11 18:59:21 +02:00
## Quick usage
Suppose this git is checked out at `~/.config/awesome/layout-machi`
2019-07-13 00:04:39 +02:00
`machi = require("layout-machi")`
2019-07-11 18:59:21 +02:00
2019-07-13 00:04:39 +02:00
The package provide a default layout `machi.default_layout` and editor `machi.default_editor`, which can be added into the layout list.
2019-07-11 18:59:21 +02:00
The package comes with the icon for `layoutbox`, which can be set with the following statement (after a theme has been loaded):
`require("beautiful").layout_machi = machi.get_icon()`
2019-07-04 23:32:05 +02:00
## Use the layout
2019-07-13 00:04:39 +02:00
Use `layout = machi.layout.create(name, editor)` to instantiate the layout with an editor object.
2019-07-14 19:26:13 +02:00
`name` can be a string or a function returning a string (see `init.lua` and "Advanced" below).
This is used for having different actual layout dependent on tags.
`editor` are used for editing and persisting the layouts.
2019-07-13 00:04:39 +02:00
`machi.default_editor` can be used, or see below on creating editors.
You can create multiple layouts with different names and share the same editor.
2019-07-07 20:22:01 +02:00
## Editor
2019-07-04 23:32:05 +02:00
2019-07-12 00:06:40 +02:00
Call `editor = machi.editor.create()` to create an editor.
To edit the layout `l` on screen `s`, call `editor.start_interactive(s = awful.screen.focused(), l = awful.layout.get(s))`.
### The layout editing command
2019-07-06 06:10:04 +02:00
The editing starts with the open area of the entire workarea, takes commands to split the current area into multiple sub-areas, then recursively edits each of them.
2019-07-10 04:07:54 +02:00
The editor is keyboard driven, each command is a key with optional digits (namely `D`) before it as parameter (or multiple parameters depending on the command).
2019-07-04 23:32:05 +02:00
1. `Up`/`Down`: restore to the history command sequence
2019-07-10 04:07:54 +02:00
2. `h`/`v`: split the current region horizontally/vertically into `#D` regions. The split will respect the ratio of digits in `D`.
3. `w`: Take the last two digits from `D` as `D = ...AB` (1 if `D` is shorter than 2 digits), and split the current region equally into A rows and B columns. If no digits are provided at all, behave the same as `Space`.
4. `s`: shift the current editing region with other open regions. If digits are provided, shift for that many times.
5. `Space` or `-`: Without parameters, close the current region and move to the next open region. With digits, set the maximum depth of splitting (the default depth is 2).
6. `Enter`/`.`: close all open regions. When all regions are closed, press `Enter` will save the layout and exit the editor.
2019-07-04 23:32:05 +02:00
7. `Backspace`: undo the last command.
8. `Escape`: exit the editor without saving the layout.
For examples:
2019-07-04 23:32:05 +02:00
2019-07-07 21:04:58 +02:00
`h-v`
2019-07-04 23:32:05 +02:00
```
11 22
11 22
11
2019-07-04 23:32:05 +02:00
11 33
11 33
```
2019-07-07 21:04:58 +02:00
`hvv` (or `22w`)
2019-07-04 23:32:05 +02:00
```
11 33
11 33
22 44
22 44
```
2019-07-10 04:07:54 +02:00
`131h2v-12v`
2019-07-04 23:55:10 +02:00
2019-07-05 05:20:30 +02:00
Details:
2019-07-10 04:07:54 +02:00
- `131h`: horizontally split the initial region (entire desktop) to the ratio of 1:3:1
- For the first `1` part:
2019-07-05 05:20:30 +02:00
- `2v`: vertically split the region to the ratio of 2:1
2019-07-10 04:07:54 +02:00
- `-`: skip the editing of the middle `3` part
- For the right `1` part:
2019-07-05 05:20:30 +02:00
- `12v`: split the right part vertically to the ratio of 1:2
Tada!
2019-07-04 23:55:10 +02:00
```
11 3333 44
11 3333 44
11 3333
11 3333 55
3333 55
22 3333 55
22 3333 55
```
2019-07-05 01:09:17 +02:00
### Persistent history
2019-07-12 16:25:53 +02:00
By default, the last 100 command sequences are stored in `.cache/awesome/history_machi`.
2019-07-06 06:10:04 +02:00
To change that, please refer to `editor.lua`. (XXX more documents)
2019-07-05 23:13:59 +02:00
2019-07-07 20:22:01 +02:00
## Switcher
2019-07-12 00:06:40 +02:00
Calling `machi.switcher.start()` will create a switcher supporting the following keys:
2019-07-10 05:30:02 +02:00
- Arrow keys: move focus into other regions by the direction.
- `Shift` + arrow keys: move the focused window to other regions by the direction.
- `Tab`: switch windows in the same regions.
So far, the key binding is not configurable. One has to modify the source code to change it.
2019-07-07 20:22:01 +02:00
2019-07-05 01:09:17 +02:00
## Other functions
2019-07-12 00:06:40 +02:00
`machi.editor.fit_region(c, cycle = false)` will fit a floating client into the closest region.
2019-07-06 06:19:41 +02:00
If `cycle` is true, it then moves the window by cycling all regions.
2019-07-04 23:32:05 +02:00
2019-07-14 19:26:13 +02:00
## Advanced
2019-07-14 19:27:29 +02:00
### `name` as a function in `machi.layout.create`
2019-07-14 19:26:13 +02:00
2019-07-14 19:33:39 +02:00
When passed in as a function, `name` takes the tag `t` and returns (1) a string for the tag-dependent name of the layout, and (2) a boolean indicating the persistence of the layout.
2019-07-14 19:26:13 +02:00
The default layout, `machi.default_layout`, uses the screen geometry and the tag name for name, thus allows the actual layout to be tag- and screen-dependent.
To differentiate tags with the same name, you may need a more advanced naming function.
2019-07-10 22:57:39 +02:00
## Caveats
1. layout-machi handles `beautiful.useless_gap` slightly differently.
2019-07-10 22:57:39 +02:00
2. True transparency is required. Otherwise switcher and editor will block the clients.
2019-07-11 20:40:13 +02:00
2019-07-05 22:14:40 +02:00
## TODO
2019-07-05 23:13:59 +02:00
- Tabs on regions?
2019-07-05 22:14:40 +02:00
2019-07-04 23:32:05 +02:00
## License
Apache 2.0 --- See LICENSE