Skip to content
Open
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ does not exactly feature the same keybindings as the default
configuration. I don't recommend using it by you can pick anything you
need in it.

This configuration is for _awesome_ 3.4. I did not update to 3.5 yet.
This configuration is a beta for _awesome_ 3.5, please report any bug.
Have a look at [@P-EB pull request](https://github.com/vincentbernat/awesome-configuration/pull/5).
This configuration may not be backward compatible for _awesome_ 3.4.

I rely on machine hostname for some configuration parts (see
`rc/start.lua`) for the most important part.
Expand Down
1 change: 1 addition & 0 deletions lib/keydoc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ local function key2str(key)
local sym = key.key or key.keysym
local translate = {
["#14"] = "#",
["#19"] = "0",
[" "] = "Space",
}
sym = translate[sym] or sym
Expand Down
50 changes: 25 additions & 25 deletions lib/quake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ function QuakeConsole:display()
-- First, we locate the terminal
local client = nil
local i = 0
for c in awful.client.cycle(function (c)
-- c.name may be changed!
return (c.instance == self.name or c.role == self.name)
end,
nil, self.screen) do
for c in awful.client.iterate(function (c)
-- c.name may be changed!
return c.instance == self.name
end,
nil, self.screen) do
i = i + 1
if i == 1 then
client = c
Expand Down Expand Up @@ -126,35 +126,35 @@ function QuakeConsole:new(config)
config.argname = config.argname or "-name %s" -- how to specify window name

-- If width or height <= 1 this is a proportion of the workspace
config.height = config.height or 0.25 -- height
config.width = config.width or 1 -- width
config.vert = config.vert or "top" -- top, bottom or center
config.height = config.height or 0.25 -- height
config.width = config.width or 1 -- width
config.vert = config.vert or "top" -- top, bottom or center
config.horiz = config.horiz or "center" -- left, right or center

config.screen = config.screen or capi.mouse.screen
config.visible = config.visible or false -- Initially, not visible

local console = setmetatable(config, { __index = QuakeConsole })
capi.client.add_signal("manage",
function(c)
if (c.instance == console.name or c.role == console.name) and c.screen == console.screen then
console:display()
end
end)
capi.client.add_signal("unmanage",
function(c)
if (c.instance == console.name or c.role == console.name) and c.screen == console.screen then
console.visible = false
end
end)
capi.client.connect_signal("manage",
function(c)
if c.instance == console.name and c.screen == console.screen then
console:display()
end
end)
capi.client.connect_signal("unmanage",
function(c)
if c.instance == console.name and c.screen == console.screen then
console.visible = false
end
end)

-- "Reattach" currently running QuakeConsole. This is in case awesome is restarted.
local reattach = capi.timer { timeout = 0 }
reattach:add_signal("timeout",
function()
reattach:stop()
console:display()
end)
reattach:connect_signal("timeout",
function()
reattach:stop()
console:display()
end)
reattach:start()
return console
end
Expand Down
85 changes: 44 additions & 41 deletions lib/shifty.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
-- TODO:
-- - Maybe name a tag after first client.


-- environment
local type = type
local ipairs = ipairs
Expand Down Expand Up @@ -75,7 +74,7 @@ end
local function setname(t, name)
if name then
local dispname = "" .. name
local pos = awful.tag.getproperty(t, "position") or "?"
local pos = awful.tag.getproperty(t, "position")
awful.tag.setproperty(t, "shortname", name)
if pos then
if "" .. pos ~= "" .. dispname then
Expand All @@ -101,7 +100,7 @@ local function freeposition()
end
end
for s = 1, capi.screen.count() do
for i, t in ipairs(capi.screen[s]:tags()) do
for i, t in ipairs(awful.tag.gettags(s)) do
local pos = awful.tag.getproperty(t, "position")
if pos then
local idx = awful.util.table.hasitem(positions, pos)
Expand All @@ -125,7 +124,7 @@ function name2tags(name, scr)
local ret = {}
local a, b = scr or 1, scr or capi.screen.count()
for s = a, b do
for i, t in ipairs(capi.screen[s]:tags()) do
for i, t in ipairs(awful.tag.gettags(s)) do
if name == getname(t) then
table.insert(ret, t)
end
Expand All @@ -144,7 +143,7 @@ end
-- @param tag : the tag object to find
-- @return the index [or zero] or end of the list
function tag2index(scr, tag)
for i, t in ipairs(capi.screen[scr]:tags()) do
for i, t in ipairs(awful.tag.gettags(scr)) do
if t == tag then return i end
end
end
Expand All @@ -154,7 +153,11 @@ end
function rename(tag, no_selectall)
local theme = beautiful.get()
local t = tag or awful.tag.selected(capi.mouse.screen)
local scr = t.screen

-- Sometimes we have no tag to rename.
if t == nil then return end

local scr = awful.tag.getscreen(t)
local bg = nil
local fg = nil
local text = getname(t)
Expand All @@ -168,10 +171,13 @@ function rename(tag, no_selectall)
fg = theme.fg_urgent or '#ffffff'
end

local tag_index = tag2index(scr, t)
-- Access to textbox widget in taglist
local tb_widget = taglist[scr].widgets[tag_index].widget.widgets[2].widget
awful.prompt.run({
fg_cursor = fg, bg_cursor = bg, ul_cursor = "single",
text = text, selectall = not no_selectall},
taglist[scr][tag2index(scr, t) * 2],
tb_widget,
function (name) if name:len() > 0 then setname(t, name); end end,
completion,
awful.util.getdir("cache") .. "/history_tags",
Expand All @@ -195,7 +201,7 @@ function send(idx)
local scr = capi.client.focus.screen or capi.mouse.screen
local sel = awful.tag.selected(scr)
local sel_idx = tag2index(scr, sel)
local tags = capi.screen[scr]:tags()
local tags = awful.tag.gettags(scr)
local target = awful.util.cycle(#tags, sel_idx + idx)
awful.client.movetotag(tags[target], capi.client.focus)
awful.tag.viewonly(tags[target])
Expand All @@ -210,8 +216,8 @@ function send_prev() send(-1) end
function pos2idx(pos, scr)
local v = 1
if pos and scr then
for i = #capi.screen[scr]:tags() , 1, -1 do
local t = capi.screen[scr]:tags()[i]
for i = #awful.tag.gettags(scr) , 1, -1 do
local t = awful.tag.gettags(scr)[i]
if awful.tag.getproperty(t, "position") and
awful.tag.getproperty(t, "position") <= pos then
v = i + 1
Expand Down Expand Up @@ -243,7 +249,7 @@ function tagtoscr(scr, t)
-- tag to move
local otag = t or awful.tag.selected()

otag.screen = scr
awful.tag.setscreen(otag, scr)
-- set screen and then reset tag to order properly
if #otag:clients() > 0 then
for _ , c in ipairs(otag:clients()) do
Expand Down Expand Up @@ -275,17 +281,17 @@ function set(t, args)

-- pick screen and get its tag table
local scr = args.screen or
(not t.screen and preset.screen) or
t.screen or
(not awful.tag.getscreen(t) and awful.tag.getscreen(preset)) or
awful.tag.getscreen(t) or
capi.mouse.screen

local clientstomove = nil
if scr > capi.screen.count() then scr = capi.screen.count() end
if t.screen and scr ~= t.screen then
if awful.tag.getscreen(t) and scr ~= awful.tag.getscreen(t) then
tagtoscr(scr, t)
t.screen = nil
awful.tag.setscreen(t, nil)
end
local tags = capi.screen[scr]:tags()
local tags = awful.tag.gettags(scr)

-- allow preset.layout to be a table to provide a different layout per
-- screen for a given tag
Expand Down Expand Up @@ -372,7 +378,10 @@ function set(t, args)
end

-- set tag properties and push the new tag table
capi.screen[scr]:tags(tags)
for i, tmp_tag in ipairs(tags) do
awful.tag.setscreen(tmp_tag, scr)
awful.tag.setproperty(tmp_tag, "index", i)
end
for prop, val in pairs(props) do awful.tag.setproperty(t, prop, val) end

-- execute run/spawn
Expand Down Expand Up @@ -402,17 +411,14 @@ function add(args)
local name = args.name or " "

-- initialize a new tag object and its data structure
local t = capi.tag{name = name}

-- tell set() that this is the first time
awful.tag.setproperty(t, "initial", true)
local t = awful.tag.add(name, { initial = true })

-- apply tag settings
set(t, args)

-- unless forbidden or if first tag on the screen, show the tag
if not (awful.tag.getproperty(t, "nopopup") or args.noswitch) or
#capi.screen[t.screen]:tags() == 1 then
#awful.tag.gettags(awful.tag.getscreen(t)) == 1 then
awful.tag.viewonly(t)
end

Expand All @@ -427,7 +433,7 @@ function add(args)
local tmr
local f = function() rename(t); tmr:stop() end
tmr = capi.timer({timeout = 0.01})
tmr:add_signal("timeout", f)
tmr:connect_signal("timeout", f)
tmr:start()
end

Expand All @@ -437,8 +443,8 @@ end
--del : delete a tag
--@param tag : the tag to be deleted [current tag]
function del(tag)
local scr = (tag and tag.screen) or capi.mouse.screen or 1
local tags = capi.screen[scr]:tags()
local scr = (tag and awful.tag.getscreen(tag)) or capi.mouse.screen or 1
local tags = awful.tag.gettags(awful.tag.getscreen(t))
local sel = awful.tag.selected(scr)
local t = tag or sel
local idx = tag2index(scr, t)
Expand All @@ -449,13 +455,13 @@ function del(tag)
for i, c in ipairs(clients) do
if c.sticky then sticky = sticky + 1 end
end
if #clients > sticky then return false end
if #clients > sticky then return end

-- store index for later
index_cache[scr][getname(t)] = idx

-- remove tag
t.screen = nil
awful.tag.delete(t)

-- if the current tag is being deleted, restore from history
if t == sel and #tags > 1 then
Expand All @@ -469,7 +475,6 @@ function del(tag)

-- FIXME: what is this for??
if capi.client.focus then capi.client.focus:raise() end
return true
end

--is_client_tagged : replicate behavior in tag.c - returns true if the
Expand Down Expand Up @@ -607,7 +612,7 @@ function match(c, startup)
table.insert(target_tags, t)
if config.guess_name and cls then
if getname(t) == config.default_name or
getname(t) == "" .. (awful.tag.getproperty(t, "position") or "?") then
getname(t) == "" .. (awful.tag.getproperty(t, "position") or "") then
setname(t, cls:lower())
end
end
Expand Down Expand Up @@ -656,7 +661,7 @@ function match(c, startup)
end

-- set client's screen/tag if needed
target_screen = target_tags[1].screen or target_screen
target_screen = awful.tag.getscreen(target_tags[1]) or target_screen
if c.screen ~= target_screen then c.screen = target_screen end
if slave then awful.client.setslave(c) end
c:tags(target_tags)
Expand Down Expand Up @@ -704,14 +709,13 @@ function match(c, startup)

-- execute run function if specified
if run then run(c, target) end

end

--sweep : hook function that marks tags as used, visited,
--deserted also handles deleting used and empty tags
function sweep()
for s = 1, capi.screen.count() do
for i, t in ipairs(capi.screen[s]:tags()) do
for i, t in ipairs(awful.tag.gettags(s)) do
local clients = t:clients()
local sticky = 0
for i, c in ipairs(clients) do
Expand All @@ -730,7 +734,7 @@ function sweep()
tmr:stop()
end
tmr = capi.timer({timeout = delay})
tmr:add_signal("timeout", f)
tmr:connect_signal("timeout", f)
tmr:start()
else
del(t)
Expand Down Expand Up @@ -764,7 +768,7 @@ function getpos(pos, args)

-- search for existing tag assigned to pos
for i = 1, capi.screen.count() do
for j, t in ipairs(capi.screen[i]:tags()) do
for j, t in ipairs(awful.tag.gettags(i)) do
if awful.tag.getproperty(t, "position") == pos then
table.insert(existing, t)
if t.selected and i == scr then
Expand Down Expand Up @@ -884,7 +888,7 @@ function completion(cmd, cur_pos, ncomp, sources, matchers)
for i = 1, capi.screen.count() do
local s = awful.util.cycle(capi.screen.count(),
capi.mouse.screen + i - 1)
local tags = capi.screen[s]:tags()
local tags = awful.tag.gettags(s)
for j, t in pairs(tags) do
table.insert(ret, getname(t))
end
Expand Down Expand Up @@ -945,12 +949,11 @@ function completion(cmd, cur_pos, ncomp, sources, matchers)
end

-- signals
capi.client.add_signal("manage", match)
capi.client.add_signal("unmanage", sweep)
capi.client.remove_signal("manage", awful.tag.withcurrent)
capi.client.connect_signal("manage", match)
capi.client.connect_signal("unmanage", sweep)
capi.client.disconnect_signal("manage", awful.tag.withcurrent)

for s = 1, capi.screen.count() do
awful.tag.attached_add_signal(s, "property::selected", sweep)
awful.tag.attached_add_signal(s, "tagged", sweep)
awful.tag.attached_connect_signal(s, "property::selected", sweep)
awful.tag.attached_connect_signal(s, "tagged", sweep)
end

20 changes: 15 additions & 5 deletions rc.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
require("awful")
require("awful.autofocus")
require("awful.rules")
require("beautiful")
require("naughty")
awful = require("awful")
awful.autofocus = require("awful.autofocus")
awful.rules = require("awful.rules")
beautiful = require("beautiful")
naughty = require("naughty")

-- Override awesome.quit when we're using GNOME
_awesome_quit = awesome.quit
awesome.quit = function()
if os.getenv("DESKTOP_SESSION") == "gnome-awesome" then
os.execute("/usr/bin/gnome-session-quit --logout --no-prompt --force")
else
_awesome_quit()
end
end

-- Simple function to load additional LUA files from rc/.
function loadrc(name, mod)
Expand Down
Loading