Ported awful to lua 5.2
Tested with lua 5.1: all good Signed-off-by: Arvydas Sidorenko <asido4@gmail.com>
This commit is contained in:
parent
f73e0b44c0
commit
61ff9ce2b7
|
@ -1,7 +1,7 @@
|
||||||
-- Standard awesome library
|
-- Standard awesome library
|
||||||
require("awful")
|
local awful = require("awful")
|
||||||
|
awful.rules = require("awful.rules")
|
||||||
require("awful.autofocus")
|
require("awful.autofocus")
|
||||||
require("awful.rules")
|
|
||||||
-- Widget and layout library
|
-- Widget and layout library
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
-- Theme handling library
|
-- Theme handling library
|
||||||
|
|
|
@ -11,7 +11,7 @@ local atag = require("awful.tag")
|
||||||
|
|
||||||
--- When loaded, this module makes sure that there's always a client that will have focus
|
--- When loaded, this module makes sure that there's always a client that will have focus
|
||||||
-- on event such as tag switching, client unmanaging, etc.
|
-- on event such as tag switching, client unmanaging, etc.
|
||||||
module("awful.autofocus")
|
-- awful.autofocus
|
||||||
|
|
||||||
-- Give focus when clients appear/disappear.
|
-- Give focus when clients appear/disappear.
|
||||||
-- @param obj An object that should have a .screen property.
|
-- @param obj An object that should have a .screen property.
|
||||||
|
|
|
@ -11,7 +11,8 @@ local capi = { button = button }
|
||||||
local util = require("awful.util")
|
local util = require("awful.util")
|
||||||
|
|
||||||
--- Create easily new buttons objects ignoring certain modifiers.
|
--- Create easily new buttons objects ignoring certain modifiers.
|
||||||
module("awful.button")
|
-- awful.button
|
||||||
|
local button = { mt = {} }
|
||||||
|
|
||||||
--- Modifiers to ignore.
|
--- Modifiers to ignore.
|
||||||
-- By default this is initialized as { "Lock", "Mod2" }
|
-- By default this is initialized as { "Lock", "Mod2" }
|
||||||
|
@ -19,7 +20,7 @@ module("awful.button")
|
||||||
-- when pressing keys.
|
-- when pressing keys.
|
||||||
-- @name ignore_modifiers
|
-- @name ignore_modifiers
|
||||||
-- @class table
|
-- @class table
|
||||||
ignore_modifiers = { "Lock", "Mod2" }
|
local ignore_modifiers = { "Lock", "Mod2" }
|
||||||
|
|
||||||
--- Create a new button to use as binding.
|
--- Create a new button to use as binding.
|
||||||
-- This function is useful to create several buttons from one, because it will use
|
-- This function is useful to create several buttons from one, because it will use
|
||||||
|
@ -31,12 +32,12 @@ ignore_modifiers = { "Lock", "Mod2" }
|
||||||
-- CapsLock off.
|
-- CapsLock off.
|
||||||
-- @see button
|
-- @see button
|
||||||
-- @return A table with one or several button objects.
|
-- @return A table with one or several button objects.
|
||||||
function new(mod, button, press, release)
|
function button.new(mod, _button, press, release)
|
||||||
local ret = {}
|
local ret = {}
|
||||||
local subsets = util.subsets(ignore_modifiers)
|
local subsets = util.subsets(ignore_modifiers)
|
||||||
for _, set in ipairs(subsets) do
|
for _, set in ipairs(subsets) do
|
||||||
ret[#ret + 1] = capi.button({ modifiers = util.table.join(mod, set),
|
ret[#ret + 1] = capi.button({ modifiers = util.table.join(mod, set),
|
||||||
button = button })
|
button = _button })
|
||||||
if press then
|
if press then
|
||||||
ret[#ret]:connect_signal("press", function(bobj, ...) press(...) end)
|
ret[#ret]:connect_signal("press", function(bobj, ...) press(...) end)
|
||||||
end
|
end
|
||||||
|
@ -47,6 +48,10 @@ function new(mod, button, press, release)
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
setmetatable(_M, { __call = function(_, ...) return new(...) end })
|
function button.mt:__call(...)
|
||||||
|
return button.new(...)
|
||||||
|
end
|
||||||
|
|
||||||
|
return setmetatable(button, button.mt)
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
|
@ -21,30 +21,31 @@ local capi =
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Useful client manipulation functions.
|
--- Useful client manipulation functions.
|
||||||
module("awful.client")
|
-- awful.client
|
||||||
|
local client = {}
|
||||||
|
|
||||||
-- Private data
|
-- Private data
|
||||||
data = {}
|
client.data = {}
|
||||||
data.focus = {}
|
client.data.focus = {}
|
||||||
data.urgent = {}
|
client.data.urgent = {}
|
||||||
data.marked = {}
|
client.data.marked = {}
|
||||||
data.properties = setmetatable({}, { __mode = 'k' })
|
client.data.properties = setmetatable({}, { __mode = 'k' })
|
||||||
|
|
||||||
-- Functions
|
-- Functions
|
||||||
urgent = {}
|
client.urgent = {}
|
||||||
focus = {}
|
client.focus = {}
|
||||||
focus.history = {}
|
client.focus.history = {}
|
||||||
swap = {}
|
client.swap = {}
|
||||||
floating = {}
|
client.floating = {}
|
||||||
dockable = {}
|
client.dockable = {}
|
||||||
property = {}
|
client.property = {}
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Jump to the given client. Takes care of focussing the screen, the right tag,
|
-- Jump to the given client. Takes care of focussing the screen, the right tag,
|
||||||
-- etc.
|
-- etc.
|
||||||
-- @param c the client to jump to
|
-- @param c the client to jump to
|
||||||
-- @param merge If true then merge tags when clients are not visible.
|
-- @param merge If true then merge tags when clients are not visible.
|
||||||
function jumpto(c, merge)
|
function client.jumpto(c, merge)
|
||||||
local s = capi.client.focus and capi.client.focus.screen or capi.mouse.screen
|
local s = capi.client.focus and capi.client.focus.screen or capi.mouse.screen
|
||||||
-- focus the screen
|
-- focus the screen
|
||||||
if s ~= c.screen then
|
if s ~= c.screen then
|
||||||
|
@ -68,9 +69,9 @@ end
|
||||||
|
|
||||||
--- Get the first client that got the urgent hint.
|
--- Get the first client that got the urgent hint.
|
||||||
-- @return The first urgent client.
|
-- @return The first urgent client.
|
||||||
function urgent.get()
|
function client.urgent.get()
|
||||||
if #data.urgent > 0 then
|
if #client.data.urgent > 0 then
|
||||||
return data.urgent[1]
|
return client.data.urgent[1]
|
||||||
else
|
else
|
||||||
-- fallback behaviour: iterate through clients and get the first urgent
|
-- fallback behaviour: iterate through clients and get the first urgent
|
||||||
local clients = capi.client.get()
|
local clients = capi.client.get()
|
||||||
|
@ -84,28 +85,28 @@ end
|
||||||
|
|
||||||
--- Jump to the client that received the urgent hint first.
|
--- Jump to the client that received the urgent hint first.
|
||||||
-- @param merge If true then merge tags when clients are not visible.
|
-- @param merge If true then merge tags when clients are not visible.
|
||||||
function urgent.jumpto(merge)
|
function client.urgent.jumpto(merge)
|
||||||
local c = urgent.get()
|
local c = client.urgent.get()
|
||||||
if c then
|
if c then
|
||||||
jumpto(c, merge)
|
client.jumpto(c, merge)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Adds client to urgent stack.
|
--- Adds client to urgent stack.
|
||||||
-- @param c The client object.
|
-- @param c The client object.
|
||||||
-- @param prop The property which is updated.
|
-- @param prop The property which is updated.
|
||||||
function urgent.add(c, prop)
|
function client.urgent.add(c, prop)
|
||||||
if type(c) == "client" and prop == "urgent" and c.urgent then
|
if type(c) == "client" and prop == "urgent" and c.urgent then
|
||||||
table.insert(data.urgent, c)
|
table.insert(client.data.urgent, c)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Remove client from urgent stack.
|
--- Remove client from urgent stack.
|
||||||
-- @param c The client object.
|
-- @param c The client object.
|
||||||
function urgent.delete(c)
|
function client.urgent.delete(c)
|
||||||
for k, cl in ipairs(data.urgent) do
|
for k, cl in ipairs(client.data.urgent) do
|
||||||
if c == cl then
|
if c == cl then
|
||||||
table.remove(data.urgent, k)
|
table.remove(client.data.urgent, k)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -113,10 +114,10 @@ end
|
||||||
|
|
||||||
--- Remove a client from the focus history
|
--- Remove a client from the focus history
|
||||||
-- @param c The client that must be removed.
|
-- @param c The client that must be removed.
|
||||||
function focus.history.delete(c)
|
function client.focus.history.delete(c)
|
||||||
for k, v in ipairs(data.focus) do
|
for k, v in ipairs(client.data.focus) do
|
||||||
if v == c then
|
if v == c then
|
||||||
table.remove(data.focus, k)
|
table.remove(client.data.focus, k)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -127,7 +128,7 @@ end
|
||||||
-- not registered and cannot get focus.
|
-- not registered and cannot get focus.
|
||||||
-- @param c A client.
|
-- @param c A client.
|
||||||
-- @return The same client if it's ok, nil otherwise.
|
-- @return The same client if it's ok, nil otherwise.
|
||||||
function focus.filter(c)
|
function client.focus.filter(c)
|
||||||
if c.type == "desktop"
|
if c.type == "desktop"
|
||||||
or c.type == "dock"
|
or c.type == "dock"
|
||||||
or c.type == "splash"
|
or c.type == "splash"
|
||||||
|
@ -139,11 +140,11 @@ end
|
||||||
|
|
||||||
--- Update client focus history.
|
--- Update client focus history.
|
||||||
-- @param c The client that has been focused.
|
-- @param c The client that has been focused.
|
||||||
function focus.history.add(c)
|
function client.focus.history.add(c)
|
||||||
-- Remove the client if its in stack
|
-- Remove the client if its in stack
|
||||||
focus.history.delete(c)
|
client.focus.history.delete(c)
|
||||||
-- Record the client has latest focused
|
-- Record the client has latest focused
|
||||||
table.insert(data.focus, 1, c)
|
table.insert(client.data.focus, 1, c)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get the latest focused client for a screen in history.
|
--- Get the latest focused client for a screen in history.
|
||||||
|
@ -151,11 +152,11 @@ end
|
||||||
-- @param idx The index: 0 will return first candidate,
|
-- @param idx The index: 0 will return first candidate,
|
||||||
-- 1 will return second, etc.
|
-- 1 will return second, etc.
|
||||||
-- @return A client.
|
-- @return A client.
|
||||||
function focus.history.get(screen, idx)
|
function client.focus.history.get(screen, idx)
|
||||||
-- When this counter is equal to idx, we return the client
|
-- When this counter is equal to idx, we return the client
|
||||||
local counter = 0
|
local counter = 0
|
||||||
local vc = visible(screen)
|
local vc = client.visible(screen)
|
||||||
for k, c in ipairs(data.focus) do
|
for k, c in ipairs(client.data.focus) do
|
||||||
if c.screen == screen then
|
if c.screen == screen then
|
||||||
for j, vcc in ipairs(vc) do
|
for j, vcc in ipairs(vc) do
|
||||||
if vcc == c then
|
if vcc == c then
|
||||||
|
@ -173,7 +174,7 @@ function focus.history.get(screen, idx)
|
||||||
-- that passes the filter.
|
-- that passes the filter.
|
||||||
if counter == 0 then
|
if counter == 0 then
|
||||||
for k, v in ipairs(vc) do
|
for k, v in ipairs(vc) do
|
||||||
if focus.filter(v) then
|
if client.focus.filter(v) then
|
||||||
return v
|
return v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -181,7 +182,7 @@ function focus.history.get(screen, idx)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Focus the previous client in history.
|
--- Focus the previous client in history.
|
||||||
function focus.history.previous()
|
function client.focus.history.previous()
|
||||||
local sel = capi.client.focus
|
local sel = capi.client.focus
|
||||||
local s
|
local s
|
||||||
if sel then
|
if sel then
|
||||||
|
@ -189,14 +190,14 @@ function focus.history.previous()
|
||||||
else
|
else
|
||||||
s = capi.mouse.screen
|
s = capi.mouse.screen
|
||||||
end
|
end
|
||||||
local c = focus.history.get(s, 1)
|
local c = client.focus.history.get(s, 1)
|
||||||
if c then capi.client.focus = c end
|
if c then capi.client.focus = c end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get visible clients from a screen.
|
--- Get visible clients from a screen.
|
||||||
-- @param screen The screen number, or nil for all screens.
|
-- @param screen The screen number, or nil for all screens.
|
||||||
-- @return A table with all visible clients.
|
-- @return A table with all visible clients.
|
||||||
function visible(screen)
|
function client.visible(screen)
|
||||||
local cls = capi.client.get(screen)
|
local cls = capi.client.get(screen)
|
||||||
local vcls = {}
|
local vcls = {}
|
||||||
for k, c in pairs(cls) do
|
for k, c in pairs(cls) do
|
||||||
|
@ -210,12 +211,12 @@ end
|
||||||
--- Get visible and tiled clients
|
--- Get visible and tiled clients
|
||||||
-- @param screen The screen number, or nil for all screens.
|
-- @param screen The screen number, or nil for all screens.
|
||||||
-- @return A tabl with all visible and tiled clients.
|
-- @return A tabl with all visible and tiled clients.
|
||||||
function tiled(screen)
|
function client.tiled(screen)
|
||||||
local clients = visible(screen)
|
local clients = client.visible(screen)
|
||||||
local tclients = {}
|
local tclients = {}
|
||||||
-- Remove floating clients
|
-- Remove floating clients
|
||||||
for k, c in pairs(clients) do
|
for k, c in pairs(clients) do
|
||||||
if not floating.get(c) then
|
if not client.floating.get(c) then
|
||||||
table.insert(tclients, c)
|
table.insert(tclients, c)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -227,16 +228,16 @@ end
|
||||||
-- @param i The index.
|
-- @param i The index.
|
||||||
-- @param c Optional client.
|
-- @param c Optional client.
|
||||||
-- @return A client, or nil if no client is available.
|
-- @return A client, or nil if no client is available.
|
||||||
function next(i, c)
|
function client.next(i, c)
|
||||||
-- Get currently focused client
|
-- Get currently focused client
|
||||||
local sel = c or capi.client.focus
|
local sel = c or capi.client.focus
|
||||||
if sel then
|
if sel then
|
||||||
-- Get all visible clients
|
-- Get all visible clients
|
||||||
local cls = visible(sel.screen)
|
local cls = client.visible(sel.screen)
|
||||||
local fcls = {}
|
local fcls = {}
|
||||||
-- Remove all non-normal clients
|
-- Remove all non-normal clients
|
||||||
for idx, c in ipairs(cls) do
|
for idx, c in ipairs(cls) do
|
||||||
if focus.filter(c) or c == sel then
|
if client.focus.filter(c) or c == sel then
|
||||||
table.insert(fcls, c)
|
table.insert(fcls, c)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -307,7 +308,7 @@ local function get_client_in_direction(dir, c)
|
||||||
local geometry = sel:geometry()
|
local geometry = sel:geometry()
|
||||||
local dist, dist_min
|
local dist, dist_min
|
||||||
local target = nil
|
local target = nil
|
||||||
local cls = visible(sel.screen)
|
local cls = client.visible(sel.screen)
|
||||||
|
|
||||||
-- We check each client.
|
-- We check each client.
|
||||||
for i, c in ipairs(cls) do
|
for i, c in ipairs(cls) do
|
||||||
|
@ -332,7 +333,7 @@ end
|
||||||
--- Focus a client by the given direction.
|
--- Focus a client by the given direction.
|
||||||
-- @param dir The direction, can be either "up", "down", "left" or "right".
|
-- @param dir The direction, can be either "up", "down", "left" or "right".
|
||||||
-- @param c Optional client.
|
-- @param c Optional client.
|
||||||
function focus.bydirection(dir, c)
|
function client.focus.bydirection(dir, c)
|
||||||
local sel = c or capi.client.focus
|
local sel = c or capi.client.focus
|
||||||
if sel then
|
if sel then
|
||||||
local target = get_client_in_direction(dir, sel)
|
local target = get_client_in_direction(dir, sel)
|
||||||
|
@ -347,8 +348,8 @@ end
|
||||||
--- Focus a client by its relative index.
|
--- Focus a client by its relative index.
|
||||||
-- @param i The index.
|
-- @param i The index.
|
||||||
-- @param c Optional client.
|
-- @param c Optional client.
|
||||||
function focus.byidx(i, c)
|
function client.focus.byidx(i, c)
|
||||||
local target = next(i, c)
|
local target = client.next(i, c)
|
||||||
if target then
|
if target then
|
||||||
capi.client.focus = target
|
capi.client.focus = target
|
||||||
end
|
end
|
||||||
|
@ -357,7 +358,7 @@ end
|
||||||
--- Swap a client with another client in the given direction
|
--- Swap a client with another client in the given direction
|
||||||
-- @param dir The direction, can be either "up", "down", "left" or "right".
|
-- @param dir The direction, can be either "up", "down", "left" or "right".
|
||||||
-- @param c Optional client.
|
-- @param c Optional client.
|
||||||
function swap.bydirection(dir, c)
|
function client.swap.bydirection(dir, c)
|
||||||
local sel = c or capi.client.focus
|
local sel = c or capi.client.focus
|
||||||
if sel then
|
if sel then
|
||||||
local target = get_client_in_direction(dir, sel)
|
local target = get_client_in_direction(dir, sel)
|
||||||
|
@ -372,7 +373,7 @@ end
|
||||||
--- Swap a client by its relative index.
|
--- Swap a client by its relative index.
|
||||||
-- @param i The index.
|
-- @param i The index.
|
||||||
-- @param c Optional client, otherwise focused one is used.
|
-- @param c Optional client, otherwise focused one is used.
|
||||||
function swap.byidx(i, c)
|
function client.swap.byidx(i, c)
|
||||||
local sel = c or capi.client.focus
|
local sel = c or capi.client.focus
|
||||||
local target = next(i, sel)
|
local target = next(i, sel)
|
||||||
if target then
|
if target then
|
||||||
|
@ -383,9 +384,9 @@ end
|
||||||
--- Cycle clients.
|
--- Cycle clients.
|
||||||
-- @param clockwise True to cycle clients clockwise.
|
-- @param clockwise True to cycle clients clockwise.
|
||||||
-- @param screen Optional screen where to cycle clients.
|
-- @param screen Optional screen where to cycle clients.
|
||||||
function cycle(clockwise, screen)
|
function client.cycle(clockwise, screen)
|
||||||
local screen = screen or capi.mouse.screen
|
local screen = screen or capi.mouse.screen
|
||||||
local cls = visible(screen)
|
local cls = client.visible(screen)
|
||||||
-- We can't rotate without at least 2 clients, buddy.
|
-- We can't rotate without at least 2 clients, buddy.
|
||||||
if #cls >= 2 then
|
if #cls >= 2 then
|
||||||
local c = table.remove(cls, 1)
|
local c = table.remove(cls, 1)
|
||||||
|
@ -404,14 +405,14 @@ end
|
||||||
--- Get the master window.
|
--- Get the master window.
|
||||||
-- @param screen Optional screen number, otherwise screen mouse is used.
|
-- @param screen Optional screen number, otherwise screen mouse is used.
|
||||||
-- @return The master window.
|
-- @return The master window.
|
||||||
function getmaster(screen)
|
function client.getmaster(screen)
|
||||||
local s = screen or capi.mouse.screen
|
local s = screen or capi.mouse.screen
|
||||||
return visible(s)[1]
|
return client.visible(s)[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set the client as slave: put it at the end of other windows.
|
--- Set the client as slave: put it at the end of other windows.
|
||||||
-- @param c The window to set as slave.
|
-- @param c The window to set as slave.
|
||||||
function setslave(c)
|
function client.setslave(c)
|
||||||
local cls = capi.client.get(c.screen)
|
local cls = capi.client.get(c.screen)
|
||||||
for k, v in pairs(cls) do
|
for k, v in pairs(cls) do
|
||||||
c:swap(v)
|
c:swap(v)
|
||||||
|
@ -424,7 +425,7 @@ end
|
||||||
-- @param w The relative width.
|
-- @param w The relative width.
|
||||||
-- @param h The relative height.
|
-- @param h The relative height.
|
||||||
-- @param c The optional client, otherwise focused one is used.
|
-- @param c The optional client, otherwise focused one is used.
|
||||||
function moveresize(x, y, w, h, c)
|
function client.moveresize(x, y, w, h, c)
|
||||||
local sel = c or capi.client.focus
|
local sel = c or capi.client.focus
|
||||||
local geometry = sel:geometry()
|
local geometry = sel:geometry()
|
||||||
geometry['x'] = geometry['x'] + x
|
geometry['x'] = geometry['x'] + x
|
||||||
|
@ -437,7 +438,7 @@ end
|
||||||
--- Move a client to a tag.
|
--- Move a client to a tag.
|
||||||
-- @param target The tag to move the client to.
|
-- @param target The tag to move the client to.
|
||||||
-- @param c Optional client to move, otherwise the focused one is used.
|
-- @param c Optional client to move, otherwise the focused one is used.
|
||||||
function movetotag(target, c)
|
function client.movetotag(target, c)
|
||||||
local sel = c or capi.client.focus
|
local sel = c or capi.client.focus
|
||||||
if sel and target.screen then
|
if sel and target.screen then
|
||||||
-- Set client on the same screen as the tag.
|
-- Set client on the same screen as the tag.
|
||||||
|
@ -449,7 +450,7 @@ end
|
||||||
--- Toggle a tag on a client.
|
--- Toggle a tag on a client.
|
||||||
-- @param target The tag to toggle.
|
-- @param target The tag to toggle.
|
||||||
-- @param c Optional client to toggle, otherwise the focused one is used.
|
-- @param c Optional client to toggle, otherwise the focused one is used.
|
||||||
function toggletag(target, c)
|
function client.toggletag(target, c)
|
||||||
local sel = c or capi.client.focus
|
local sel = c or capi.client.focus
|
||||||
-- Check that tag and client screen are identical
|
-- Check that tag and client screen are identical
|
||||||
if sel and sel.screen == target.screen then
|
if sel and sel.screen == target.screen then
|
||||||
|
@ -475,7 +476,7 @@ end
|
||||||
--- Move a client to a screen. Default is next screen, cycling.
|
--- Move a client to a screen. Default is next screen, cycling.
|
||||||
-- @param c The client to move.
|
-- @param c The client to move.
|
||||||
-- @param s The screen number, default to current + 1.
|
-- @param s The screen number, default to current + 1.
|
||||||
function movetoscreen(c, s)
|
function client.movetoscreen(c, s)
|
||||||
local sel = c or capi.client.focus
|
local sel = c or capi.client.focus
|
||||||
if sel then
|
if sel then
|
||||||
local sc = capi.screen.count()
|
local sc = capi.screen.count()
|
||||||
|
@ -491,16 +492,16 @@ end
|
||||||
--- Mark a client, and then call 'marked' hook.
|
--- Mark a client, and then call 'marked' hook.
|
||||||
-- @param c The client to mark, the focused one if not specified.
|
-- @param c The client to mark, the focused one if not specified.
|
||||||
-- @return True if the client has been marked. False if the client was already marked.
|
-- @return True if the client has been marked. False if the client was already marked.
|
||||||
function mark(c)
|
function client.mark(c)
|
||||||
local cl = c or capi.client.focus
|
local cl = c or capi.client.focus
|
||||||
if cl then
|
if cl then
|
||||||
for k, v in pairs(data.marked) do
|
for k, v in pairs(client.data.marked) do
|
||||||
if cl == v then
|
if cl == v then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(data.marked, cl)
|
table.insert(client.data.marked, cl)
|
||||||
|
|
||||||
-- Call callback
|
-- Call callback
|
||||||
cl:emit_signal("marked")
|
cl:emit_signal("marked")
|
||||||
|
@ -511,12 +512,12 @@ end
|
||||||
--- Unmark a client and then call 'unmarked' hook.
|
--- Unmark a client and then call 'unmarked' hook.
|
||||||
-- @param c The client to unmark, or the focused one if not specified.
|
-- @param c The client to unmark, or the focused one if not specified.
|
||||||
-- @return True if the client has been unmarked. False if the client was not marked.
|
-- @return True if the client has been unmarked. False if the client was not marked.
|
||||||
function unmark(c)
|
function client.unmark(c)
|
||||||
local cl = c or capi.client.focus
|
local cl = c or capi.client.focus
|
||||||
|
|
||||||
for k, v in pairs(data.marked) do
|
for k, v in pairs(client.data.marked) do
|
||||||
if cl == v then
|
if cl == v then
|
||||||
table.remove(data.marked, k)
|
table.remove(client.data.marked, k)
|
||||||
cl:emit_signal("unmarked")
|
cl:emit_signal("unmarked")
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -527,10 +528,10 @@ end
|
||||||
|
|
||||||
--- Check if a client is marked.
|
--- Check if a client is marked.
|
||||||
-- @param c The client to check, or the focused one otherwise.
|
-- @param c The client to check, or the focused one otherwise.
|
||||||
function ismarked(c)
|
function client.ismarked(c)
|
||||||
local cl = c or capi.client.focus
|
local cl = c or capi.client.focus
|
||||||
if cl then
|
if cl then
|
||||||
for k, v in pairs(data.marked) do
|
for k, v in pairs(client.data.marked) do
|
||||||
if cl == v then
|
if cl == v then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -541,23 +542,23 @@ end
|
||||||
|
|
||||||
--- Toggle a client as marked.
|
--- Toggle a client as marked.
|
||||||
-- @param c The client to toggle mark.
|
-- @param c The client to toggle mark.
|
||||||
function togglemarked(c)
|
function client.togglemarked(c)
|
||||||
local cl = c or capi.client.focus
|
local cl = c or capi.client.focus
|
||||||
|
|
||||||
if not mark(c) then
|
if not client.mark(c) then
|
||||||
unmark(c)
|
client.unmark(c)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Return the marked clients and empty the marked table.
|
--- Return the marked clients and empty the marked table.
|
||||||
-- @return A table with all marked clients.
|
-- @return A table with all marked clients.
|
||||||
function getmarked()
|
function client.getmarked()
|
||||||
for k, v in pairs(data.marked) do
|
for k, v in pairs(client.data.marked) do
|
||||||
v:emit_signal("unmarked")
|
v:emit_signal("unmarked")
|
||||||
end
|
end
|
||||||
|
|
||||||
t = data.marked
|
t = client.data.marked
|
||||||
data.marked = {}
|
client.data.marked = {}
|
||||||
return t
|
return t
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -565,28 +566,28 @@ end
|
||||||
-- Floating client are not handled by tiling layouts.
|
-- Floating client are not handled by tiling layouts.
|
||||||
-- @param c A client.
|
-- @param c A client.
|
||||||
-- @param s True or false.
|
-- @param s True or false.
|
||||||
function floating.set(c, s)
|
function client.floating.set(c, s)
|
||||||
local c = c or capi.client.focus
|
local c = c or capi.client.focus
|
||||||
if c and property.get(c, "floating") ~= s then
|
if c and client.property.get(c, "floating") ~= s then
|
||||||
property.set(c, "floating", s)
|
client.property.set(c, "floating", s)
|
||||||
local screen = c.screen
|
local screen = c.screen
|
||||||
if s == true then
|
if s == true then
|
||||||
c:geometry(property.get(c, "floating_geometry"))
|
c:geometry(client.property.get(c, "floating_geometry"))
|
||||||
end
|
end
|
||||||
c.screen = screen
|
c.screen = screen
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function store_floating_geometry(c)
|
local function store_floating_geometry(c)
|
||||||
if floating.get(c) then
|
if client.floating.get(c) then
|
||||||
property.set(c, "floating_geometry", c:geometry())
|
client.property.set(c, "floating_geometry", c:geometry())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Store the initial client geometry.
|
-- Store the initial client geometry.
|
||||||
capi.client.connect_signal("new", function(c)
|
capi.client.connect_signal("new", function(c)
|
||||||
local function store_init_geometry(c)
|
local function store_init_geometry(c)
|
||||||
property.set(c, "floating_geometry", c:geometry())
|
client.property.set(c, "floating_geometry", c:geometry())
|
||||||
c:disconnect_signal("property::border_width", store_init_geometry)
|
c:disconnect_signal("property::border_width", store_init_geometry)
|
||||||
end
|
end
|
||||||
c:connect_signal("property::border_width", store_init_geometry)
|
c:connect_signal("property::border_width", store_init_geometry)
|
||||||
|
@ -598,7 +599,7 @@ end)
|
||||||
|
|
||||||
--- Return if a client has a fixe size or not.
|
--- Return if a client has a fixe size or not.
|
||||||
-- @param c The client.
|
-- @param c The client.
|
||||||
function isfixed(c)
|
function client.isfixed(c)
|
||||||
local c = c or capi.client.focus
|
local c = c or capi.client.focus
|
||||||
if not c then return end
|
if not c then return end
|
||||||
local h = c.size_hints
|
local h = c.size_hints
|
||||||
|
@ -618,10 +619,10 @@ end
|
||||||
-- @return True or false. Note that some windows might be floating even if you
|
-- @return True or false. Note that some windows might be floating even if you
|
||||||
-- did not set them manually. For example, windows with a type different than
|
-- did not set them manually. For example, windows with a type different than
|
||||||
-- normal.
|
-- normal.
|
||||||
function floating.get(c)
|
function client.floating.get(c)
|
||||||
local c = c or capi.client.focus
|
local c = c or capi.client.focus
|
||||||
if c then
|
if c then
|
||||||
local value = property.get(c, "floating")
|
local value = client.property.get(c, "floating")
|
||||||
if value ~= nil then
|
if value ~= nil then
|
||||||
return value
|
return value
|
||||||
end
|
end
|
||||||
|
@ -629,7 +630,7 @@ function floating.get(c)
|
||||||
or c.fullscreen
|
or c.fullscreen
|
||||||
or c.maximized_vertical
|
or c.maximized_vertical
|
||||||
or c.maximized_horizontal
|
or c.maximized_horizontal
|
||||||
or isfixed(c) then
|
or client.isfixed(c) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
|
@ -638,26 +639,26 @@ end
|
||||||
|
|
||||||
--- Toggle the floating state of a client between 'auto' and 'true'.
|
--- Toggle the floating state of a client between 'auto' and 'true'.
|
||||||
-- @param c A client.
|
-- @param c A client.
|
||||||
function floating.toggle(c)
|
function client.floating.toggle(c)
|
||||||
local c = c or capi.client.focus
|
local c = c or capi.client.focus
|
||||||
-- If it has been set to floating
|
-- If it has been set to floating
|
||||||
if floating.get(c) then
|
if client.floating.get(c) then
|
||||||
floating.set(c, false)
|
client.floating.set(c, false)
|
||||||
else
|
else
|
||||||
floating.set(c, true)
|
client.floating.set(c, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Remove the floating information on a client.
|
--- Remove the floating information on a client.
|
||||||
-- @param c The client.
|
-- @param c The client.
|
||||||
function floating.delete(c)
|
function client.floating.delete(c)
|
||||||
floating.set(c, nil)
|
client.floating.set(c, nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Restore (=unminimize) a random client.
|
--- Restore (=unminimize) a random client.
|
||||||
-- @param s The screen to use.
|
-- @param s The screen to use.
|
||||||
-- @return True if some client was restored.
|
-- @return True if some client was restored.
|
||||||
function restore(s)
|
function client.restore(s)
|
||||||
local s = s or (capi.client.focus and capi.client.focus.screen) or capi.mouse.screen
|
local s = s or (capi.client.focus and capi.client.focus.screen) or capi.mouse.screen
|
||||||
local cls = capi.client.get(s)
|
local cls = capi.client.get(s)
|
||||||
local tags = tag.selectedlist(s)
|
local tags = tag.selectedlist(s)
|
||||||
|
@ -706,11 +707,11 @@ end
|
||||||
-- @return col the column number
|
-- @return col the column number
|
||||||
-- @return idx index of the client in the column
|
-- @return idx index of the client in the column
|
||||||
-- @return num the number of visible clients in the column
|
-- @return num the number of visible clients in the column
|
||||||
function idx(c)
|
function client.idx(c)
|
||||||
local c = c or capi.client.focus
|
local c = c or capi.client.focus
|
||||||
if not c then return end
|
if not c then return end
|
||||||
|
|
||||||
local clients = tiled(c.screen)
|
local clients = client.tiled(c.screen)
|
||||||
local idx = nil
|
local idx = nil
|
||||||
for k, cl in ipairs(clients) do
|
for k, cl in ipairs(clients) do
|
||||||
if cl == c then
|
if cl == c then
|
||||||
|
@ -758,15 +759,15 @@ end
|
||||||
--- Set the window factor of a client
|
--- Set the window factor of a client
|
||||||
-- @param wfact the window factor value
|
-- @param wfact the window factor value
|
||||||
-- @param c the client
|
-- @param c the client
|
||||||
function setwfact(wfact, c)
|
function client.setwfact(wfact, c)
|
||||||
-- get the currently selected window
|
-- get the currently selected window
|
||||||
local c = c or capi.client.focus
|
local c = c or capi.client.focus
|
||||||
if not c or not c:isvisible() then return end
|
if not c or not c:isvisible() then return end
|
||||||
|
|
||||||
local t = tag.selected(c.screen)
|
local t = tag.selected(c.screen)
|
||||||
local w = idx(c)
|
local w = client.idx(c)
|
||||||
|
|
||||||
local cls = tiled(t.screen)
|
local cls = client.tiled(t.screen)
|
||||||
local nmaster = tag.getnmaster(t)
|
local nmaster = tag.getnmaster(t)
|
||||||
|
|
||||||
-- n is the number of windows currently visible for which we have to be concerned with the properties
|
-- n is the number of windows currently visible for which we have to be concerned with the properties
|
||||||
|
@ -797,13 +798,13 @@ end
|
||||||
--- Increment a client's window factor
|
--- Increment a client's window factor
|
||||||
-- @param add amount to increase the client's window
|
-- @param add amount to increase the client's window
|
||||||
-- @param c the client
|
-- @param c the client
|
||||||
function incwfact(add, c)
|
function client.incwfact(add, c)
|
||||||
local c = c or capi.client.focus
|
local c = c or capi.client.focus
|
||||||
if not c then return end
|
if not c then return end
|
||||||
|
|
||||||
local t = tag.selected(c.screen)
|
local t = tag.selected(c.screen)
|
||||||
|
|
||||||
local w = idx(c)
|
local w = client.idx(c)
|
||||||
|
|
||||||
local nmaster = tag.getnmaster(t)
|
local nmaster = tag.getnmaster(t)
|
||||||
local data = tag.getproperty(t, "windowfact") or {}
|
local data = tag.getproperty(t, "windowfact") or {}
|
||||||
|
@ -822,8 +823,8 @@ end
|
||||||
-- @return True or false. Note that some windows might be dockable even if you
|
-- @return True or false. Note that some windows might be dockable even if you
|
||||||
-- did not set them manually. For example, windows with a type "utility", "toolbar"
|
-- did not set them manually. For example, windows with a type "utility", "toolbar"
|
||||||
-- or "dock"
|
-- or "dock"
|
||||||
function dockable.get(c)
|
function client.dockable.get(c)
|
||||||
local value = property.get(c, "dockable")
|
local value = client.property.get(c, "dockable")
|
||||||
|
|
||||||
-- Some sane defaults
|
-- Some sane defaults
|
||||||
if value == nil then
|
if value == nil then
|
||||||
|
@ -842,17 +843,17 @@ end
|
||||||
-- to the edge of the workarea.
|
-- to the edge of the workarea.
|
||||||
-- @param c A client.
|
-- @param c A client.
|
||||||
-- @param value True or false.
|
-- @param value True or false.
|
||||||
function dockable.set(c, value)
|
function client.dockable.set(c, value)
|
||||||
property.set(c, "dockable", value)
|
client.property.set(c, "dockable", value)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get a client property.
|
--- Get a client property.
|
||||||
-- @param c The client.
|
-- @param c The client.
|
||||||
-- @param prop The property name.
|
-- @param prop The property name.
|
||||||
-- @return The property.
|
-- @return The property.
|
||||||
function property.get(c, prop)
|
function client.property.get(c, prop)
|
||||||
if data.properties[c] then
|
if client.data.properties[c] then
|
||||||
return data.properties[c][prop]
|
return client.data.properties[c][prop]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -861,11 +862,11 @@ end
|
||||||
-- @param c The client.
|
-- @param c The client.
|
||||||
-- @param prop The property name.
|
-- @param prop The property name.
|
||||||
-- @param value The value.
|
-- @param value The value.
|
||||||
function property.set(c, prop, value)
|
function client.property.set(c, prop, value)
|
||||||
if not data.properties[c] then
|
if not client.data.properties[c] then
|
||||||
data.properties[c] = {}
|
client.data.properties[c] = {}
|
||||||
end
|
end
|
||||||
data.properties[c][prop] = value
|
client.data.properties[c][prop] = value
|
||||||
c:emit_signal("property::" .. prop)
|
c:emit_signal("property::" .. prop)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -888,7 +889,7 @@ end
|
||||||
-- c.minimized = false <br/>
|
-- c.minimized = false <br/>
|
||||||
-- end <br/>
|
-- end <br/>
|
||||||
-- </code></p>
|
-- </code></p>
|
||||||
function iterate(filter, start, s)
|
function client.iterate(filter, start, s)
|
||||||
local clients = capi.client.get(s)
|
local clients = capi.client.get(s)
|
||||||
local focused = capi.client.focus
|
local focused = capi.client.focus
|
||||||
local start = start or util.table.hasitem(clients, focused)
|
local start = start or util.table.hasitem(clients, focused)
|
||||||
|
@ -913,13 +914,13 @@ end
|
||||||
-- awful.client.run_or_raise('urxvt', matcher)
|
-- awful.client.run_or_raise('urxvt', matcher)
|
||||||
-- end);
|
-- end);
|
||||||
-- </code></p>
|
-- </code></p>
|
||||||
function run_or_raise(cmd, matcher, merge)
|
function client.run_or_raise(cmd, matcher, merge)
|
||||||
local clients = capi.client.get()
|
local clients = capi.client.get()
|
||||||
local findex = util.table.hasitem(clients, capi.client.focus) or 1
|
local findex = util.table.hasitem(clients, capi.client.focus) or 1
|
||||||
local start = util.cycle(#clients, findex + 1)
|
local start = util.cycle(#clients, findex + 1)
|
||||||
|
|
||||||
for c in iterate(matcher, start) do
|
for c in iterate(matcher, start) do
|
||||||
jumpto(c, merge)
|
client.jumpto(c, merge)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -932,13 +933,15 @@ capi.client.add_signal("property::floating_geometry")
|
||||||
capi.client.add_signal("property::floating")
|
capi.client.add_signal("property::floating")
|
||||||
capi.client.add_signal("property::dockable")
|
capi.client.add_signal("property::dockable")
|
||||||
|
|
||||||
capi.client.connect_signal("focus", focus.history.add)
|
capi.client.connect_signal("focus", client.focus.history.add)
|
||||||
capi.client.connect_signal("unmanage", focus.history.delete)
|
capi.client.connect_signal("unmanage", client.focus.history.delete)
|
||||||
|
|
||||||
capi.client.connect_signal("manage", function(c) c:connect_signal("property::urgent", urgent.add) end)
|
capi.client.connect_signal("manage", function(c) c:connect_signal("property::urgent", client.urgent.add) end)
|
||||||
capi.client.connect_signal("focus", urgent.delete)
|
capi.client.connect_signal("focus", client.urgent.delete)
|
||||||
capi.client.connect_signal("unmanage", urgent.delete)
|
capi.client.connect_signal("unmanage", client.urgent.delete)
|
||||||
|
|
||||||
capi.client.connect_signal("unmanage", floating.delete)
|
capi.client.connect_signal("unmanage", client.floating.delete)
|
||||||
|
|
||||||
|
return client
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
|
@ -17,7 +17,8 @@ local util = require("awful.util")
|
||||||
|
|
||||||
--- Completion module.
|
--- Completion module.
|
||||||
-- This module store a set of function using shell to complete commands name.
|
-- This module store a set of function using shell to complete commands name.
|
||||||
module("awful.completion")
|
-- awful.completion
|
||||||
|
local completion = {}
|
||||||
|
|
||||||
-- mapping of command/completion function
|
-- mapping of command/completion function
|
||||||
local bashcomp_funcs = {}
|
local bashcomp_funcs = {}
|
||||||
|
@ -26,7 +27,7 @@ local bashcomp_src = "@SYSCONFDIR@/bash_completion"
|
||||||
--- Enable programmable bash completion in awful.completion.bash at the price of
|
--- Enable programmable bash completion in awful.completion.bash at the price of
|
||||||
-- a slight overhead.
|
-- a slight overhead.
|
||||||
-- @param src The bash completion source file, /etc/bash_completion by default.
|
-- @param src The bash completion source file, /etc/bash_completion by default.
|
||||||
function bashcomp_load(src)
|
function completion.bashcomp_load(src)
|
||||||
if src then bashcomp_src = src end
|
if src then bashcomp_src = src end
|
||||||
local c, err = io.popen("/usr/bin/env bash -c 'source " .. bashcomp_src .. "; complete -p'")
|
local c, err = io.popen("/usr/bin/env bash -c 'source " .. bashcomp_src .. "; complete -p'")
|
||||||
if c then
|
if c then
|
||||||
|
@ -59,7 +60,7 @@ end
|
||||||
-- @param ncomp The element number to complete.
|
-- @param ncomp The element number to complete.
|
||||||
-- @param shell The shell to use for completion (bash (default) or zsh).
|
-- @param shell The shell to use for completion (bash (default) or zsh).
|
||||||
-- @return The new command, the new cursor position, the table of all matches.
|
-- @return The new command, the new cursor position, the table of all matches.
|
||||||
function shell(command, cur_pos, ncomp, shell)
|
function completion.shell(command, cur_pos, ncomp, shell)
|
||||||
local wstart = 1
|
local wstart = 1
|
||||||
local wend = 1
|
local wend = 1
|
||||||
local words = {}
|
local words = {}
|
||||||
|
@ -160,7 +161,7 @@ end
|
||||||
-- @param ncomp The number of yet requested completion using current text.
|
-- @param ncomp The number of yet requested completion using current text.
|
||||||
-- @param keywords The keywords table uised for completion.
|
-- @param keywords The keywords table uised for completion.
|
||||||
-- @return The new match, the new cursor position, the table of all matches.
|
-- @return The new match, the new cursor position, the table of all matches.
|
||||||
function generic(text, cur_pos, ncomp, keywords)
|
function completion.generic(text, cur_pos, ncomp, keywords)
|
||||||
-- The keywords table may be empty
|
-- The keywords table may be empty
|
||||||
if #keywords == 0 then
|
if #keywords == 0 then
|
||||||
return text, #text + 1
|
return text, #text + 1
|
||||||
|
@ -191,4 +192,6 @@ function generic(text, cur_pos, ncomp, keywords)
|
||||||
return matches[ncomp], #matches[ncomp] + 1, matches
|
return matches[ncomp], #matches[ncomp] + 1, matches
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return completion
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
|
@ -10,7 +10,7 @@ local dbus = dbus
|
||||||
--- D-Bus module for awful.
|
--- D-Bus module for awful.
|
||||||
-- This module simply request the org.naquadah.awesome.awful name on the D-Bus
|
-- This module simply request the org.naquadah.awesome.awful name on the D-Bus
|
||||||
-- for futur usage by other awful modules.
|
-- for futur usage by other awful modules.
|
||||||
module("awful.dbus")
|
-- awful.dbus
|
||||||
|
|
||||||
if dbus then
|
if dbus then
|
||||||
dbus.request_name("session", "org.naquadah.awesome.awful")
|
dbus.request_name("session", "org.naquadah.awesome.awful")
|
||||||
|
|
|
@ -11,7 +11,7 @@ local ipairs = ipairs
|
||||||
local math = math
|
local math = math
|
||||||
|
|
||||||
--- Implements EWMH requests handling.
|
--- Implements EWMH requests handling.
|
||||||
module("awful.ewmh")
|
-- awful.ewmh
|
||||||
|
|
||||||
local data = setmetatable({}, { __mode = 'k' })
|
local data = setmetatable({}, { __mode = 'k' })
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,12 @@ local client = client
|
||||||
local math = math
|
local math = math
|
||||||
|
|
||||||
--- Implements ICCCM handling.
|
--- Implements ICCCM handling.
|
||||||
module("awful.icccm")
|
-- awful.icccm
|
||||||
|
|
||||||
-- Make sure we don't get into an endless loop
|
-- Make sure we don't get into an endless loop
|
||||||
local size_hints_lock = false
|
local size_hints_lock = false
|
||||||
|
|
||||||
function apply_size_hints(c)
|
local function apply_size_hints(c)
|
||||||
if size_hints_lock then return end
|
if size_hints_lock then return end
|
||||||
if not c.size_hints_honor then return end
|
if not c.size_hints_honor then return end
|
||||||
-- Fullscreen clients don't get size hints applied!
|
-- Fullscreen clients don't get size hints applied!
|
||||||
|
|
|
@ -4,28 +4,31 @@
|
||||||
-- @release @AWESOME_VERSION@
|
-- @release @AWESOME_VERSION@
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
require("awful.client")
|
|
||||||
require("awful.completion")
|
|
||||||
require("awful.layout")
|
|
||||||
require("awful.placement")
|
|
||||||
require("awful.prompt")
|
|
||||||
require("awful.screen")
|
|
||||||
require("awful.tag")
|
|
||||||
require("awful.util")
|
|
||||||
require("awful.widget")
|
|
||||||
require("awful.keygrabber")
|
|
||||||
require("awful.menu")
|
|
||||||
require("awful.mouse")
|
|
||||||
require("awful.remote")
|
|
||||||
require("awful.key")
|
|
||||||
require("awful.button")
|
|
||||||
require("awful.wibox")
|
|
||||||
require("awful.startup_notification")
|
|
||||||
require("awful.tooltip")
|
|
||||||
require("awful.ewmh")
|
|
||||||
require("awful.icccm")
|
|
||||||
|
|
||||||
--- AWesome Functions very UsefuL
|
--- AWesome Functions very UsefuL
|
||||||
module("awful")
|
-- awful
|
||||||
|
|
||||||
|
return
|
||||||
|
{
|
||||||
|
client = require("awful.client");
|
||||||
|
completion = require("awful.completion");
|
||||||
|
layout = require("awful.layout");
|
||||||
|
placement = require("awful.placement");
|
||||||
|
prompt = require("awful.prompt");
|
||||||
|
screen = require("awful.screen");
|
||||||
|
tag = require("awful.tag");
|
||||||
|
util = require("awful.util");
|
||||||
|
widget = require("awful.widget");
|
||||||
|
keygrabber = require("awful.keygrabber");
|
||||||
|
menu = require("awful.menu");
|
||||||
|
mouse = require("awful.mouse");
|
||||||
|
remote = require("awful.remote");
|
||||||
|
key = require("awful.key");
|
||||||
|
button = require("awful.button");
|
||||||
|
wibox = require("awful.wibox");
|
||||||
|
startup_notification = require("awful.startup_notification");
|
||||||
|
tooltip = require("awful.tooltip");
|
||||||
|
ewmh = require("awful.ewmh");
|
||||||
|
icccm = require("awful.icccm");
|
||||||
|
}
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
|
@ -11,7 +11,8 @@ local capi = { key = key }
|
||||||
local util = require("awful.util")
|
local util = require("awful.util")
|
||||||
|
|
||||||
--- Create easily new key objects ignoring certain modifiers.
|
--- Create easily new key objects ignoring certain modifiers.
|
||||||
module("awful.key")
|
-- awful.key
|
||||||
|
local key = { mt = {} }
|
||||||
|
|
||||||
--- Modifiers to ignore.
|
--- Modifiers to ignore.
|
||||||
-- By default this is initialized as { "Lock", "Mod2" }
|
-- By default this is initialized as { "Lock", "Mod2" }
|
||||||
|
@ -19,7 +20,7 @@ module("awful.key")
|
||||||
-- when pressing keys.
|
-- when pressing keys.
|
||||||
-- @name ignore_modifiers
|
-- @name ignore_modifiers
|
||||||
-- @class table
|
-- @class table
|
||||||
ignore_modifiers = { "Lock", "Mod2" }
|
local ignore_modifiers = { "Lock", "Mod2" }
|
||||||
|
|
||||||
--- Create a new key to use as binding.
|
--- Create a new key to use as binding.
|
||||||
-- This function is useful to create several keys from one, because it will use
|
-- This function is useful to create several keys from one, because it will use
|
||||||
|
@ -31,12 +32,12 @@ ignore_modifiers = { "Lock", "Mod2" }
|
||||||
-- CapsLock off.
|
-- CapsLock off.
|
||||||
-- @see capi.key
|
-- @see capi.key
|
||||||
-- @return A table with one or several key objects.
|
-- @return A table with one or several key objects.
|
||||||
function new(mod, key, press, release)
|
function key.new(mod, _key, press, release)
|
||||||
local ret = {}
|
local ret = {}
|
||||||
local subsets = util.subsets(ignore_modifiers)
|
local subsets = util.subsets(ignore_modifiers)
|
||||||
for _, set in ipairs(subsets) do
|
for _, set in ipairs(subsets) do
|
||||||
ret[#ret + 1] = capi.key({ modifiers = util.table.join(mod, set),
|
ret[#ret + 1] = capi.key({ modifiers = util.table.join(mod, set),
|
||||||
key = key })
|
key = _key })
|
||||||
if press then
|
if press then
|
||||||
ret[#ret]:connect_signal("press", function(kobj, ...) press(...) end)
|
ret[#ret]:connect_signal("press", function(kobj, ...) press(...) end)
|
||||||
end
|
end
|
||||||
|
@ -51,11 +52,11 @@ end
|
||||||
-- @param key The key object.
|
-- @param key The key object.
|
||||||
-- @param pressed_mod The modifiers to compare with.
|
-- @param pressed_mod The modifiers to compare with.
|
||||||
-- @param pressed_key The key to compare with.
|
-- @param pressed_key The key to compare with.
|
||||||
function match(key, pressed_mod, pressed_key)
|
function key.match(_key, pressed_mod, pressed_key)
|
||||||
-- First, compare key.
|
-- First, compare key.
|
||||||
if pressed_key ~= key.key then return false end
|
if pressed_key ~= _key.key then return false end
|
||||||
-- Then, compare mod
|
-- Then, compare mod
|
||||||
local mod = key.modifiers
|
local mod = _key.modifiers
|
||||||
-- For each modifier of the key object, check that the modifier has been
|
-- For each modifier of the key object, check that the modifier has been
|
||||||
-- pressed.
|
-- pressed.
|
||||||
for _, m in ipairs(mod) do
|
for _, m in ipairs(mod) do
|
||||||
|
@ -70,6 +71,10 @@ function match(key, pressed_mod, pressed_key)
|
||||||
return #pressed_mod == #mod
|
return #pressed_mod == #mod
|
||||||
end
|
end
|
||||||
|
|
||||||
setmetatable(_M, { __call = function(_, ...) return new(...) end })
|
function key.mt:__call(...)
|
||||||
|
return key.new(...)
|
||||||
|
end
|
||||||
|
|
||||||
|
return setmetatable(key, key.mt)
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
|
@ -10,7 +10,8 @@ local capi = {
|
||||||
keygrabber = keygrabber }
|
keygrabber = keygrabber }
|
||||||
|
|
||||||
--- Keygrabber Stack
|
--- Keygrabber Stack
|
||||||
module("awful.keygrabber")
|
-- awful.keygrabber
|
||||||
|
local keygrabber = {}
|
||||||
|
|
||||||
-- Private data
|
-- Private data
|
||||||
local grabbers = {}
|
local grabbers = {}
|
||||||
|
@ -29,7 +30,7 @@ end
|
||||||
--- Stop grabbing the keyboard for the provided callback.
|
--- Stop grabbing the keyboard for the provided callback.
|
||||||
-- When no callback is given, the least grabber gets removed (last one added to the stack).
|
-- When no callback is given, the least grabber gets removed (last one added to the stack).
|
||||||
-- @param g The key grabber that must be removed.
|
-- @param g The key grabber that must be removed.
|
||||||
function stop(g)
|
function keygrabber.stop(g)
|
||||||
for i, v in ipairs(grabbers) do
|
for i, v in ipairs(grabbers) do
|
||||||
if v == g then
|
if v == g then
|
||||||
table.remove(grabbers, i)
|
table.remove(grabbers, i)
|
||||||
|
@ -71,9 +72,9 @@ end
|
||||||
-- end) <br/>
|
-- end) <br/>
|
||||||
-- end <br/>
|
-- end <br/>
|
||||||
-- </code></p>
|
-- </code></p>
|
||||||
function run(g)
|
function keygrabber.run(g)
|
||||||
-- Remove the grabber if its in stack
|
-- Remove the grabber if its in stack
|
||||||
stop(g)
|
keygrabber.stop(g)
|
||||||
-- Record the grabber has latest added
|
-- Record the grabber has latest added
|
||||||
table.insert(grabbers, 1, g)
|
table.insert(grabbers, 1, g)
|
||||||
-- start the keygrabber if its not running already
|
-- start the keygrabber if its not running already
|
||||||
|
@ -84,4 +85,6 @@ function run(g)
|
||||||
return g
|
return g
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return keygrabber
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
|
@ -32,7 +32,8 @@ local capi = {
|
||||||
client = client }
|
client = client }
|
||||||
|
|
||||||
|
|
||||||
module("awful.menu")
|
-- awful.menu
|
||||||
|
local menu = { mt = {} }
|
||||||
|
|
||||||
|
|
||||||
local table_update = function (t, set)
|
local table_update = function (t, set)
|
||||||
|
@ -98,16 +99,16 @@ local function load_theme(a, b)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function item_position(menu, child)
|
local function item_position(_menu, child)
|
||||||
local in_dir, other, a, b = 0, 0, "height", "width"
|
local in_dir, other, a, b = 0, 0, "height", "width"
|
||||||
local dir = menu.layout.get_dir and menu.layout:get_dir() or "y"
|
local dir = _menu.layout.get_dir and _menu.layout:get_dir() or "y"
|
||||||
if dir == "x" then a, b = b, a end
|
if dir == "x" then a, b = b, a end
|
||||||
|
|
||||||
local in_dir, other = 0, menu[b]
|
local in_dir, other = 0, _menu[b]
|
||||||
local num = util.table.hasitem(menu.child, child)
|
local num = util.table.hasitem(_menu.child, child)
|
||||||
if num then
|
if num then
|
||||||
for i = 0, num - 1 do
|
for i = 0, num - 1 do
|
||||||
local item = menu.items[i]
|
local item = _menu.items[i]
|
||||||
if item then
|
if item then
|
||||||
other = math.max(other, item[b])
|
other = math.max(other, item[b])
|
||||||
in_dir = in_dir + item[a]
|
in_dir = in_dir + item[a]
|
||||||
|
@ -120,104 +121,104 @@ local function item_position(menu, child)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function set_coords(menu, screen_idx, m_coords)
|
local function set_coords(_menu, screen_idx, m_coords)
|
||||||
local s_geometry = capi.screen[screen_idx].workarea
|
local s_geometry = capi.screen[screen_idx].workarea
|
||||||
local screen_w = s_geometry.x + s_geometry.width
|
local screen_w = s_geometry.x + s_geometry.width
|
||||||
local screen_h = s_geometry.y + s_geometry.height
|
local screen_h = s_geometry.y + s_geometry.height
|
||||||
|
|
||||||
menu.width = menu.wibox.width
|
_menu.width = _menu.wibox.width
|
||||||
menu.height = menu.wibox.height
|
_menu.height = _menu.wibox.height
|
||||||
|
|
||||||
menu.x = menu.wibox.x
|
_menu.x = _menu.wibox.x
|
||||||
menu.y = menu.wibox.y
|
_menu.y = _menu.wibox.y
|
||||||
|
|
||||||
if menu.parent then
|
if _menu.parent then
|
||||||
local w, h = item_position(menu.parent, menu)
|
local w, h = item_position(_menu.parent, _menu)
|
||||||
w = w + menu.parent.theme.border_width
|
w = w + _menu.parent.theme.border_width
|
||||||
|
|
||||||
menu.y = menu.parent.y + h + menu.height > screen_h and
|
_menu.y = _menu.parent.y + h + _menu.height > screen_h and
|
||||||
screen_h - menu.height or menu.parent.y + h
|
screen_h - _menu.height or _menu.parent.y + h
|
||||||
menu.x = menu.parent.x + w + menu.width > screen_w and
|
_menu.x = _menu.parent.x + w + _menu.width > screen_w and
|
||||||
menu.parent.x - menu.width or menu.parent.x + w
|
_menu.parent.x - _menu.width or _menu.parent.x + w
|
||||||
else
|
else
|
||||||
if m_coords == nil then
|
if m_coords == nil then
|
||||||
m_coords = capi.mouse.coords()
|
m_coords = capi.mouse.coords()
|
||||||
m_coords.x = m_coords.x + 1
|
m_coords.x = m_coords.x + 1
|
||||||
m_coords.y = m_coords.y + 1
|
m_coords.y = m_coords.y + 1
|
||||||
end
|
end
|
||||||
menu.y = m_coords.y < s_geometry.y and s_geometry.y or m_coords.y
|
_menu.y = m_coords.y < s_geometry.y and s_geometry.y or m_coords.y
|
||||||
menu.x = m_coords.x < s_geometry.x and s_geometry.x or m_coords.x
|
_menu.x = m_coords.x < s_geometry.x and s_geometry.x or m_coords.x
|
||||||
|
|
||||||
menu.y = menu.y + menu.height > screen_h and
|
_menu.y = _menu.y + _menu.height > screen_h and
|
||||||
screen_h - menu.height or menu.y
|
screen_h - _menu.height or _menu.y
|
||||||
menu.x = menu.x + menu.width > screen_w and
|
_menu.x = _menu.x + _menu.width > screen_w and
|
||||||
screen_w - menu.width or menu.x
|
screen_w - _menu.width or _menu.x
|
||||||
end
|
end
|
||||||
|
|
||||||
menu.wibox.x = menu.x
|
_menu.wibox.x = _menu.x
|
||||||
menu.wibox.y = menu.y
|
_menu.wibox.y = _menu.y
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function set_size(menu)
|
local function set_size(_menu)
|
||||||
local in_dir, other, a, b = 0, 0, "height", "width"
|
local in_dir, other, a, b = 0, 0, "height", "width"
|
||||||
local dir = menu.layout.get_dir and menu.layout:get_dir() or "y"
|
local dir = _menu.layout.get_dir and _menu.layout:get_dir() or "y"
|
||||||
if dir == "x" then a, b = b, a end
|
if dir == "x" then a, b = b, a end
|
||||||
for _, item in ipairs(menu.items) do
|
for _, item in ipairs(_menu.items) do
|
||||||
other = math.max(other, item[b])
|
other = math.max(other, item[b])
|
||||||
in_dir = in_dir + item[a]
|
in_dir = in_dir + item[a]
|
||||||
end
|
end
|
||||||
menu[a], menu[b] = in_dir, other
|
_menu[a], _menu[b] = in_dir, other
|
||||||
if in_dir > 0 and other > 0 then
|
if in_dir > 0 and other > 0 then
|
||||||
menu.wibox[a] = in_dir
|
_menu.wibox[a] = in_dir
|
||||||
menu.wibox[b] = other
|
_menu.wibox[b] = other
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function check_access_key(menu, key)
|
local function check_access_key(_menu, key)
|
||||||
for i, item in ipairs(menu.items) do
|
for i, item in ipairs(_menu.items) do
|
||||||
if item.akey == key then
|
if item.akey == key then
|
||||||
menu:item_enter(i)
|
_menu:item_enter(i)
|
||||||
menu:exec(i, { exec = true })
|
_menu:exec(i, { exec = true })
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if menu.parent then
|
if _menu.parent then
|
||||||
check_access_key(menu.parent, key)
|
check_access_key(_menu.parent, key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function grabber(menu, mod, key, event)
|
local function grabber(_menu, mod, key, event)
|
||||||
if event ~= "press" then return end
|
if event ~= "press" then return end
|
||||||
|
|
||||||
local sel = menu.sel or 0
|
local sel = _menu.sel or 0
|
||||||
if util.table.hasitem(menu_keys.up, key) then
|
if util.table.hasitem(menu_keys.up, key) then
|
||||||
local sel_new = sel-1 < 1 and #menu.items or sel-1
|
local sel_new = sel-1 < 1 and #_menu.items or sel-1
|
||||||
menu:item_enter(sel_new)
|
_menu:item_enter(sel_new)
|
||||||
elseif util.table.hasitem(menu_keys.down, key) then
|
elseif util.table.hasitem(menu_keys.down, key) then
|
||||||
local sel_new = sel+1 > #menu.items and 1 or sel+1
|
local sel_new = sel+1 > #_menu.items and 1 or sel+1
|
||||||
menu:item_enter(sel_new)
|
_menu:item_enter(sel_new)
|
||||||
elseif sel > 0 and util.table.hasitem(menu_keys.enter, key) then
|
elseif sel > 0 and util.table.hasitem(menu_keys.enter, key) then
|
||||||
menu:exec(sel)
|
_menu:exec(sel)
|
||||||
elseif sel > 0 and util.table.hasitem(menu_keys.exec, key) then
|
elseif sel > 0 and util.table.hasitem(menu_keys.exec, key) then
|
||||||
menu:exec(sel, { exec = true })
|
_menu:exec(sel, { exec = true })
|
||||||
elseif util.table.hasitem(menu_keys.back, key) then
|
elseif util.table.hasitem(menu_keys.back, key) then
|
||||||
menu:hide()
|
_menu:hide()
|
||||||
elseif util.table.hasitem(menu_keys.close, key) then
|
elseif util.table.hasitem(menu_keys.close, key) then
|
||||||
get_root(menu):hide()
|
menu.get_root(_menu):hide()
|
||||||
else
|
else
|
||||||
check_access_key(menu, key)
|
check_access_key(_menu, key)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function exec(menu, num, opts)
|
function menu.exec(_menu, num, opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
local item = menu.items[num]
|
local item = _menu.items[num]
|
||||||
if not item then return end
|
if not item then return end
|
||||||
local cmd = item.cmd
|
local cmd = item.cmd
|
||||||
if type(cmd) == "table" then
|
if type(cmd) == "table" then
|
||||||
|
@ -228,41 +229,41 @@ function exec(menu, num, opts)
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if not menu.child[num] then
|
if not _menu.child[num] then
|
||||||
menu.child[num] = new(cmd, menu)
|
_menu.child[num] = menu.new(cmd, _menu)
|
||||||
end
|
end
|
||||||
local can_invoke_action = opts.exec and
|
local can_invoke_action = opts.exec and
|
||||||
action and type(action) == "function" and
|
action and type(action) == "function" and
|
||||||
(not opts.mouse or (opts.mouse and (menu.auto_expand or
|
(not opts.mouse or (opts.mouse and (_menu.auto_expand or
|
||||||
(menu.active_child == menu.child[num] and
|
(_menu.active_child == _menu.child[num] and
|
||||||
menu.active_child.wibox.visible))))
|
_menu.active_child.wibox.visible))))
|
||||||
if can_invoke_action then
|
if can_invoke_action then
|
||||||
local visible = action(menu.child[num], item)
|
local visible = action(_menu.child[num], item)
|
||||||
if not visible then
|
if not visible then
|
||||||
get_root(menu):hide()
|
menu.get_root(_menu):hide()
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
menu.child[num]:update()
|
_menu.child[num]:update()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if menu.active_child and menu.active_child ~= menu.child[num] then
|
if _menu.active_child and _menu.active_child ~= _menu.child[num] then
|
||||||
menu.active_child:hide()
|
_menu.active_child:hide()
|
||||||
end
|
end
|
||||||
menu.active_child = menu.child[num]
|
_menu.active_child = _menu.child[num]
|
||||||
if not menu.active_child.visible then
|
if not _menu.active_child.visible then
|
||||||
menu.active_child:show()
|
_menu.active_child:show()
|
||||||
end
|
end
|
||||||
elseif type(cmd) == "string" then
|
elseif type(cmd) == "string" then
|
||||||
get_root(menu):hide()
|
menu.get_root(_menu):hide()
|
||||||
util.spawn(cmd)
|
util.spawn(cmd)
|
||||||
elseif type(cmd) == "function" then
|
elseif type(cmd) == "function" then
|
||||||
local visible, action = cmd(item, menu)
|
local visible, action = cmd(item, _menu)
|
||||||
if not visible then
|
if not visible then
|
||||||
get_root(menu):hide()
|
menu.get_root(_menu):hide()
|
||||||
else
|
else
|
||||||
menu:update()
|
_menu:update()
|
||||||
if menu.items[num] then
|
if _menu.items[num] then
|
||||||
menu:item_enter(num, opts)
|
_menu:item_enter(num, opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if action and type(action) == "function" then
|
if action and type(action) == "function" then
|
||||||
|
@ -271,35 +272,35 @@ function exec(menu, num, opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function item_enter(menu, num, opts)
|
function menu.item_enter(_menu, num, opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
local item = menu.items[num]
|
local item = _menu.items[num]
|
||||||
if num == nil or menu.sel == num or not item then
|
if num == nil or _menu.sel == num or not item then
|
||||||
return
|
return
|
||||||
elseif menu.sel then
|
elseif _menu.sel then
|
||||||
menu:item_leave(menu.sel)
|
_menu:item_leave(_menu.sel)
|
||||||
end
|
end
|
||||||
--print("sel", num, menu.sel, item.theme.bg_focus)
|
--print("sel", num, menu.sel, item.theme.bg_focus)
|
||||||
item._background:set_fg(item.theme.fg_focus)
|
item._background:set_fg(item.theme.fg_focus)
|
||||||
item._background:set_bg(item.theme.bg_focus)
|
item._background:set_bg(item.theme.bg_focus)
|
||||||
menu.sel = num
|
_menu.sel = num
|
||||||
|
|
||||||
if menu.auto_expand and opts.hover then
|
if _menu.auto_expand and opts.hover then
|
||||||
if menu.active_child then
|
if _menu.active_child then
|
||||||
menu.active_child:hide()
|
_menu.active_child:hide()
|
||||||
menu.active_child = nil
|
_menu.active_child = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if type(item.cmd) == "table" then
|
if type(item.cmd) == "table" then
|
||||||
menu:exec(num, opts)
|
_menu:exec(num, opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function item_leave(menu, num)
|
function menu.item_leave(_menu, num)
|
||||||
--print("leave", num)
|
--print("leave", num)
|
||||||
local item = menu.items[num]
|
local item = _menu.items[num]
|
||||||
if item then
|
if item then
|
||||||
item._background:set_fg(item.theme.fg_normal)
|
item._background:set_fg(item.theme.fg_normal)
|
||||||
item._background:set_bg(item.theme.bg_normal)
|
item._background:set_bg(item.theme.bg_normal)
|
||||||
|
@ -308,77 +309,77 @@ end
|
||||||
|
|
||||||
|
|
||||||
--- Show a menu.
|
--- Show a menu.
|
||||||
-- @param menu The menu to show.
|
-- @param _menu The menu to show.
|
||||||
-- @param args.coords Menu position defaulting to mouse.coords()
|
-- @param args.coords Menu position defaulting to mouse.coords()
|
||||||
function show(menu, args)
|
function menu.show(_menu, args)
|
||||||
args = args or {}
|
args = args or {}
|
||||||
local coords = args.coords or nil
|
local coords = args.coords or nil
|
||||||
local screen_index = capi.mouse.screen
|
local screen_index = capi.mouse.screen
|
||||||
|
|
||||||
if not set_size(menu) then return end
|
if not set_size(_menu) then return end
|
||||||
set_coords(menu, screen_index, coords)
|
set_coords(_menu, screen_index, coords)
|
||||||
|
|
||||||
keygrabber.run(menu._keygrabber)
|
keygrabber.run(_menu._keygrabber)
|
||||||
menu.wibox.visible = true
|
_menu.wibox.visible = true
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Hide a menu popup.
|
--- Hide a menu popup.
|
||||||
-- @param menu The menu to hide.
|
-- @param _menu The menu to hide.
|
||||||
function hide(menu)
|
function menu.hide(_menu)
|
||||||
-- Remove items from screen
|
-- Remove items from screen
|
||||||
for i = 1, #menu.items do
|
for i = 1, #_menu.items do
|
||||||
menu:item_leave(i)
|
_menu:item_leave(i)
|
||||||
end
|
end
|
||||||
if menu.active_child then
|
if _menu.active_child then
|
||||||
menu.active_child:hide()
|
_menu.active_child:hide()
|
||||||
menu.active_child = nil
|
_menu.active_child = nil
|
||||||
end
|
end
|
||||||
menu.sel = nil
|
_menu.sel = nil
|
||||||
|
|
||||||
keygrabber.stop(menu._keygrabber)
|
keygrabber.stop(_menu._keygrabber)
|
||||||
menu.wibox.visible = false
|
_menu.wibox.visible = false
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Toggle menu visibility.
|
--- Toggle menu visibility.
|
||||||
-- @param menu The menu to show if it's hidden, or to hide if it's shown.
|
-- @param _menu The menu to show if it's hidden, or to hide if it's shown.
|
||||||
-- @param args.coords Menu position {x,y}
|
-- @param args.coords Menu position {x,y}
|
||||||
function toggle(menu, args)
|
function menu.toggle(_menu, args)
|
||||||
if menu.wibox.visible then
|
if _menu.wibox.visible then
|
||||||
menu:hide()
|
_menu:hide()
|
||||||
else
|
else
|
||||||
menu:show(args)
|
_menu:show(args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Update menu content
|
--- Update menu content
|
||||||
-- @param menu The mnenu to update.
|
-- @param _menu The mnenu to update.
|
||||||
function update(menu)
|
function menu.update(_menu)
|
||||||
if menu.wibox.visible then
|
if _menu.wibox.visible then
|
||||||
menu:show({ coords = { x = menu.x, y = menu.y } })
|
_menu:show({ coords = { x = _menu.x, y = _menu.y } })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Get the elder parent so for example when you kill
|
--- Get the elder parent so for example when you kill
|
||||||
-- it, it will destroy the whole family.
|
-- it, it will destroy the whole family.
|
||||||
-- @param menu The sub menu of the menu family.
|
-- @param _menu The sub menu of the menu family.
|
||||||
function get_root(menu)
|
function menu.get_root(_menu)
|
||||||
return menu.parent and get_root(menu.parent) or menu
|
return _menu.parent and menu.get_root(_menu.parent) or _menu
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Add a new menu entry
|
--- Add a new menu entry
|
||||||
-- @param menu The parent menu
|
-- @param _menu The parent menu
|
||||||
-- @param args The item params
|
-- @param args The item params
|
||||||
-- @param args.new (Default: awful.menu.entry) The menu entry constructor
|
-- @param args.new (Default: awful.menu.entry) The menu entry constructor
|
||||||
-- @param args.theme (Optional) The menu entry theme
|
-- @param args.theme (Optional) The menu entry theme
|
||||||
-- @param args.* params needed for the menu entry constructor
|
-- @param args.* params needed for the menu entry constructor
|
||||||
-- @param index (Optional) the index where the new entry will inserted
|
-- @param index (Optional) the index where the new entry will inserted
|
||||||
function add(menu, args, index)
|
function menu.add(_menu, args, index)
|
||||||
if not args then return end
|
if not args then return end
|
||||||
local theme = load_theme(args.theme or {}, menu.theme)
|
local theme = load_theme(args.theme or {}, _menu.theme)
|
||||||
args.theme = theme
|
args.theme = theme
|
||||||
args.new = args.new or entry
|
args.new = args.new or menu.entry
|
||||||
local success, item = pcall(args.new, menu, args)
|
local success, item = pcall(args.new, _menu, args)
|
||||||
if not success then
|
if not success then
|
||||||
print("Error while creating menu entry: " .. item)
|
print("Error while creating menu entry: " .. item)
|
||||||
return
|
return
|
||||||
|
@ -387,7 +388,7 @@ function add(menu, args, index)
|
||||||
print("Error while checking menu entry: no property widget found.")
|
print("Error while checking menu entry: no property widget found.")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
item.parent = menu
|
item.parent = _menu
|
||||||
item.theme = item.theme or theme
|
item.theme = item.theme or theme
|
||||||
item.width = item.width or theme.width
|
item.width = item.width or theme.width
|
||||||
item.height = item.height or theme.height
|
item.height = item.height or theme.height
|
||||||
|
@ -400,69 +401,69 @@ function add(menu, args, index)
|
||||||
|
|
||||||
-- Create bindings
|
-- Create bindings
|
||||||
item._background:buttons(util.table.join(
|
item._background:buttons(util.table.join(
|
||||||
button({}, 3, function () menu:hide() end),
|
button({}, 3, function () _menu:hide() end),
|
||||||
button({}, 1, function ()
|
button({}, 1, function ()
|
||||||
local num = util.table.hasitem(menu.items, item)
|
local num = util.table.hasitem(_menu.items, item)
|
||||||
menu:item_enter(num, { mouse = true })
|
_menu:item_enter(num, { mouse = true })
|
||||||
menu:exec(num, { exec = true, mouse = true })
|
_menu:exec(num, { exec = true, mouse = true })
|
||||||
end )))
|
end )))
|
||||||
|
|
||||||
|
|
||||||
item._mouse = function ()
|
item._mouse = function ()
|
||||||
local num = util.table.hasitem(menu.items, item)
|
local num = util.table.hasitem(_menu.items, item)
|
||||||
menu:item_enter(num, { hover = true, moue = true })
|
_menu:item_enter(num, { hover = true, moue = true })
|
||||||
end
|
end
|
||||||
item.widget:connect_signal("mouse::enter", item._mouse)
|
item.widget:connect_signal("mouse::enter", item._mouse)
|
||||||
|
|
||||||
if index then
|
if index then
|
||||||
menu.layout:reset()
|
_menu.layout:reset()
|
||||||
table.insert(menu.items, index, item)
|
table.insert(_menu.items, index, item)
|
||||||
for _, i in ipairs(menu.items) do
|
for _, i in ipairs(_menu.items) do
|
||||||
menu.layout:add(i._background)
|
_menu.layout:add(i._background)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
table.insert(menu.items, item)
|
table.insert(_menu.items, item)
|
||||||
menu.layout:add(item._background)
|
_menu.layout:add(item._background)
|
||||||
end
|
end
|
||||||
return item
|
return item
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Delete menu entry at given position
|
-- Delete menu entry at given position
|
||||||
-- @param menu The menu
|
-- @param _menu The menu
|
||||||
-- @param num The position in the table of the menu entry to be deleted; can be also the menu entry itself
|
-- @param num The position in the table of the menu entry to be deleted; can be also the menu entry itself
|
||||||
function delete(menu, num)
|
function menu.delete(_menu, num)
|
||||||
if type(num) == "table" then
|
if type(num) == "table" then
|
||||||
num = util.table.hasitem(menu.items, num)
|
num = util.table.hasitem(_menu.items, num)
|
||||||
end
|
end
|
||||||
local item = menu.items[num]
|
local item = _menu.items[num]
|
||||||
if not item then return end
|
if not item then return end
|
||||||
item.widget:disconnect_signal("mouse::enter", item._mouse)
|
item.widget:disconnect_signal("mouse::enter", item._mouse)
|
||||||
item.widget.visible = false
|
item.widget.visible = false
|
||||||
table.remove(menu.items, num)
|
table.remove(_menu.items, num)
|
||||||
if menu.sel == num then
|
if _menu.sel == num then
|
||||||
menu:item_leave(menu.sel)
|
_menu:item_leave(_menu.sel)
|
||||||
menu.sel = nil
|
_menu.sel = nil
|
||||||
end
|
end
|
||||||
menu.layout:reset()
|
_menu.layout:reset()
|
||||||
for _, i in ipairs(menu.items) do
|
for _, i in ipairs(_menu.items) do
|
||||||
menu.layout:add(i._background)
|
_menu.layout:add(i._background)
|
||||||
end
|
end
|
||||||
if menu.child[num] then
|
if _menu.child[num] then
|
||||||
menu.child[num]:hide()
|
_menu.child[num]:hide()
|
||||||
if menu.active_child == menu.child[num] then
|
if _menu.active_child == _menu.child[num] then
|
||||||
menu.active_child = nil
|
_menu.active_child = nil
|
||||||
end
|
end
|
||||||
table.remove(menu.child, num)
|
table.remove(_menu.child, num)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- Build a popup menu with running clients and shows it.
|
--- Build a popup menu with running clients and shows it.
|
||||||
-- @param menu Menu table, see new() function for more informations
|
-- @param _menu Menu table, see new() function for more informations
|
||||||
-- @return The menu.
|
-- @return The menu.
|
||||||
function clients(menu, args) -- FIXME crude api
|
function menu.clients(_menu, args) -- FIXME crude api
|
||||||
menu = menu or {}
|
_menu = _menu or {}
|
||||||
local cls = capi.client.get()
|
local cls = capi.client.get()
|
||||||
local cls_t = {}
|
local cls_t = {}
|
||||||
for k, c in pairs(cls) do
|
for k, c in pairs(cls) do
|
||||||
|
@ -492,7 +493,7 @@ end
|
||||||
-- @param parent The parent menu
|
-- @param parent The parent menu
|
||||||
-- @param args the item params
|
-- @param args the item params
|
||||||
-- @return table with 'widget', 'cmd', 'akey' and all the properties the user wants to change
|
-- @return table with 'widget', 'cmd', 'akey' and all the properties the user wants to change
|
||||||
function entry(parent, args)
|
function menu.entry(parent, args)
|
||||||
args = args or {}
|
args = args or {}
|
||||||
args.text = args[1] or args.text or ""
|
args.text = args[1] or args.text or ""
|
||||||
args.cmd = args[2] or args.cmd
|
args.cmd = args[2] or args.cmd
|
||||||
|
@ -616,20 +617,20 @@ end
|
||||||
-- awful.menu(terms):show() <br/>
|
-- awful.menu(terms):show() <br/>
|
||||||
-- end <br/>
|
-- end <br/>
|
||||||
--</code></p>
|
--</code></p>
|
||||||
function new(args, parent)
|
function menu.new(args, parent)
|
||||||
args = args or {}
|
args = args or {}
|
||||||
args.layout = args.layout or wibox.layout.flex.vertical
|
args.layout = args.layout or wibox.layout.flex.vertical
|
||||||
local menu = table_update(object(), {
|
local _menu = table_update(object(), {
|
||||||
item_enter = item_enter,
|
item_enter = menu.item_enter,
|
||||||
item_leave = item_leave,
|
item_leave = menu.item_leave,
|
||||||
get_root = get_root,
|
get_root = menu.get_root,
|
||||||
delete = delete,
|
delete = menu.delete,
|
||||||
update = update,
|
update = menu.update,
|
||||||
toggle = toggle,
|
toggle = menu.toggle,
|
||||||
hide = hide,
|
hide = menu.hide,
|
||||||
show = show,
|
show = menu.show,
|
||||||
exec = exec,
|
exec = menu.exec,
|
||||||
add = add,
|
add = menu.add,
|
||||||
child = {},
|
child = {},
|
||||||
items = {},
|
items = {},
|
||||||
parent = parent,
|
parent = parent,
|
||||||
|
@ -637,39 +638,43 @@ function new(args, parent)
|
||||||
theme = load_theme(args.theme or {}, parent and parent.theme) })
|
theme = load_theme(args.theme or {}, parent and parent.theme) })
|
||||||
|
|
||||||
if parent then
|
if parent then
|
||||||
menu.auto_expand = parent.auto_expand
|
_menu.auto_expand = parent.auto_expand
|
||||||
elseif args.auto_expand ~= nil then
|
elseif args.auto_expand ~= nil then
|
||||||
menu.auto_expand = args.auto_expand
|
_menu.auto_expand = args.auto_expand
|
||||||
else
|
else
|
||||||
menu.auto_expand = true
|
_menu.auto_expand = true
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Create items
|
-- Create items
|
||||||
for i, v in ipairs(args) do menu:add(v) end
|
for i, v in ipairs(args) do _menu:add(v) end
|
||||||
if args.items then
|
if args.items then
|
||||||
for i, v in pairs(args.items) do menu:add(v) end
|
for i, v in pairs(args.items) do _menu:add(v) end
|
||||||
end
|
end
|
||||||
|
|
||||||
menu._keygrabber = function (...)
|
_menu._keygrabber = function (...)
|
||||||
grabber(menu, ...)
|
grabber(_menu, ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
menu.wibox = wibox({
|
_menu.wibox = wibox({
|
||||||
ontop = true,
|
ontop = true,
|
||||||
fg = menu.theme.fg_normal,
|
fg = _menu.theme.fg_normal,
|
||||||
bg = menu.theme.bg_normal,
|
bg = _menu.theme.bg_normal,
|
||||||
border_color = menu.theme.border,
|
border_color = _menu.theme.border,
|
||||||
border_width = menu.theme.border_width,
|
border_width = _menu.theme.border_width,
|
||||||
type = "popup_menu" })
|
type = "popup_menu" })
|
||||||
menu.wibox.visible = false
|
_menu.wibox.visible = false
|
||||||
menu.wibox:set_widget(menu.layout)
|
_menu.wibox:set_widget(_menu.layout)
|
||||||
set_size(menu)
|
set_size(_menu)
|
||||||
|
|
||||||
menu.x = menu.wibox.x
|
_menu.x = _menu.wibox.x
|
||||||
menu.y = menu.wibox.y
|
_menu.y = _menu.wibox.y
|
||||||
return menu
|
return _menu
|
||||||
end
|
end
|
||||||
|
|
||||||
setmetatable(_M, { __call = function (_, ...) return new(...) end })
|
function menu.mt:__call(...)
|
||||||
|
return menu.new(...)
|
||||||
|
end
|
||||||
|
|
||||||
|
return setmetatable(menu, menu.mt)
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
|
@ -20,7 +20,8 @@ local layout = require("awful.layout")
|
||||||
local a_screen = require("awful.screen")
|
local a_screen = require("awful.screen")
|
||||||
|
|
||||||
--- Places client according to special criteria.
|
--- Places client according to special criteria.
|
||||||
module("awful.placement")
|
-- awful.placement
|
||||||
|
local placement = {}
|
||||||
|
|
||||||
-- Check if an area intersect another area.
|
-- Check if an area intersect another area.
|
||||||
-- @param a The area.
|
-- @param a The area.
|
||||||
|
@ -103,7 +104,7 @@ end
|
||||||
--- Place the client so no part of it will be outside the screen.
|
--- Place the client so no part of it will be outside the screen.
|
||||||
-- @param c The client.
|
-- @param c The client.
|
||||||
-- @return The new client geometry.
|
-- @return The new client geometry.
|
||||||
function no_offscreen(c)
|
function placement.no_offscreen(c)
|
||||||
local c = c or capi.client.focus
|
local c = c or capi.client.focus
|
||||||
local geometry = c:geometry()
|
local geometry = c:geometry()
|
||||||
local screen = c.screen or a_screen.getbycoord(geometry.x, geometry.y)
|
local screen = c.screen or a_screen.getbycoord(geometry.x, geometry.y)
|
||||||
|
@ -127,7 +128,7 @@ end
|
||||||
|
|
||||||
--- Place the client where there's place available with minimum overlap.
|
--- Place the client where there's place available with minimum overlap.
|
||||||
-- @param c The client.
|
-- @param c The client.
|
||||||
function no_overlap(c)
|
function placement.no_overlap(c)
|
||||||
local geometry = c:geometry()
|
local geometry = c:geometry()
|
||||||
local screen = c.screen or a_screen.getbycoord(geometry.x, geometry.y)
|
local screen = c.screen or a_screen.getbycoord(geometry.x, geometry.y)
|
||||||
local cls = client.visible(screen)
|
local cls = client.visible(screen)
|
||||||
|
@ -180,7 +181,7 @@ end
|
||||||
--- Place the client under the mouse.
|
--- Place the client under the mouse.
|
||||||
-- @param c The client.
|
-- @param c The client.
|
||||||
-- @return The new client geometry.
|
-- @return The new client geometry.
|
||||||
function under_mouse(c)
|
function placement.under_mouse(c)
|
||||||
local c = c or capi.client.focus
|
local c = c or capi.client.focus
|
||||||
local c_geometry = c:geometry()
|
local c_geometry = c:geometry()
|
||||||
local m_coords = capi.mouse.coords()
|
local m_coords = capi.mouse.coords()
|
||||||
|
@ -192,7 +193,7 @@ end
|
||||||
-- @param c The client.
|
-- @param c The client.
|
||||||
-- @param p The parent (optional, nil for screen centering).
|
-- @param p The parent (optional, nil for screen centering).
|
||||||
-- @return The new client geometry.
|
-- @return The new client geometry.
|
||||||
function centered(c, p)
|
function placement.centered(c, p)
|
||||||
local c = c or capi.client.focus
|
local c = c or capi.client.focus
|
||||||
local c_geometry = c:geometry()
|
local c_geometry = c:geometry()
|
||||||
local screen = c.screen or a_screen.getbycoord(c_geometry.x, c_geometry.y)
|
local screen = c.screen or a_screen.getbycoord(c_geometry.x, c_geometry.y)
|
||||||
|
@ -210,7 +211,7 @@ end
|
||||||
-- @param c The client.
|
-- @param c The client.
|
||||||
-- @param p The parent (optional, nil for screen centering).
|
-- @param p The parent (optional, nil for screen centering).
|
||||||
-- @return The new client geometry.
|
-- @return The new client geometry.
|
||||||
function center_horizontal(c, p)
|
function placement.center_horizontal(c, p)
|
||||||
local c = c or capi.client.focus
|
local c = c or capi.client.focus
|
||||||
local c_geometry = c:geometry()
|
local c_geometry = c:geometry()
|
||||||
local screen = c.screen or a_screen.getbycoord(c_geometry.x, c_geometry.y)
|
local screen = c.screen or a_screen.getbycoord(c_geometry.x, c_geometry.y)
|
||||||
|
@ -227,7 +228,7 @@ end
|
||||||
-- @param c The client.
|
-- @param c The client.
|
||||||
-- @param p The parent (optional, nil for screen centering).
|
-- @param p The parent (optional, nil for screen centering).
|
||||||
-- @return The new client geometry.
|
-- @return The new client geometry.
|
||||||
function center_vertical(c, p)
|
function placement.center_vertical(c, p)
|
||||||
local c = c or capi.client.focus
|
local c = c or capi.client.focus
|
||||||
local c_geometry = c:geometry()
|
local c_geometry = c:geometry()
|
||||||
local screen = c.screen or a_screen.getbycoord(c_geometry.x, c_geometry.y)
|
local screen = c.screen or a_screen.getbycoord(c_geometry.x, c_geometry.y)
|
||||||
|
@ -240,5 +241,6 @@ function center_vertical(c, p)
|
||||||
return c:geometry({ y = s_geometry.y + (s_geometry.height - c_geometry.height) / 2 })
|
return c:geometry({ y = s_geometry.y + (s_geometry.height - c_geometry.height) / 2 })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return placement
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
|
@ -20,7 +20,8 @@ local util = require("awful.util")
|
||||||
local beautiful = require("beautiful")
|
local beautiful = require("beautiful")
|
||||||
|
|
||||||
--- Prompt module for awful
|
--- Prompt module for awful
|
||||||
module("awful.prompt")
|
-- awful.prompt
|
||||||
|
local prompt = {}
|
||||||
|
|
||||||
--- Private data
|
--- Private data
|
||||||
local data = {}
|
local data = {}
|
||||||
|
@ -131,7 +132,7 @@ end
|
||||||
local function prompt_text_with_cursor(args)
|
local function prompt_text_with_cursor(args)
|
||||||
local char, spacer, text_start, text_end, ret
|
local char, spacer, text_start, text_end, ret
|
||||||
local text = args.text or ""
|
local text = args.text or ""
|
||||||
local prompt = args.prompt or ""
|
local _prompt = args.prompt or ""
|
||||||
local underline = args.cursor_ul or "none"
|
local underline = args.cursor_ul or "none"
|
||||||
|
|
||||||
if args.selectall then
|
if args.selectall then
|
||||||
|
@ -151,7 +152,7 @@ local function prompt_text_with_cursor(args)
|
||||||
text_end = util.escape(text:sub(args.cursor_pos + 1))
|
text_end = util.escape(text:sub(args.cursor_pos + 1))
|
||||||
end
|
end
|
||||||
|
|
||||||
ret = prompt .. text_start .. "<span background=\"" .. util.color_strip_alpha(args.cursor_color) .. "\" foreground=\"" .. util.color_strip_alpha(args.text_color) .. "\" underline=\"" .. underline .. "\">" .. char .. "</span>" .. text_end .. spacer
|
ret = _prompt .. text_start .. "<span background=\"" .. util.color_strip_alpha(args.cursor_color) .. "\" foreground=\"" .. util.color_strip_alpha(args.text_color) .. "\" underline=\"" .. underline .. "\">" .. char .. "</span>" .. text_end .. spacer
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -165,7 +166,7 @@ end
|
||||||
-- @param done_callback Optional parameter: the callback function to always call without arguments, regardless of whether the prompt was cancelled.
|
-- @param done_callback Optional parameter: the callback function to always call without arguments, regardless of whether the prompt was cancelled.
|
||||||
-- @param changed_callback Optional parameter: the callback function to call with command as argument when a command was changed.
|
-- @param changed_callback Optional parameter: the callback function to call with command as argument when a command was changed.
|
||||||
-- @param keypressed_callback Optional parameter: the callback function to call with mod table, key and command as arguments when a key was pressed.
|
-- @param keypressed_callback Optional parameter: the callback function to call with mod table, key and command as arguments when a key was pressed.
|
||||||
function run(args, textbox, exe_callback, completion_callback, history_path, history_max, done_callback, changed_callback, keypressed_callback)
|
function prompt.run(args, textbox, exe_callback, completion_callback, history_path, history_max, done_callback, changed_callback, keypressed_callback)
|
||||||
local grabber
|
local grabber
|
||||||
local theme = beautiful.get()
|
local theme = beautiful.get()
|
||||||
if not args then args = {} end
|
if not args then args = {} end
|
||||||
|
@ -465,4 +466,6 @@ function run(args, textbox, exe_callback, completion_callback, history_path, his
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return prompt
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
|
@ -15,7 +15,7 @@ local dbus = dbus
|
||||||
local type = type
|
local type = type
|
||||||
|
|
||||||
--- Remote control module allowing usage of awesome-client.
|
--- Remote control module allowing usage of awesome-client.
|
||||||
module("awful.remote")
|
-- awful.remote
|
||||||
|
|
||||||
if dbus then
|
if dbus then
|
||||||
dbus.connect_signal("org.naquadah.awesome.awful.Remote", function(data, code)
|
dbus.connect_signal("org.naquadah.awesome.awful.Remote", function(data, code)
|
||||||
|
|
|
@ -14,7 +14,8 @@ local aclient = require("awful.client")
|
||||||
local atag = require("awful.tag")
|
local atag = require("awful.tag")
|
||||||
|
|
||||||
--- Apply rules to clients at startup.
|
--- Apply rules to clients at startup.
|
||||||
module("awful.rules")
|
-- awful.rules
|
||||||
|
local rules = {}
|
||||||
|
|
||||||
--- This is the global rules table.
|
--- This is the global rules table.
|
||||||
-- <p>You should fill this table with your rule and properties to apply.
|
-- <p>You should fill this table with your rule and properties to apply.
|
||||||
|
@ -100,13 +101,13 @@ module("awful.rules")
|
||||||
--
|
--
|
||||||
-- @class table
|
-- @class table
|
||||||
-- @name rules
|
-- @name rules
|
||||||
rules = {}
|
rules.rules = {}
|
||||||
|
|
||||||
--- Check if a client match a rule.
|
--- Check if a client match a rule.
|
||||||
-- @param c The client.
|
-- @param c The client.
|
||||||
-- @param rule The rule to check.
|
-- @param rule The rule to check.
|
||||||
-- @return True if it matches, false otherwise.
|
-- @return True if it matches, false otherwise.
|
||||||
function match(c, rule)
|
function rules.match(c, rule)
|
||||||
if not rule then return false end
|
if not rule then return false end
|
||||||
for field, value in pairs(rule) do
|
for field, value in pairs(rule) do
|
||||||
if c[field] then
|
if c[field] then
|
||||||
|
@ -128,7 +129,7 @@ end
|
||||||
-- @param c The client.
|
-- @param c The client.
|
||||||
-- @param rules The rule to check.
|
-- @param rules The rule to check.
|
||||||
-- @return True if at least one rule is matched, false otherwise.
|
-- @return True if at least one rule is matched, false otherwise.
|
||||||
function match_any(c, rule)
|
function rules.match_any(c, rule)
|
||||||
if not rule then return false end
|
if not rule then return false end
|
||||||
for field, values in pairs(rule) do
|
for field, values in pairs(rule) do
|
||||||
if c[field] then
|
if c[field] then
|
||||||
|
@ -146,12 +147,12 @@ end
|
||||||
|
|
||||||
--- Apply rules to a client.
|
--- Apply rules to a client.
|
||||||
-- @param c The client.
|
-- @param c The client.
|
||||||
function apply(c)
|
function rules.apply(c)
|
||||||
local props = {}
|
local props = {}
|
||||||
local callbacks = {}
|
local callbacks = {}
|
||||||
for _, entry in ipairs(rules) do
|
for _, entry in ipairs(rules.rules) do
|
||||||
if (match(c, entry.rule) or match_any(c, entry.rule_any)) and
|
if (rules.match(c, entry.rule) or rules.match_any(c, entry.rule_any)) and
|
||||||
(not match(c, entry.except) and not match_any(c, entry.except_any)) then
|
(not rules.match(c, entry.except) and not rules.match_any(c, entry.except_any)) then
|
||||||
if entry.properties then
|
if entry.properties then
|
||||||
for property, value in pairs(entry.properties) do
|
for property, value in pairs(entry.properties) do
|
||||||
props[property] = value
|
props[property] = value
|
||||||
|
@ -202,7 +203,9 @@ function apply(c)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
client.connect_signal("manage", apply)
|
client.connect_signal("manage", rules.apply)
|
||||||
client.disconnect_signal("manage", atag.withcurrent)
|
client.disconnect_signal("manage", atag.withcurrent)
|
||||||
|
|
||||||
|
return rules
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
|
@ -15,7 +15,8 @@ local util = require("awful.util")
|
||||||
local client = require("awful.client")
|
local client = require("awful.client")
|
||||||
|
|
||||||
--- Screen module for awful
|
--- Screen module for awful
|
||||||
module("awful.screen")
|
-- awful.screen
|
||||||
|
local screen = {}
|
||||||
|
|
||||||
local data = {}
|
local data = {}
|
||||||
data.padding = {}
|
data.padding = {}
|
||||||
|
@ -26,7 +27,7 @@ data.padding = {}
|
||||||
-- `screen` table/object.
|
-- `screen` table/object.
|
||||||
-- @param x The x coordinate
|
-- @param x The x coordinate
|
||||||
-- @param y The y coordinate
|
-- @param y The y coordinate
|
||||||
function getbycoord(x, y)
|
function screen.getbycoord(x, y)
|
||||||
for i = 1, capi.screen:count() do
|
for i = 1, capi.screen:count() do
|
||||||
local geometry = capi.screen[i].geometry
|
local geometry = capi.screen[i].geometry
|
||||||
if((x < 0 or (x >= geometry.x and x < geometry.x + geometry.width))
|
if((x < 0 or (x >= geometry.x and x < geometry.x + geometry.width))
|
||||||
|
@ -38,36 +39,38 @@ end
|
||||||
|
|
||||||
--- Give the focus to a screen, and move pointer.
|
--- Give the focus to a screen, and move pointer.
|
||||||
-- @param screen Screen number.
|
-- @param screen Screen number.
|
||||||
function focus(screen)
|
function screen.focus(_screen)
|
||||||
if screen > capi.screen.count() then screen = capi.mouse.screen end
|
if _screen > capi.screen.count() then _screen = capi.mouse.screen end
|
||||||
local c = client.focus.history.get(screen, 0)
|
local c = client.focus.history.get(_screen, 0)
|
||||||
if c then capi.client.focus = c end
|
if c then capi.client.focus = c end
|
||||||
-- Move the mouse on the screen
|
-- Move the mouse on the screen
|
||||||
capi.mouse.screen = screen
|
capi.mouse.screen = _screen
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Give the focus to a screen, and move pointer, but relative to the current
|
--- Give the focus to a screen, and move pointer, but relative to the current
|
||||||
-- focused screen.
|
-- focused screen.
|
||||||
-- @param i Value to add to the current focused screen index. 1 will focus next
|
-- @param i Value to add to the current focused screen index. 1 will focus next
|
||||||
-- screen, -1 would focus the previous one.
|
-- screen, -1 would focus the previous one.
|
||||||
function focus_relative(i)
|
function screen.focus_relative(i)
|
||||||
return focus(util.cycle(capi.screen.count(), capi.mouse.screen + i))
|
return screen.focus(util.cycle(capi.screen.count(), capi.mouse.screen + i))
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get or set the screen padding.
|
--- Get or set the screen padding.
|
||||||
-- @param screen The screen object to change the padding on
|
-- @param screen The screen object to change the padding on
|
||||||
-- @param padding The padding, an table with 'top', 'left', 'right' and/or
|
-- @param padding The padding, an table with 'top', 'left', 'right' and/or
|
||||||
-- 'bottom'. Can be nil if you only want to retrieve padding
|
-- 'bottom'. Can be nil if you only want to retrieve padding
|
||||||
function padding(screen, padding)
|
function screen.padding(_screen, padding)
|
||||||
if padding then
|
if padding then
|
||||||
data.padding[screen] = padding
|
data.padding[_screen] = padding
|
||||||
screen:emit_signal("padding")
|
_screen:emit_signal("padding")
|
||||||
end
|
end
|
||||||
return data.padding[screen]
|
return data.padding[_screen]
|
||||||
end
|
end
|
||||||
|
|
||||||
for s = 1, capi.screen.count() do
|
for s = 1, capi.screen.count() do
|
||||||
capi.screen[s]:add_signal("padding")
|
capi.screen[s]:add_signal("padding")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return screen
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
|
@ -14,11 +14,11 @@ local capi =
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Startup notification module for awful
|
--- Startup notification module for awful
|
||||||
module("awful.startup_notification")
|
-- awful.startup_notification
|
||||||
|
|
||||||
local app_starting = {}
|
local app_starting = {}
|
||||||
|
|
||||||
cursor_waiting = "watch"
|
local cursor_waiting = "watch"
|
||||||
|
|
||||||
local function update_cursor()
|
local function update_cursor()
|
||||||
if #app_starting > 0 then
|
if #app_starting > 0 then
|
||||||
|
|
|
@ -20,7 +20,8 @@ local capi =
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Useful functions for tag manipulation.
|
--- Useful functions for tag manipulation.
|
||||||
module("awful.tag")
|
-- awful.tag
|
||||||
|
local tag = { mt = {} }
|
||||||
|
|
||||||
-- Private data
|
-- Private data
|
||||||
local data = {}
|
local data = {}
|
||||||
|
@ -28,13 +29,13 @@ data.history = {}
|
||||||
data.tags = setmetatable({}, { __mode = 'k' })
|
data.tags = setmetatable({}, { __mode = 'k' })
|
||||||
|
|
||||||
-- History functions
|
-- History functions
|
||||||
history = {}
|
tag.history = {}
|
||||||
history.limit = 20
|
tag.history.limit = 20
|
||||||
|
|
||||||
--- Move a tag to an absolute position in the screen[]:tags() table.
|
--- Move a tag to an absolute position in the screen[]:tags() table.
|
||||||
-- @param new_index Integer absolute position in the table to insert.
|
-- @param new_index Integer absolute position in the table to insert.
|
||||||
function move(new_index, target_tag)
|
function tag.move(new_index, target_tag)
|
||||||
local target_tag = target_tag or selected()
|
local target_tag = target_tag or tag.selected()
|
||||||
local scr = target_tag.screen
|
local scr = target_tag.screen
|
||||||
local tmp_tags = capi.screen[scr]:tags()
|
local tmp_tags = capi.screen[scr]:tags()
|
||||||
|
|
||||||
|
@ -57,13 +58,13 @@ end
|
||||||
-- @param name The tag name, a string
|
-- @param name The tag name, a string
|
||||||
-- @param props The tags properties, a table
|
-- @param props The tags properties, a table
|
||||||
-- @return The created tag
|
-- @return The created tag
|
||||||
function add(name, props)
|
function tag.add(name, props)
|
||||||
local properties = props or {}
|
local properties = props or {}
|
||||||
local newtag = capi.tag{name = name}
|
local newtag = capi.tag{name = name}
|
||||||
newtag.screen = properties.screen or capi.mouse.screen
|
newtag.screen = properties.screen or capi.mouse.screen
|
||||||
|
|
||||||
for k, v in pairs(properties) do
|
for k, v in pairs(properties) do
|
||||||
setproperty(newtag, k, v)
|
tag.setproperty(newtag, k, v)
|
||||||
end
|
end
|
||||||
|
|
||||||
return newtag
|
return newtag
|
||||||
|
@ -74,11 +75,11 @@ end
|
||||||
-- @param screen The tag screen, or 1 if not set.
|
-- @param screen The tag screen, or 1 if not set.
|
||||||
-- @param layout The layout or layout table to set for this tags by default.
|
-- @param layout The layout or layout table to set for this tags by default.
|
||||||
-- @return A table with all created tags.
|
-- @return A table with all created tags.
|
||||||
function new(names, screen, layout)
|
function tag.new(names, screen, layout)
|
||||||
local screen = screen or 1
|
local screen = screen or 1
|
||||||
local tags = {}
|
local tags = {}
|
||||||
for id, name in ipairs(names) do
|
for id, name in ipairs(names) do
|
||||||
table.insert(tags, id, add(name, {screen = screen,
|
table.insert(tags, id, tag.add(name, {screen = screen,
|
||||||
layout = (layout and layout[id]) or
|
layout = (layout and layout[id]) or
|
||||||
layout}))
|
layout}))
|
||||||
-- Select the first tag.
|
-- Select the first tag.
|
||||||
|
@ -93,9 +94,9 @@ end
|
||||||
--- Find a suitable fallback tag.
|
--- Find a suitable fallback tag.
|
||||||
-- @param screen The screen number to look for a tag on. [mouse.screen]
|
-- @param screen The screen number to look for a tag on. [mouse.screen]
|
||||||
-- @param target A table of tags we consider unacceptable. [selectedlist(scr)]
|
-- @param target A table of tags we consider unacceptable. [selectedlist(scr)]
|
||||||
function find_fallback(screen, invalids)
|
function tag.find_fallback(screen, invalids)
|
||||||
local scr = screen or capi.mouse.screen
|
local scr = screen or capi.mouse.screen
|
||||||
local t = invalids or selectedlist(scr)
|
local t = invalids or tag.selectedlist(scr)
|
||||||
|
|
||||||
for _, v in pairs(capi.screen[scr]:tags()) do
|
for _, v in pairs(capi.screen[scr]:tags()) do
|
||||||
if not util.table.hasitem(t, v) then return v end
|
if not util.table.hasitem(t, v) then return v end
|
||||||
|
@ -110,9 +111,9 @@ end
|
||||||
-- stickied clients are assigned to the optional 'fallback_tag'.
|
-- stickied clients are assigned to the optional 'fallback_tag'.
|
||||||
-- If after deleting the tag there is no selected tag, try and restore from
|
-- If after deleting the tag there is no selected tag, try and restore from
|
||||||
-- history or select the first tag on the screen.
|
-- history or select the first tag on the screen.
|
||||||
function delete(target_tag, fallback_tag)
|
function tag.delete(target_tag, fallback_tag)
|
||||||
-- abort if no tag is passed or currently selected
|
-- abort if no tag is passed or currently selected
|
||||||
local target_tag = target_tag or selected()
|
local target_tag = target_tag or tag.selected()
|
||||||
if target_tag == nil then return end
|
if target_tag == nil then return end
|
||||||
|
|
||||||
local ntags = #capi.screen[target_tag.screen]:tags()
|
local ntags = #capi.screen[target_tag.screen]:tags()
|
||||||
|
@ -124,7 +125,7 @@ function delete(target_tag, fallback_tag)
|
||||||
|
|
||||||
-- No fallback_tag provided, try and get one.
|
-- No fallback_tag provided, try and get one.
|
||||||
if fallback_tag == nil then
|
if fallback_tag == nil then
|
||||||
fallback_tag = find_fallback(target_scr, {target_tag})
|
fallback_tag = tag.find_fallback(target_scr, {target_tag})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Abort if we would have un-tagged clients.
|
-- Abort if we would have un-tagged clients.
|
||||||
|
@ -148,9 +149,9 @@ function delete(target_tag, fallback_tag)
|
||||||
target_tag.screen = nil
|
target_tag.screen = nil
|
||||||
|
|
||||||
-- If no tags are visible, try and view one.
|
-- If no tags are visible, try and view one.
|
||||||
if selected(target_scr) == nil and ntags > 0 then
|
if tag.selected(target_scr) == nil and ntags > 0 then
|
||||||
history.restore()
|
tag.history.restore()
|
||||||
if selected(target_scr) == nil then
|
if tag.selected(target_scr) == nil then
|
||||||
capi.screen[target_scr]:tags()[1].selected = true
|
capi.screen[target_scr]:tags()[1].selected = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -160,9 +161,9 @@ end
|
||||||
|
|
||||||
--- Update the tag history.
|
--- Update the tag history.
|
||||||
-- @param obj Screen object.
|
-- @param obj Screen object.
|
||||||
function history.update(obj)
|
function tag.history.update(obj)
|
||||||
local s = obj.index
|
local s = obj.index
|
||||||
local curtags = selectedlist(s)
|
local curtags = tag.selectedlist(s)
|
||||||
-- create history table
|
-- create history table
|
||||||
if not data.history[s] then
|
if not data.history[s] then
|
||||||
data.history[s] = {}
|
data.history[s] = {}
|
||||||
|
@ -170,8 +171,8 @@ function history.update(obj)
|
||||||
if data.history[s].current then
|
if data.history[s].current then
|
||||||
-- Check that the list is not identical
|
-- Check that the list is not identical
|
||||||
local identical = true
|
local identical = true
|
||||||
for idx, tag in ipairs(data.history[s].current) do
|
for idx, _tag in ipairs(data.history[s].current) do
|
||||||
if curtags[idx] ~= tag then
|
if curtags[idx] ~= _tag then
|
||||||
identical = false
|
identical = false
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
|
@ -182,8 +183,8 @@ function history.update(obj)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Limit history
|
-- Limit history
|
||||||
if #data.history[s] >= history.limit then
|
if #data.history[s] >= tag.history.limit then
|
||||||
for i = history.limit, #data.history[s] do
|
for i = tag.history.limit, #data.history[s] do
|
||||||
data.history[s][i] = nil
|
data.history[s][i] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -201,20 +202,20 @@ end
|
||||||
-- @param idx Index in history. Defaults to "previous" which is a special index
|
-- @param idx Index in history. Defaults to "previous" which is a special index
|
||||||
-- toggling between last two selected sets of tags. Number (eg 1) will go back
|
-- toggling between last two selected sets of tags. Number (eg 1) will go back
|
||||||
-- to the given index in history.
|
-- to the given index in history.
|
||||||
function history.restore(screen, idx)
|
function tag.history.restore(screen, idx)
|
||||||
local s = screen or capi.mouse.screen
|
local s = screen or capi.mouse.screen
|
||||||
local i = idx or "previous"
|
local i = idx or "previous"
|
||||||
local sel = selectedlist(s)
|
local sel = tag.selectedlist(s)
|
||||||
-- do nothing if history empty
|
-- do nothing if history empty
|
||||||
if not data.history[s] or not data.history[s][i] then return end
|
if not data.history[s] or not data.history[s][i] then return end
|
||||||
-- if all tags been deleted, try next entry
|
-- if all tags been deleted, try next entry
|
||||||
if #data.history[s][i] == 0 then
|
if #data.history[s][i] == 0 then
|
||||||
if i == "previous" then i = 0 end
|
if i == "previous" then i = 0 end
|
||||||
history.restore(s, i + 1)
|
tag.history.restore(s, i + 1)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- deselect all tags
|
-- deselect all tags
|
||||||
viewnone(s)
|
tag.viewnone(s)
|
||||||
-- select tags from the history entry
|
-- select tags from the history entry
|
||||||
for _, t in ipairs(data.history[s][i]) do
|
for _, t in ipairs(data.history[s][i]) do
|
||||||
t.selected = true
|
t.selected = true
|
||||||
|
@ -230,7 +231,7 @@ end
|
||||||
--- Return a table with all visible tags
|
--- Return a table with all visible tags
|
||||||
-- @param s Screen number.
|
-- @param s Screen number.
|
||||||
-- @return A table with all selected tags.
|
-- @return A table with all selected tags.
|
||||||
function selectedlist(s)
|
function tag.selectedlist(s)
|
||||||
local screen = s or capi.mouse.screen
|
local screen = s or capi.mouse.screen
|
||||||
local tags = capi.screen[screen]:tags()
|
local tags = capi.screen[screen]:tags()
|
||||||
local vtags = {}
|
local vtags = {}
|
||||||
|
@ -244,96 +245,96 @@ end
|
||||||
|
|
||||||
--- Return only the first visible tag.
|
--- Return only the first visible tag.
|
||||||
-- @param s Screen number.
|
-- @param s Screen number.
|
||||||
function selected(s)
|
function tag.selected(s)
|
||||||
return selectedlist(s)[1]
|
return tag.selectedlist(s)[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set master width factor.
|
--- Set master width factor.
|
||||||
-- @param mwfact Master width factor.
|
-- @param mwfact Master width factor.
|
||||||
function setmwfact(mwfact, t)
|
function tag.setmwfact(mwfact, t)
|
||||||
local t = t or selected()
|
local t = t or tag.selected()
|
||||||
if mwfact >= 0 and mwfact <= 1 then
|
if mwfact >= 0 and mwfact <= 1 then
|
||||||
setproperty(t, "mwfact", mwfact)
|
tag.setproperty(t, "mwfact", mwfact)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Increase master width factor.
|
--- Increase master width factor.
|
||||||
-- @param add Value to add to master width factor.
|
-- @param add Value to add to master width factor.
|
||||||
function incmwfact(add, t)
|
function tag.incmwfact(add, t)
|
||||||
setmwfact(getmwfact(t) + add, t)
|
tag.setmwfact(tag.getmwfact(t) + add, t)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get master width factor.
|
--- Get master width factor.
|
||||||
-- @param t Optional tag.
|
-- @param t Optional tag.
|
||||||
function getmwfact(t)
|
function tag.getmwfact(t)
|
||||||
local t = t or selected()
|
local t = t or tag.selected()
|
||||||
return getproperty(t, "mwfact") or 0.5
|
return tag.getproperty(t, "mwfact") or 0.5
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set the number of master windows.
|
--- Set the number of master windows.
|
||||||
-- @param nmaster The number of master windows.
|
-- @param nmaster The number of master windows.
|
||||||
-- @param t Optional tag.
|
-- @param t Optional tag.
|
||||||
function setnmaster(nmaster, t)
|
function tag.setnmaster(nmaster, t)
|
||||||
local t = t or selected()
|
local t = t or tag.selected()
|
||||||
if nmaster >= 0 then
|
if nmaster >= 0 then
|
||||||
setproperty(t, "nmaster", nmaster)
|
tag.setproperty(t, "nmaster", nmaster)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get the number of master windows.
|
--- Get the number of master windows.
|
||||||
-- @param t Optional tag.
|
-- @param t Optional tag.
|
||||||
function getnmaster(t)
|
function tag.getnmaster(t)
|
||||||
local t = t or selected()
|
local t = t or tag.selected()
|
||||||
return getproperty(t, "nmaster") or 1
|
return tag.getproperty(t, "nmaster") or 1
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Increase the number of master windows.
|
--- Increase the number of master windows.
|
||||||
-- @param add Value to add to number of master windows.
|
-- @param add Value to add to number of master windows.
|
||||||
function incnmaster(add, t)
|
function tag.incnmaster(add, t)
|
||||||
setnmaster(getnmaster(t) + add, t)
|
tag.setnmaster(tag.getnmaster(t) + add, t)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Set the tag icon
|
--- Set the tag icon
|
||||||
-- @param icon the icon to set, either path or image object
|
-- @param icon the icon to set, either path or image object
|
||||||
-- @param tag the tag
|
-- @param tag the tag
|
||||||
function seticon(icon, tag)
|
function tag.seticon(icon, _tag)
|
||||||
local tag = tag or selected()
|
local _tag = _tag or tag.selected()
|
||||||
setproperty(tag, "icon", icon)
|
tag.setproperty(_tag, "icon", icon)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get the tag icon
|
--- Get the tag icon
|
||||||
-- @param t the tag
|
-- @param t the tag
|
||||||
function geticon(tag)
|
function tag.geticon(_tag)
|
||||||
local tag = tag or selected()
|
local _tag = _tag or tag.selected()
|
||||||
return getproperty(tag, "icon")
|
return tag.getproperty(_tag, "icon")
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set number of column windows.
|
--- Set number of column windows.
|
||||||
-- @param ncol The number of column.
|
-- @param ncol The number of column.
|
||||||
function setncol(ncol, t)
|
function tag.setncol(ncol, t)
|
||||||
local t = t or selected()
|
local t = t or tag.selected()
|
||||||
if ncol >= 1 then
|
if ncol >= 1 then
|
||||||
setproperty(t, "ncol", ncol)
|
tag.setproperty(t, "ncol", ncol)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get number of column windows.
|
--- Get number of column windows.
|
||||||
-- @param t Optional tag.
|
-- @param t Optional tag.
|
||||||
function getncol(t)
|
function tag.getncol(t)
|
||||||
local t = t or selected()
|
local t = t or tag.selected()
|
||||||
return getproperty(t, "ncol") or 1
|
return tag.getproperty(t, "ncol") or 1
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Increase number of column windows.
|
--- Increase number of column windows.
|
||||||
-- @param add Value to add to number of column windows.
|
-- @param add Value to add to number of column windows.
|
||||||
function incncol(add, t)
|
function tag.incncol(add, t)
|
||||||
setncol(getncol(t) + add, t)
|
tag.setncol(tag.getncol(t) + add, t)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- View no tag.
|
--- View no tag.
|
||||||
-- @param Optional screen number.
|
-- @param Optional screen number.
|
||||||
function viewnone(screen)
|
function tag.viewnone(screen)
|
||||||
local tags = capi.screen[screen or capi.mouse.screen]:tags()
|
local tags = capi.screen[screen or capi.mouse.screen]:tags()
|
||||||
for i, t in pairs(tags) do
|
for i, t in pairs(tags) do
|
||||||
t.selected = false
|
t.selected = false
|
||||||
|
@ -343,17 +344,17 @@ end
|
||||||
--- View a tag by its taglist index.
|
--- View a tag by its taglist index.
|
||||||
-- @param i The relative index to see.
|
-- @param i The relative index to see.
|
||||||
-- @param screen Optional screen number.
|
-- @param screen Optional screen number.
|
||||||
function viewidx(i, screen)
|
function tag.viewidx(i, screen)
|
||||||
local screen = screen and screen.index or capi.mouse.screen
|
local screen = screen and screen.index or capi.mouse.screen
|
||||||
local tags = capi.screen[screen]:tags()
|
local tags = capi.screen[screen]:tags()
|
||||||
local showntags = {}
|
local showntags = {}
|
||||||
for k, t in ipairs(tags) do
|
for k, t in ipairs(tags) do
|
||||||
if not getproperty(t, "hide") then
|
if not tag.getproperty(t, "hide") then
|
||||||
table.insert(showntags, t)
|
table.insert(showntags, t)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local sel = selected(screen)
|
local sel = tag.selected(screen)
|
||||||
viewnone(screen)
|
tag.viewnone(screen)
|
||||||
for k, t in ipairs(showntags) do
|
for k, t in ipairs(showntags) do
|
||||||
if t == sel then
|
if t == sel then
|
||||||
showntags[util.cycle(#showntags, k + i)].selected = true
|
showntags[util.cycle(#showntags, k + i)].selected = true
|
||||||
|
@ -365,8 +366,8 @@ end
|
||||||
--- Get a tag's index in the screen[]:tags() table.
|
--- Get a tag's index in the screen[]:tags() table.
|
||||||
-- @param query_tag The tag object to find. [selected()]
|
-- @param query_tag The tag object to find. [selected()]
|
||||||
-- @return The index of the tag, nil if the tag is not found.
|
-- @return The index of the tag, nil if the tag is not found.
|
||||||
function getidx(query_tag)
|
function tag.getidx(query_tag)
|
||||||
local query_tag = query_tag or selected()
|
local query_tag = query_tag or tag.selected()
|
||||||
if query_tag == nil then return end
|
if query_tag == nil then return end
|
||||||
|
|
||||||
for i, t in ipairs(capi.screen[query_tag.screen]:tags()) do
|
for i, t in ipairs(capi.screen[query_tag.screen]:tags()) do
|
||||||
|
@ -378,24 +379,24 @@ end
|
||||||
|
|
||||||
--- View next tag. This is the same as tag.viewidx(1).
|
--- View next tag. This is the same as tag.viewidx(1).
|
||||||
-- @param screen The screen number.
|
-- @param screen The screen number.
|
||||||
function viewnext(screen)
|
function tag.viewnext(screen)
|
||||||
return viewidx(1, screen)
|
return tag.viewidx(1, screen)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- View previous tag. This is the same a tag.viewidx(-1).
|
--- View previous tag. This is the same a tag.viewidx(-1).
|
||||||
-- @param screen The screen number.
|
-- @param screen The screen number.
|
||||||
function viewprev(screen)
|
function tag.viewprev(screen)
|
||||||
return viewidx(-1, screen)
|
return tag.viewidx(-1, screen)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- View only a tag.
|
--- View only a tag.
|
||||||
-- @param t The tag object.
|
-- @param t The tag object.
|
||||||
function viewonly(t)
|
function tag.viewonly(t)
|
||||||
local tags = capi.screen[t.screen]:tags()
|
local tags = capi.screen[t.screen]:tags()
|
||||||
-- First, untag everyone except the viewed tag.
|
-- First, untag everyone except the viewed tag.
|
||||||
for _, tag in pairs(tags) do
|
for _, _tag in pairs(tags) do
|
||||||
if tag ~= t then
|
if _tag ~= t then
|
||||||
tag.selected = false
|
_tag.selected = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Then, set this one to selected.
|
-- Then, set this one to selected.
|
||||||
|
@ -408,22 +409,22 @@ end
|
||||||
--- View only a set of tags.
|
--- View only a set of tags.
|
||||||
-- @param tags A table with tags to view only.
|
-- @param tags A table with tags to view only.
|
||||||
-- @param screen Optional screen number of the tags.
|
-- @param screen Optional screen number of the tags.
|
||||||
function viewmore(tags, screen)
|
function tag.viewmore(tags, screen)
|
||||||
local screen_tags = capi.screen[screen or capi.mouse.screen]:tags()
|
local screen_tags = capi.screen[screen or capi.mouse.screen]:tags()
|
||||||
for _, tag in ipairs(screen_tags) do
|
for _, _tag in ipairs(screen_tags) do
|
||||||
if not util.table.hasitem(tags, tag) then
|
if not util.table.hasitem(tags, _tag) then
|
||||||
tag.selected = false
|
_tag.selected = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for _, tag in ipairs(tags) do
|
for _, _tag in ipairs(tags) do
|
||||||
tag.selected = true
|
_tag.selected = true
|
||||||
end
|
end
|
||||||
capi.screen[screen]:emit_signal("tag::history::update")
|
capi.screen[screen]:emit_signal("tag::history::update")
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Toggle selection of a tag
|
--- Toggle selection of a tag
|
||||||
-- @param tag Tag to be toggled
|
-- @param tag Tag to be toggled
|
||||||
function viewtoggle(t)
|
function tag.viewtoggle(t)
|
||||||
t.selected = not t.selected
|
t.selected = not t.selected
|
||||||
capi.screen[t.screen]:emit_signal("tag::history::update")
|
capi.screen[t.screen]:emit_signal("tag::history::update")
|
||||||
end
|
end
|
||||||
|
@ -431,17 +432,17 @@ end
|
||||||
--- Get tag data table.
|
--- Get tag data table.
|
||||||
-- @param tag The Tag.
|
-- @param tag The Tag.
|
||||||
-- @return The data table.
|
-- @return The data table.
|
||||||
function getdata(tag)
|
function tag.getdata(_tag)
|
||||||
return data.tags[tag]
|
return data.tags[_tag]
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get a tag property.
|
--- Get a tag property.
|
||||||
-- @param tag The tag.
|
-- @param tag The tag.
|
||||||
-- @param prop The property name.
|
-- @param prop The property name.
|
||||||
-- @return The property.
|
-- @return The property.
|
||||||
function getproperty(tag, prop)
|
function tag.getproperty(_tag, prop)
|
||||||
if data.tags[tag] then
|
if data.tags[_tag] then
|
||||||
return data.tags[tag][prop]
|
return data.tags[_tag][prop]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -451,41 +452,41 @@ end
|
||||||
-- @param tag The tag.
|
-- @param tag The tag.
|
||||||
-- @param prop The property name.
|
-- @param prop The property name.
|
||||||
-- @param value The value.
|
-- @param value The value.
|
||||||
function setproperty(tag, prop, value)
|
function tag.setproperty(_tag, prop, value)
|
||||||
if not data.tags[tag] then
|
if not data.tags[_tag] then
|
||||||
data.tags[tag] = {}
|
data.tags[_tag] = {}
|
||||||
end
|
end
|
||||||
data.tags[tag][prop] = value
|
data.tags[_tag][prop] = value
|
||||||
tag:emit_signal("property::" .. prop)
|
_tag:emit_signal("property::" .. prop)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Tag a client with the set of current tags.
|
--- Tag a client with the set of current tags.
|
||||||
-- @param c The client to tag.
|
-- @param c The client to tag.
|
||||||
-- @param startup Optional: don't do anything if true.
|
-- @param startup Optional: don't do anything if true.
|
||||||
function withcurrent(c, startup)
|
function tag.withcurrent(c, startup)
|
||||||
if startup ~= true then
|
if startup ~= true then
|
||||||
if #c:tags() == 0 then
|
if #c:tags() == 0 then
|
||||||
c:tags(selectedlist(c.screen))
|
c:tags(tag.selectedlist(c.screen))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function attached_connect_signal_screen(screen, sig, func)
|
local function attached_connect_signal_screen(screen, sig, func)
|
||||||
capi.screen[screen]:connect_signal("tag::attach", function (s, tag)
|
capi.screen[screen]:connect_signal("tag::attach", function (s, _tag)
|
||||||
tag:connect_signal(sig, func)
|
_tag:connect_signal(sig, func)
|
||||||
end)
|
end)
|
||||||
capi.screen[screen]:connect_signal("tag::detach", function (s, tag)
|
capi.screen[screen]:connect_signal("tag::detach", function (s, _tag)
|
||||||
tag:disconnect_signal(sig, func)
|
_tag:disconnect_signal(sig, func)
|
||||||
end)
|
end)
|
||||||
for _, tag in ipairs(capi.screen[screen]:tags()) do
|
for _, _tag in ipairs(capi.screen[screen]:tags()) do
|
||||||
tag:connect_signal(sig, func)
|
_tag:connect_signal(sig, func)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Add a signal to all attached tag and all tag that will be attached in the
|
--- Add a signal to all attached tag and all tag that will be attached in the
|
||||||
-- future. When a tag is detach from the screen, its signal is removed.
|
-- future. When a tag is detach from the screen, its signal is removed.
|
||||||
-- @param screen The screen concerned, or all if nil.
|
-- @param screen The screen concerned, or all if nil.
|
||||||
function attached_connect_signal(screen, ...)
|
function tag.attached_connect_signal(screen, ...)
|
||||||
if screen then
|
if screen then
|
||||||
attached_connect_signal_screen(screen, ...)
|
attached_connect_signal_screen(screen, ...)
|
||||||
else
|
else
|
||||||
|
@ -510,10 +511,10 @@ capi.client.connect_signal("manage", function(c, startup)
|
||||||
c.screen = capi.mouse.screen
|
c.screen = capi.mouse.screen
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
c:connect_signal("property::screen", withcurrent)
|
c:connect_signal("property::screen", tag.withcurrent)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
capi.client.connect_signal("manage", withcurrent)
|
capi.client.connect_signal("manage", tag.withcurrent)
|
||||||
|
|
||||||
capi.tag.add_signal("property::hide")
|
capi.tag.add_signal("property::hide")
|
||||||
capi.tag.add_signal("property::icon")
|
capi.tag.add_signal("property::icon")
|
||||||
|
@ -525,9 +526,13 @@ capi.tag.add_signal("property::windowfact")
|
||||||
|
|
||||||
for s = 1, capi.screen.count() do
|
for s = 1, capi.screen.count() do
|
||||||
capi.screen[s]:add_signal("tag::history::update")
|
capi.screen[s]:add_signal("tag::history::update")
|
||||||
capi.screen[s]:connect_signal("tag::history::update", history.update)
|
capi.screen[s]:connect_signal("tag::history::update", tag.history.update)
|
||||||
end
|
end
|
||||||
|
|
||||||
setmetatable(_M, { __call = function (_, ...) return new(...) end })
|
function tag.mt:__call(...)
|
||||||
|
return tag.new(...)
|
||||||
|
end
|
||||||
|
|
||||||
|
return setmetatable(tag, tag.mt)
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
|
@ -46,7 +46,8 @@ local ipairs = ipairs
|
||||||
-- </code>
|
-- </code>
|
||||||
-- Now the same tooltip is only attached to <code>myclock</code>.<br/>
|
-- Now the same tooltip is only attached to <code>myclock</code>.<br/>
|
||||||
-- </p>
|
-- </p>
|
||||||
module("awful.tooltip")
|
-- awful.tooltip
|
||||||
|
local tooltip = { mt = {} }
|
||||||
|
|
||||||
local data = setmetatable({}, { __mode = 'k' })
|
local data = setmetatable({}, { __mode = 'k' })
|
||||||
|
|
||||||
|
@ -225,6 +226,10 @@ local function new(args)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
setmetatable(_M, { __call = function(_, ...) return new(...) end })
|
function tooltip.mt:__call(...)
|
||||||
|
return new(...)
|
||||||
|
end
|
||||||
|
|
||||||
|
return setmetatable(tooltip, tooltip.mt)
|
||||||
|
|
||||||
-- vim: ft=lua:et:sw=4:ts=4:sts=4:enc=utf-8:tw=78
|
-- vim: ft=lua:et:sw=4:ts=4:sts=4:enc=utf-8:tw=78
|
||||||
|
|
|
@ -24,13 +24,13 @@ local capi =
|
||||||
}
|
}
|
||||||
|
|
||||||
--- Utility module for awful
|
--- Utility module for awful
|
||||||
module("awful.util")
|
-- awful.util
|
||||||
|
local util = {}
|
||||||
table = {}
|
util.table = {}
|
||||||
|
|
||||||
shell = os.getenv("SHELL") or "/bin/sh"
|
shell = os.getenv("SHELL") or "/bin/sh"
|
||||||
|
|
||||||
function deprecate(see)
|
function util.deprecate(see)
|
||||||
io.stderr:write("W: awful: function is deprecated")
|
io.stderr:write("W: awful: function is deprecated")
|
||||||
if see then
|
if see then
|
||||||
io.stderr:write(", see " .. see)
|
io.stderr:write(", see " .. see)
|
||||||
|
@ -42,7 +42,7 @@ end
|
||||||
--- Strip alpha part of color.
|
--- Strip alpha part of color.
|
||||||
-- @param color The color.
|
-- @param color The color.
|
||||||
-- @return The color without alpha channel.
|
-- @return The color without alpha channel.
|
||||||
function color_strip_alpha(color)
|
function util.color_strip_alpha(color)
|
||||||
if color:len() == 9 then
|
if color:len() == 9 then
|
||||||
color = color:sub(1, 7)
|
color = color:sub(1, 7)
|
||||||
end
|
end
|
||||||
|
@ -53,7 +53,7 @@ end
|
||||||
-- @param t A length. Must be greater than zero.
|
-- @param t A length. Must be greater than zero.
|
||||||
-- @param i An absolute index to fit into #t.
|
-- @param i An absolute index to fit into #t.
|
||||||
-- @return An integer in (1, t) or nil if t is less than or equal to zero.
|
-- @return An integer in (1, t) or nil if t is less than or equal to zero.
|
||||||
function cycle(t, i)
|
function util.cycle(t, i)
|
||||||
if t < 1 then return end
|
if t < 1 then return end
|
||||||
while i > t do i = i - t end
|
while i > t do i = i - t end
|
||||||
while i < 1 do i = i + t end
|
while i < 1 do i = i + t end
|
||||||
|
@ -63,7 +63,7 @@ end
|
||||||
--- Create a directory
|
--- Create a directory
|
||||||
-- @param dir The directory.
|
-- @param dir The directory.
|
||||||
-- @return mkdir return code
|
-- @return mkdir return code
|
||||||
function mkdir(dir)
|
function util.mkdir(dir)
|
||||||
return os.execute("mkdir -p " .. dir)
|
return os.execute("mkdir -p " .. dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ end
|
||||||
-- @param sn Enable startup-notification.
|
-- @param sn Enable startup-notification.
|
||||||
-- @param screen The screen where to spawn window.
|
-- @param screen The screen where to spawn window.
|
||||||
-- @return The awesome.spawn return value.
|
-- @return The awesome.spawn return value.
|
||||||
function spawn(cmd, sn, screen)
|
function util.spawn(cmd, sn, screen)
|
||||||
if cmd and cmd ~= "" then
|
if cmd and cmd ~= "" then
|
||||||
if sn == nil then sn = true end
|
if sn == nil then sn = true end
|
||||||
return capi.awesome.spawn(cmd, sn, screen or capi.mouse.screen)
|
return capi.awesome.spawn(cmd, sn, screen or capi.mouse.screen)
|
||||||
|
@ -82,7 +82,7 @@ end
|
||||||
--- Spawn a program using the shell.
|
--- Spawn a program using the shell.
|
||||||
-- @param cmd The command.
|
-- @param cmd The command.
|
||||||
-- @param screen The screen where to run the command.
|
-- @param screen The screen where to run the command.
|
||||||
function spawn_with_shell(cmd, screen)
|
function util.spawn_with_shell(cmd, screen)
|
||||||
if cmd and cmd ~= "" then
|
if cmd and cmd ~= "" then
|
||||||
cmd = shell .. " -c \"" .. cmd .. "\""
|
cmd = shell .. " -c \"" .. cmd .. "\""
|
||||||
return capi.awesome.spawn(cmd, false, screen or capi.mouse.screen)
|
return capi.awesome.spawn(cmd, false, screen or capi.mouse.screen)
|
||||||
|
@ -92,7 +92,7 @@ end
|
||||||
--- Read a program output and returns its output as a string.
|
--- Read a program output and returns its output as a string.
|
||||||
-- @param cmd The command to run.
|
-- @param cmd The command to run.
|
||||||
-- @return A string with the program output, or the error if one occured.
|
-- @return A string with the program output, or the error if one occured.
|
||||||
function pread(cmd)
|
function util.pread(cmd)
|
||||||
if cmd and cmd ~= "" then
|
if cmd and cmd ~= "" then
|
||||||
local f, err = io.popen(cmd, 'r')
|
local f, err = io.popen(cmd, 'r')
|
||||||
if f then
|
if f then
|
||||||
|
@ -107,7 +107,7 @@ end
|
||||||
|
|
||||||
--- Eval Lua code.
|
--- Eval Lua code.
|
||||||
-- @return The return value of Lua code.
|
-- @return The return value of Lua code.
|
||||||
function eval(s)
|
function util.eval(s)
|
||||||
return assert(loadstring(s))()
|
return assert(loadstring(s))()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ local xml_entity_names = { ["'"] = "'", ["\""] = """, ["<"] = "<",
|
||||||
-- Useful to set raw text in textbox.
|
-- Useful to set raw text in textbox.
|
||||||
-- @param text Text to escape.
|
-- @param text Text to escape.
|
||||||
-- @return Escape text.
|
-- @return Escape text.
|
||||||
function escape(text)
|
function util.escape(text)
|
||||||
return text and text:gsub("['&<>\"]", xml_entity_names) or nil
|
return text and text:gsub("['&<>\"]", xml_entity_names) or nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ local xml_entity_chars = { lt = "<", gt = ">", nbsp = " ", quot = "\"", apos = "
|
||||||
--- Unescape a string from entities.
|
--- Unescape a string from entities.
|
||||||
-- @param text Text to unescape.
|
-- @param text Text to unescape.
|
||||||
-- @return Unescaped text.
|
-- @return Unescaped text.
|
||||||
function unescape(text)
|
function util.unescape(text)
|
||||||
return text and text:gsub("&(%a+);", xml_entity_chars) or nil
|
return text and text:gsub("&(%a+);", xml_entity_chars) or nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ end
|
||||||
-- @param path The file path.
|
-- @param path The file path.
|
||||||
-- @return A function if everything is alright, a string with the error
|
-- @return A function if everything is alright, a string with the error
|
||||||
-- otherwise.
|
-- otherwise.
|
||||||
function checkfile(path)
|
function util.checkfile(path)
|
||||||
local f, e = loadfile(path)
|
local f, e = loadfile(path)
|
||||||
-- Return function if function, otherwise return error.
|
-- Return function if function, otherwise return error.
|
||||||
if f then return f end
|
if f then return f end
|
||||||
|
@ -144,8 +144,8 @@ end
|
||||||
-- It checks if the configuration file is valid, and then restart if it's ok.
|
-- It checks if the configuration file is valid, and then restart if it's ok.
|
||||||
-- If it's not ok, the error will be returned.
|
-- If it's not ok, the error will be returned.
|
||||||
-- @return Never return if awesome restart, or return a string error.
|
-- @return Never return if awesome restart, or return a string error.
|
||||||
function restart()
|
function util.restart()
|
||||||
local c = checkfile(capi.awesome.conffile)
|
local c = util.checkfile(capi.awesome.conffile)
|
||||||
|
|
||||||
if type(c) ~= "function" then
|
if type(c) ~= "function" then
|
||||||
return c
|
return c
|
||||||
|
@ -159,7 +159,7 @@ end
|
||||||
-- default paths.
|
-- default paths.
|
||||||
-- @param d The directory to get (either "config" or "cache").
|
-- @param d The directory to get (either "config" or "cache").
|
||||||
-- @return A string containing the requested path.
|
-- @return A string containing the requested path.
|
||||||
function getdir(d)
|
function util.getdir(d)
|
||||||
if d == "config" then
|
if d == "config" then
|
||||||
local dir = os.getenv("XDG_CONFIG_HOME")
|
local dir = os.getenv("XDG_CONFIG_HOME")
|
||||||
if dir then
|
if dir then
|
||||||
|
@ -182,7 +182,7 @@ end
|
||||||
-- @param dirs Table of dirs to search, otherwise { '/usr/share/pixmaps/' }
|
-- @param dirs Table of dirs to search, otherwise { '/usr/share/pixmaps/' }
|
||||||
-- @param size Optional size. If this is specified, subdirectories <size>x<size>
|
-- @param size Optional size. If this is specified, subdirectories <size>x<size>
|
||||||
-- of the dirs are searched first
|
-- of the dirs are searched first
|
||||||
function geticonpath(iconname, exts, dirs, size)
|
function util.geticonpath(iconname, exts, dirs, size)
|
||||||
exts = exts or { 'png', 'gif' }
|
exts = exts or { 'png', 'gif' }
|
||||||
dirs = dirs or { '/usr/share/pixmaps/' }
|
dirs = dirs or { '/usr/share/pixmaps/' }
|
||||||
for _, d in pairs(dirs) do
|
for _, d in pairs(dirs) do
|
||||||
|
@ -191,12 +191,12 @@ function geticonpath(iconname, exts, dirs, size)
|
||||||
if size then
|
if size then
|
||||||
icon = string.format("%s%ux%u/%s.%s",
|
icon = string.format("%s%ux%u/%s.%s",
|
||||||
d, size, size, iconname, e)
|
d, size, size, iconname, e)
|
||||||
if file_readable(icon) then
|
if util.file_readable(icon) then
|
||||||
return icon
|
return icon
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
icon = d .. iconname .. '.' .. e
|
icon = d .. iconname .. '.' .. e
|
||||||
if file_readable(icon) then
|
if util.file_readable(icon) then
|
||||||
return icon
|
return icon
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -206,7 +206,7 @@ end
|
||||||
--- Check if file exists and is readable.
|
--- Check if file exists and is readable.
|
||||||
-- @param filename The file path
|
-- @param filename The file path
|
||||||
-- @return True if file exists and readable.
|
-- @return True if file exists and readable.
|
||||||
function file_readable(filename)
|
function util.file_readable(filename)
|
||||||
local file = io.open(filename)
|
local file = io.open(filename)
|
||||||
if file then
|
if file then
|
||||||
io.close(file)
|
io.close(file)
|
||||||
|
@ -246,7 +246,7 @@ end
|
||||||
-- { }, { 10 }, { 15 }, { 34 }, { 10, 15 }, { 10, 34 }, etc.
|
-- { }, { 10 }, { 15 }, { 34 }, { 10, 15 }, { 10, 34 }, etc.
|
||||||
-- @param set A set.
|
-- @param set A set.
|
||||||
-- @return A table with all subset.
|
-- @return A table with all subset.
|
||||||
function subsets(set)
|
function util.subsets(set)
|
||||||
local mask = {}
|
local mask = {}
|
||||||
local ret = {}
|
local ret = {}
|
||||||
for i = 1, #set do mask[i] = false end
|
for i = 1, #set do mask[i] = false end
|
||||||
|
@ -264,7 +264,7 @@ end
|
||||||
-- This will iterate all tables and insert all their keys into a new table.
|
-- This will iterate all tables and insert all their keys into a new table.
|
||||||
-- @param args A list of tables to join
|
-- @param args A list of tables to join
|
||||||
-- @return A new table containing all keys from the arguments.
|
-- @return A new table containing all keys from the arguments.
|
||||||
function table.join(...)
|
function util.table.join(...)
|
||||||
local ret = {}
|
local ret = {}
|
||||||
for i, t in ipairs({...}) do
|
for i, t in ipairs({...}) do
|
||||||
if t then
|
if t then
|
||||||
|
@ -284,7 +284,7 @@ end
|
||||||
-- @param t The table.
|
-- @param t The table.
|
||||||
-- @param item The item to look for in values of the table.
|
-- @param item The item to look for in values of the table.
|
||||||
-- @return The key were the item is found, or nil if not found.
|
-- @return The key were the item is found, or nil if not found.
|
||||||
function table.hasitem(t, item)
|
function util.table.hasitem(t, item)
|
||||||
for k, v in pairs(t) do
|
for k, v in pairs(t) do
|
||||||
if v == item then
|
if v == item then
|
||||||
return k
|
return k
|
||||||
|
@ -297,7 +297,7 @@ end
|
||||||
-- @param width Maximum length of each line. Default: 72.
|
-- @param width Maximum length of each line. Default: 72.
|
||||||
-- @param indent Number of spaces added before each wrapped line. Default: 0.
|
-- @param indent Number of spaces added before each wrapped line. Default: 0.
|
||||||
-- @return The string with lines wrapped to width.
|
-- @return The string with lines wrapped to width.
|
||||||
function linewrap(text, width, indent)
|
function util.linewrap(text, width, indent)
|
||||||
local text = text or ""
|
local text = text or ""
|
||||||
local width = width or 72
|
local width = width or 72
|
||||||
local indent = indent or 0
|
local indent = indent or 0
|
||||||
|
@ -315,7 +315,7 @@ end
|
||||||
--- Get a sorted table with all integer keys from a table
|
--- Get a sorted table with all integer keys from a table
|
||||||
-- @param t the table for which the keys to get
|
-- @param t the table for which the keys to get
|
||||||
-- @return A table with keys
|
-- @return A table with keys
|
||||||
function table.keys(t)
|
function util.table.keys(t)
|
||||||
local keys = { }
|
local keys = { }
|
||||||
for k, _ in pairs(t) do
|
for k, _ in pairs(t) do
|
||||||
rtable.insert(keys, k)
|
rtable.insert(keys, k)
|
||||||
|
@ -330,8 +330,8 @@ end
|
||||||
-- @param t The table to retrieve the keys for
|
-- @param t The table to retrieve the keys for
|
||||||
-- @param ... the types to look for
|
-- @param ... the types to look for
|
||||||
-- @return A filtered table with keys
|
-- @return A filtered table with keys
|
||||||
function table.keys_filter(t, ...)
|
function util.table.keys_filter(t, ...)
|
||||||
local keys = table.keys(t)
|
local keys = util.table.keys(t)
|
||||||
local keys_filtered = { }
|
local keys_filtered = { }
|
||||||
for _, k in pairs(keys) do
|
for _, k in pairs(keys) do
|
||||||
for _, et in pairs({...}) do
|
for _, et in pairs({...}) do
|
||||||
|
@ -347,7 +347,7 @@ end
|
||||||
--- Reverse a table
|
--- Reverse a table
|
||||||
-- @param t the table to reverse
|
-- @param t the table to reverse
|
||||||
-- @return the reversed table
|
-- @return the reversed table
|
||||||
function table.reverse(t)
|
function util.table.reverse(t)
|
||||||
local tr = { }
|
local tr = { }
|
||||||
-- reverse all elements with integer keys
|
-- reverse all elements with integer keys
|
||||||
for _, v in ipairs(t) do
|
for _, v in ipairs(t) do
|
||||||
|
@ -365,11 +365,11 @@ end
|
||||||
--- Clone a table
|
--- Clone a table
|
||||||
-- @param t the table to clone
|
-- @param t the table to clone
|
||||||
-- @return a clone of t
|
-- @return a clone of t
|
||||||
function table.clone(t)
|
function util.table.clone(t)
|
||||||
local c = { }
|
local c = { }
|
||||||
for k, v in pairs(t) do
|
for k, v in pairs(t) do
|
||||||
if type(v) == "table" then
|
if type(v) == "table" then
|
||||||
c[k] = table.clone(v)
|
c[k] = util.table.clone(v)
|
||||||
else
|
else
|
||||||
c[k] = v
|
c[k] = v
|
||||||
end
|
end
|
||||||
|
@ -385,7 +385,7 @@ end
|
||||||
-- @param filter a function that returns true to indicate a positive match
|
-- @param filter a function that returns true to indicate a positive match
|
||||||
-- @param start what index to start iterating from. Default is 1 (=> start of
|
-- @param start what index to start iterating from. Default is 1 (=> start of
|
||||||
-- the table)
|
-- the table)
|
||||||
function table.iterate(t, filter, start)
|
function util.table.iterate(t, filter, start)
|
||||||
local count = 0
|
local count = 0
|
||||||
local index = start or 1
|
local index = start or 1
|
||||||
local length = #t
|
local length = #t
|
||||||
|
@ -393,10 +393,13 @@ function table.iterate(t, filter, start)
|
||||||
return function ()
|
return function ()
|
||||||
while count < length do
|
while count < length do
|
||||||
local item = t[index]
|
local item = t[index]
|
||||||
index = cycle(#t, index + 1)
|
index = util.cycle(#t, index + 1)
|
||||||
count = count + 1
|
count = count + 1
|
||||||
if filter(item) then return item end
|
if filter(item) then return item end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return util
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
|
@ -22,7 +22,8 @@ local beautiful = require("beautiful")
|
||||||
--- Wibox module for awful.
|
--- Wibox module for awful.
|
||||||
-- This module allows you to easily create wibox and attach them to the edge of
|
-- This module allows you to easily create wibox and attach them to the edge of
|
||||||
-- a screen.
|
-- a screen.
|
||||||
module("awful.wibox")
|
-- awful.wibox
|
||||||
|
local awfulwibox = { mt = {} }
|
||||||
|
|
||||||
-- Array of table with wiboxes inside.
|
-- Array of table with wiboxes inside.
|
||||||
-- It's an array so it is ordered.
|
-- It's an array so it is ordered.
|
||||||
|
@ -31,7 +32,7 @@ local wiboxes = {}
|
||||||
--- Get a wibox position if it has been set, or return top.
|
--- Get a wibox position if it has been set, or return top.
|
||||||
-- @param wibox The wibox
|
-- @param wibox The wibox
|
||||||
-- @return The wibox position.
|
-- @return The wibox position.
|
||||||
function get_position(wibox)
|
function awfulwibox.get_position(wibox)
|
||||||
for _, wprop in ipairs(wiboxes) do
|
for _, wprop in ipairs(wiboxes) do
|
||||||
if wprop.wibox == wibox then
|
if wprop.wibox == wibox then
|
||||||
return wprop.position
|
return wprop.position
|
||||||
|
@ -45,7 +46,7 @@ end
|
||||||
-- @param position The position: top, bottom left or right.
|
-- @param position The position: top, bottom left or right.
|
||||||
-- @param screen If the wibox it not attached to a screen, specified on which
|
-- @param screen If the wibox it not attached to a screen, specified on which
|
||||||
-- screen the position should be set.
|
-- screen the position should be set.
|
||||||
function set_position(wibox, position, screen)
|
function awfulwibox.set_position(wibox, position, screen)
|
||||||
local area = capi.screen[screen].geometry
|
local area = capi.screen[screen].geometry
|
||||||
|
|
||||||
-- The "length" of a wibox is always chosen to be the optimal size
|
-- The "length" of a wibox is always chosen to be the optimal size
|
||||||
|
@ -72,7 +73,7 @@ end
|
||||||
-- Reset all wiboxes positions.
|
-- Reset all wiboxes positions.
|
||||||
local function update_all_wiboxes_position()
|
local function update_all_wiboxes_position()
|
||||||
for _, wprop in ipairs(wiboxes) do
|
for _, wprop in ipairs(wiboxes) do
|
||||||
set_position(wprop.wibox, wprop.position, wprop.screen)
|
awfulwibox.set_position(wprop.wibox, wprop.position, wprop.screen)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -104,7 +105,7 @@ end
|
||||||
-- will be attached.
|
-- will be attached.
|
||||||
-- @param wibox The wibox to attach.
|
-- @param wibox The wibox to attach.
|
||||||
-- @param position The position of the wibox: top, bottom, left or right.
|
-- @param position The position of the wibox: top, bottom, left or right.
|
||||||
function attach(wibox, position, screen)
|
function awfulwibox.attach(wibox, position, screen)
|
||||||
-- Store wibox as attached in a weak-valued table
|
-- Store wibox as attached in a weak-valued table
|
||||||
local wibox_prop_table
|
local wibox_prop_table
|
||||||
-- Start from end since we sometimes remove items
|
-- Start from end since we sometimes remove items
|
||||||
|
@ -141,8 +142,8 @@ end
|
||||||
-- @param align The alignment: left, right or center.
|
-- @param align The alignment: left, right or center.
|
||||||
-- @param screen If the wibox is not attached to any screen, you can specify the
|
-- @param screen If the wibox is not attached to any screen, you can specify the
|
||||||
-- screen where to align. Otherwise 1 is assumed.
|
-- screen where to align. Otherwise 1 is assumed.
|
||||||
function align(wibox, align, screen)
|
function awfulwibox.align(wibox, align, screen)
|
||||||
local position = get_position(wibox)
|
local position = awfulwibox.get_position(wibox)
|
||||||
local area = capi.screen[screen].workarea
|
local area = capi.screen[screen].workarea
|
||||||
|
|
||||||
if position == "right" then
|
if position == "right" then
|
||||||
|
@ -186,9 +187,9 @@ end
|
||||||
--- Stretch a wibox so it takes all screen width or height.
|
--- Stretch a wibox so it takes all screen width or height.
|
||||||
-- @param wibox The wibox.
|
-- @param wibox The wibox.
|
||||||
-- @param screen The screen to stretch on, or the wibox screen.
|
-- @param screen The screen to stretch on, or the wibox screen.
|
||||||
function stretch(wibox, screen)
|
function awfulwibox.stretch(wibox, screen)
|
||||||
if screen then
|
if screen then
|
||||||
local position = get_position(wibox)
|
local position = awfulwibox.get_position(wibox)
|
||||||
local area = capi.screen[screen].workarea
|
local area = capi.screen[screen].workarea
|
||||||
if position == "right" or position == "left" then
|
if position == "right" or position == "left" then
|
||||||
wibox.height = area.height - (2 * wibox.border_width)
|
wibox.height = area.height - (2 * wibox.border_width)
|
||||||
|
@ -208,7 +209,7 @@ end
|
||||||
-- You can also set the screen key with a screen number to attach the wibox.
|
-- You can also set the screen key with a screen number to attach the wibox.
|
||||||
-- If not specified, 1 is assumed.
|
-- If not specified, 1 is assumed.
|
||||||
-- @return The wibox created.
|
-- @return The wibox created.
|
||||||
function new(arg)
|
function awfulwibox.new(arg)
|
||||||
local arg = arg or {}
|
local arg = arg or {}
|
||||||
local position = arg.position or "top"
|
local position = arg.position or "top"
|
||||||
local has_to_stretch = true
|
local has_to_stretch = true
|
||||||
|
@ -251,14 +252,14 @@ function new(arg)
|
||||||
|
|
||||||
w.visible = true
|
w.visible = true
|
||||||
|
|
||||||
attach(w, position, screen)
|
awfulwibox.attach(w, position, screen)
|
||||||
if has_to_stretch then
|
if has_to_stretch then
|
||||||
stretch(w, screen)
|
awfulwibox.stretch(w, screen)
|
||||||
else
|
else
|
||||||
align(w, arg.align, screen)
|
awfulwibox.align(w, arg.align, screen)
|
||||||
end
|
end
|
||||||
|
|
||||||
set_position(w, position, screen)
|
awfulwibox.set_position(w, position, screen)
|
||||||
|
|
||||||
return w
|
return w
|
||||||
end
|
end
|
||||||
|
@ -275,6 +276,10 @@ end
|
||||||
capi.client.connect_signal("property::struts", update_wiboxes_on_struts)
|
capi.client.connect_signal("property::struts", update_wiboxes_on_struts)
|
||||||
capi.client.connect_signal("unmanage", update_wiboxes_on_struts)
|
capi.client.connect_signal("unmanage", update_wiboxes_on_struts)
|
||||||
|
|
||||||
setmetatable(_M, { __call = function(_, ...) return new(...) end })
|
function awfulwibox.mt:__call(...)
|
||||||
|
return awfulwibox.new(...)
|
||||||
|
end
|
||||||
|
|
||||||
|
return setmetatable(awfulwibox, awfulwibox.mt)
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
|
@ -193,7 +193,7 @@ end
|
||||||
-- Create the menubar wibox and widgets.
|
-- Create the menubar wibox and widgets.
|
||||||
local function initialize()
|
local function initialize()
|
||||||
instance.wibox = wibox({})
|
instance.wibox = wibox({})
|
||||||
instance.widget = get()
|
instance.widget = menubar.get()
|
||||||
instance.wibox.ontop = true
|
instance.wibox.ontop = true
|
||||||
instance.prompt = awful.widget.prompt()
|
instance.prompt = awful.widget.prompt()
|
||||||
local layout = wibox.layout.fixed.horizontal()
|
local layout = wibox.layout.fixed.horizontal()
|
||||||
|
|
|
@ -107,7 +107,7 @@ local function new()
|
||||||
ret.horizontal = false
|
ret.horizontal = false
|
||||||
ret.vertical = false
|
ret.vertical = false
|
||||||
|
|
||||||
for k, v in pairs(_M) do
|
for k, v in pairs(mirror) do
|
||||||
if type(v) == "function" then
|
if type(v) == "function" then
|
||||||
ret[k] = v
|
ret[k] = v
|
||||||
end
|
end
|
||||||
|
|
|
@ -106,7 +106,7 @@ end
|
||||||
local function new()
|
local function new()
|
||||||
local ret = widget_base.make_widget()
|
local ret = widget_base.make_widget()
|
||||||
|
|
||||||
for k, v in pairs(_M) do
|
for k, v in pairs(rotate) do
|
||||||
if type(v) == "function" then
|
if type(v) == "function" then
|
||||||
ret[k] = v
|
ret[k] = v
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue