Export `modifiers` table
This commit is contained in:
parent
b8f33d4d66
commit
62dc087b78
29
README.md
29
README.md
|
@ -7,19 +7,21 @@ It is based on code from the old Awesome wiki.
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
```
|
```
|
||||||
$ git clone https://github.com/jcrd/awesome-ez.git
|
git clone https://github.com/jcrd/awesome-ez.git
|
||||||
$ cd awesome-ez
|
cd awesome-ez
|
||||||
$ luarocks make --local rockspec/awesome-ez-devel-1.rockspec
|
luarocks make --local rockspec/awesome-ez-devel-1.rockspec
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Require the library:
|
Require the library:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local ez = require("awesome-ez")
|
local ez = require("awesome-ez")
|
||||||
```
|
```
|
||||||
|
|
||||||
Use `ez.keytable` to define key bindings:
|
Use `ez.keytable` to define key bindings:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local globalkeys = ez.keytable {
|
local globalkeys = ez.keytable {
|
||||||
["M-Return"] = {awful.spawn, "xterm"},
|
["M-Return"] = {awful.spawn, "xterm"},
|
||||||
|
@ -28,6 +30,7 @@ local globalkeys = ez.keytable {
|
||||||
```
|
```
|
||||||
|
|
||||||
Use `ez.btntable` to define button bindings:
|
Use `ez.btntable` to define button bindings:
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
local clientbtns = ez.btntable {
|
local clientbtns = ez.btntable {
|
||||||
["1"] = function (c) client.focus = c end,
|
["1"] = function (c) client.focus = c end,
|
||||||
|
@ -45,15 +48,21 @@ descriptions of all functions.
|
||||||
|
|
||||||
### Modifiers
|
### Modifiers
|
||||||
|
|
||||||
The following modifiers can be identified by their shorthand characters
|
The following modifiers can be identified by their default shorthand characters
|
||||||
in key and button definitions:
|
in key and button definitions:
|
||||||
|
|
||||||
Modifier | Character
|
Character | Modifier
|
||||||
-------- | ---------
|
--------- | --------
|
||||||
Mod4 | M
|
M | Mod4
|
||||||
Mod1 | A
|
A | Mod1
|
||||||
Shift | S
|
S | Shift
|
||||||
Control | C
|
C | Control
|
||||||
|
|
||||||
|
The `modifiers` table can be customized:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
ez.modifiers["M"] = "Mod1"
|
||||||
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|
12
init.lua
12
init.lua
|
@ -11,7 +11,7 @@ local gtable = require("gears.table")
|
||||||
|
|
||||||
local ez = {}
|
local ez = {}
|
||||||
|
|
||||||
local modifiers = {
|
ez.modifiers = {
|
||||||
["M"] = "Mod4",
|
["M"] = "Mod4",
|
||||||
["A"] = "Mod1",
|
["A"] = "Mod1",
|
||||||
["S"] = "Shift",
|
["S"] = "Shift",
|
||||||
|
@ -47,7 +47,7 @@ function ez.util.cb_from_table(cb)
|
||||||
not (getmetatable(cb) and getmetatable(cb).__call) then
|
not (getmetatable(cb) and getmetatable(cb).__call) then
|
||||||
local tbl = gtable.clone(cb, false)
|
local tbl = gtable.clone(cb, false)
|
||||||
local func = table.remove(tbl, 1)
|
local func = table.remove(tbl, 1)
|
||||||
cb = function ()
|
cb = function()
|
||||||
return func(unpack(tbl))
|
return func(unpack(tbl))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -69,8 +69,8 @@ end
|
||||||
function ez.util.parse_key(keydef)
|
function ez.util.parse_key(keydef)
|
||||||
local modkeys = {}
|
local modkeys = {}
|
||||||
for _, key in ipairs(split(keydef, "-")) do
|
for _, key in ipairs(split(keydef, "-")) do
|
||||||
if modifiers[key] ~= nil then
|
if ez.modifiers[key] ~= nil then
|
||||||
table.insert(modkeys, modifiers[key])
|
table.insert(modkeys, ez.modifiers[key])
|
||||||
else
|
else
|
||||||
local group = string.match(key, "<(%w+)>")
|
local group = string.match(key, "<(%w+)>")
|
||||||
if group then
|
if group then
|
||||||
|
@ -97,8 +97,8 @@ function ez.util.parse_button(btndef)
|
||||||
end
|
end
|
||||||
local modkeys = {}
|
local modkeys = {}
|
||||||
for _, key in ipairs(split(btndef, "-")) do
|
for _, key in ipairs(split(btndef, "-")) do
|
||||||
if modifiers[key] ~= nil then
|
if ez.modifiers[key] ~= nil then
|
||||||
table.insert(modkeys, modifiers[key])
|
table.insert(modkeys, ez.modifiers[key])
|
||||||
else
|
else
|
||||||
return modkeys, tonumber(key)
|
return modkeys, tonumber(key)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue