.config/awesome/rc.lua
This commit is contained in:
parent
b08f6026ed
commit
0228c95a0b
1 changed files with 88 additions and 11 deletions
|
@ -9,6 +9,8 @@ require("naughty")
|
||||||
require("bowl")
|
require("bowl")
|
||||||
require("keychain")
|
require("keychain")
|
||||||
|
|
||||||
|
oni = { } -- Container for custom functions.
|
||||||
|
|
||||||
-- {{{ Error handling
|
-- {{{ Error handling
|
||||||
-- Check if awesome encountered an error during startup and fell back to
|
-- Check if awesome encountered an error during startup and fell back to
|
||||||
-- another config (This code will only ever execute for the fallback config)
|
-- another config (This code will only ever execute for the fallback config)
|
||||||
|
@ -34,6 +36,71 @@ do
|
||||||
end
|
end
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
function oni.focus_raise(direction)
|
||||||
|
awful.client.focus.bydirection(direction)
|
||||||
|
if client.focus then client.focus:raise() end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Returns true if all pairs in table1 are present in table2
|
||||||
|
function match(table1, table2)
|
||||||
|
for k, v in pairs(table1) do
|
||||||
|
if table[k] ~= v and not table2[k]:find(v) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Spawns cmd if no client can be found matching properties
|
||||||
|
-- If such a client can be found, pop to first tag where it is
|
||||||
|
-- visible, and give it focus
|
||||||
|
function oni.run_or_raise(cmd, properties)
|
||||||
|
local clients = client.get()
|
||||||
|
local focused = awful.client.next(0)
|
||||||
|
local findex = 0
|
||||||
|
local matched_clients = { }
|
||||||
|
local n = 0
|
||||||
|
|
||||||
|
for i, c in pairs(clients) do
|
||||||
|
-- make an array of matched clients
|
||||||
|
if match(properties, c) then
|
||||||
|
n = n + 1
|
||||||
|
matched_clients[n] = c
|
||||||
|
|
||||||
|
if n == focused then
|
||||||
|
findex = n
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if n > 0 then
|
||||||
|
local c = matched_clients[1]
|
||||||
|
|
||||||
|
-- if the focused window matched switch focus to next in list
|
||||||
|
if 0 < findex and findex < n then
|
||||||
|
c = matched_clients[findex + 1]
|
||||||
|
end
|
||||||
|
|
||||||
|
local ctags = c:tags()
|
||||||
|
|
||||||
|
if table.getn(ctags) == 0 then
|
||||||
|
-- ctags is empty, show client on current tag
|
||||||
|
local curtag = awful.tag.selected()
|
||||||
|
awful.client.movetotag(curtag, c)
|
||||||
|
else
|
||||||
|
-- Otherwise, pop to first tag client is visible on
|
||||||
|
awful.tag.viewonly(ctags[1])
|
||||||
|
end
|
||||||
|
|
||||||
|
-- And then focus the client
|
||||||
|
client.focus = c
|
||||||
|
c:raise()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
awful.util.spawn(cmd)
|
||||||
|
end
|
||||||
|
|
||||||
-- {{{ Variable definitions
|
-- {{{ Variable definitions
|
||||||
-- Themes define colours, icons, and wallpapers
|
-- Themes define colours, icons, and wallpapers
|
||||||
beautiful.init("/usr/share/awesome/themes/default/theme.lua")
|
beautiful.init("/usr/share/awesome/themes/default/theme.lua")
|
||||||
|
@ -196,11 +263,6 @@ root.buttons(awful.util.table.join(
|
||||||
))
|
))
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
function focus_raise(direction)
|
|
||||||
awful.client.focus.bydirection(direction)
|
|
||||||
if client.focus then client.focus:raise() end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- {{{ Key bindings
|
-- {{{ Key bindings
|
||||||
local bind = keychain
|
local bind = keychain
|
||||||
local sub = keychain.sub
|
local sub = keychain.sub
|
||||||
|
@ -215,10 +277,19 @@ globalkeys = awful.util.table.join(
|
||||||
function () awful.screen.focus_relative(1) end),
|
function () awful.screen.focus_relative(1) end),
|
||||||
sub({ "Shift", }, "1",
|
sub({ "Shift", }, "1",
|
||||||
function () mypromptbox[mouse.screen]:run() end),
|
function () mypromptbox[mouse.screen]:run() end),
|
||||||
sub({ }, "f", function () focus_raise("right") end),
|
sub({ }, "f", function () oni.focus_raise("right") end),
|
||||||
sub({ }, "b", function () focus_raise("left") end),
|
sub({ }, "b", function () oni.focus_raise("left") end),
|
||||||
sub({ }, "n", function () focus_raise("down") end),
|
sub({ }, "n", function () oni.focus_raise("down") end),
|
||||||
sub({ }, "p", function () focus_raise("up") end) }),
|
sub({ }, "p", function () oni.focus_raise("up") end),
|
||||||
|
sub({ }, "e",
|
||||||
|
function () oni.run_or_raise("emacsclient -c -a emacs",
|
||||||
|
{ class = "Emacs" }) end),
|
||||||
|
sub({ }, "c",
|
||||||
|
function () oni.run_or_raise("urxvt",
|
||||||
|
{ class = "URxvt" }) end),
|
||||||
|
sub({ }, "w",
|
||||||
|
function () oni.run_or_raise("conkeror",
|
||||||
|
{ class = "Conkeror" }) end) }),
|
||||||
awful.key({ modkey, }, "Left", awful.tag.viewprev ),
|
awful.key({ modkey, }, "Left", awful.tag.viewprev ),
|
||||||
awful.key({ modkey, }, "Right", awful.tag.viewnext ),
|
awful.key({ modkey, }, "Right", awful.tag.viewnext ),
|
||||||
awful.key({ modkey, }, "Escape", awful.tag.history.restore),
|
awful.key({ modkey, }, "Escape", awful.tag.history.restore),
|
||||||
|
@ -349,9 +420,15 @@ awful.rules.rules = {
|
||||||
properties = { floating = true } },
|
properties = { floating = true } },
|
||||||
{ rule = { class = "gimp" },
|
{ rule = { class = "gimp" },
|
||||||
properties = { floating = true } },
|
properties = { floating = true } },
|
||||||
|
{ rule = { class = "Emacs" },
|
||||||
|
properties = { tag = tags[1][1] } },
|
||||||
-- Set Firefox to always map on tags number 2 of screen 1.
|
-- Set Firefox to always map on tags number 2 of screen 1.
|
||||||
-- { rule = { class = "Firefox" },
|
{ rule = { class = "Firefox" },
|
||||||
-- properties = { tag = tags[1][2] } },
|
properties = { tag = tags[2][1] } },
|
||||||
|
{ rule = { class = "Conkeror" },
|
||||||
|
properties = { tag = tags[2][1] } },
|
||||||
|
{ rule = { class = "URxvt" },
|
||||||
|
properties = { tag = tags[2][1] } },
|
||||||
}
|
}
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue