2008-11-20 20:45:09 +01:00
|
|
|
-- Standard awesome library
|
2008-05-20 15:39:47 +02:00
|
|
|
require("awful")
|
2009-08-19 11:21:56 +02:00
|
|
|
require("awful.autofocus")
|
2009-08-24 16:27:35 +02:00
|
|
|
require("awful.rules")
|
2008-11-20 20:45:09 +01:00
|
|
|
-- Theme handling library
|
2008-08-05 22:21:22 +02:00
|
|
|
require("beautiful")
|
2008-11-20 20:45:09 +01:00
|
|
|
-- Notification library
|
|
|
|
require("naughty")
|
2008-08-05 22:21:22 +02:00
|
|
|
|
2008-06-11 23:13:15 +02:00
|
|
|
-- {{{ Variable definitions
|
2009-09-28 13:42:34 +02:00
|
|
|
-- Themes define colours, icons, and wallpapers
|
|
|
|
beautiful.init("@AWESOME_THEMES_PATH@/default/theme.lua")
|
|
|
|
|
2008-10-22 22:51:01 +02:00
|
|
|
-- This is used later as the default terminal and editor to run.
|
2008-05-20 15:39:47 +02:00
|
|
|
terminal = "xterm"
|
2008-10-23 10:26:13 +02:00
|
|
|
editor = os.getenv("EDITOR") or "nano"
|
|
|
|
editor_cmd = terminal .. " -e " .. editor
|
2008-06-11 23:13:15 +02:00
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
-- Default modkey.
|
|
|
|
-- Usually, Mod4 is the key with a logo between Control and Alt.
|
|
|
|
-- If you do not like this or do not have such a key,
|
|
|
|
-- I suggest you to remap Mod4 to another key using xmodmap or other tools.
|
|
|
|
-- However, you can use another modifier like Mod1, but it may interact with others.
|
|
|
|
modkey = "Mod4"
|
2008-06-11 23:13:15 +02:00
|
|
|
|
2008-05-24 13:55:49 +02:00
|
|
|
-- Table of layouts to cover with awful.layout.inc, order matters.
|
2008-06-11 23:13:15 +02:00
|
|
|
layouts =
|
|
|
|
{
|
2009-01-28 12:08:33 +01:00
|
|
|
awful.layout.suit.tile,
|
|
|
|
awful.layout.suit.tile.left,
|
|
|
|
awful.layout.suit.tile.bottom,
|
|
|
|
awful.layout.suit.tile.top,
|
2008-11-25 17:01:06 +01:00
|
|
|
awful.layout.suit.fair,
|
|
|
|
awful.layout.suit.fair.horizontal,
|
2009-07-12 20:27:41 +02:00
|
|
|
awful.layout.suit.spiral,
|
|
|
|
awful.layout.suit.spiral.dwindle,
|
2008-11-25 17:01:06 +01:00
|
|
|
awful.layout.suit.max,
|
|
|
|
awful.layout.suit.max.fullscreen,
|
|
|
|
awful.layout.suit.magnifier,
|
|
|
|
awful.layout.suit.floating
|
2008-06-11 23:13:15 +02:00
|
|
|
}
|
2008-05-20 15:39:47 +02:00
|
|
|
-- }}}
|
|
|
|
|
2008-06-09 21:43:09 +02:00
|
|
|
-- {{{ Tags
|
2009-08-21 15:50:10 +02:00
|
|
|
-- Define a tag table which hold all screen tags.
|
2008-06-09 21:43:09 +02:00
|
|
|
tags = {}
|
|
|
|
for s = 1, screen.count() do
|
2008-08-06 15:15:13 +02:00
|
|
|
-- Each screen has its own tag table.
|
2009-08-21 15:50:10 +02:00
|
|
|
tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s)
|
2008-05-20 15:39:47 +02:00
|
|
|
end
|
|
|
|
-- }}}
|
|
|
|
|
2009-08-31 11:52:49 +02:00
|
|
|
-- {{{ Menu
|
2009-09-08 10:23:18 +02:00
|
|
|
-- Create a laucher widget and a main menu
|
|
|
|
myawesomemenu = {
|
|
|
|
{ "manual", terminal .. " -e man awesome" },
|
|
|
|
{ "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
|
|
|
|
{ "restart", awesome.restart },
|
|
|
|
{ "quit", awesome.quit }
|
|
|
|
}
|
|
|
|
|
2009-08-31 11:52:49 +02:00
|
|
|
mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
|
|
|
|
{ "open terminal", terminal }
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
|
|
|
|
menu = mymainmenu })
|
|
|
|
-- }}}
|
|
|
|
|
2008-09-24 12:13:21 +02:00
|
|
|
-- {{{ Wibox
|
2009-06-30 12:20:45 +02:00
|
|
|
-- Create a textclock widget
|
|
|
|
mytextclock = awful.widget.textclock({ align = "right" })
|
2008-05-20 15:39:47 +02:00
|
|
|
|
2008-06-14 18:12:16 +02:00
|
|
|
-- Create a systray
|
2009-03-10 19:31:28 +01:00
|
|
|
mysystray = widget({ type = "systray" })
|
2008-06-14 18:12:16 +02:00
|
|
|
|
2008-09-24 12:13:21 +02:00
|
|
|
-- Create a wibox for each screen and add it
|
|
|
|
mywibox = {}
|
2008-10-13 11:28:36 +02:00
|
|
|
mypromptbox = {}
|
2008-10-19 19:14:55 +02:00
|
|
|
mylayoutbox = {}
|
|
|
|
mytaglist = {}
|
2009-04-17 11:13:22 +02:00
|
|
|
mytaglist.buttons = awful.util.table.join(
|
|
|
|
awful.button({ }, 1, awful.tag.viewonly),
|
|
|
|
awful.button({ modkey }, 1, awful.client.movetotag),
|
2009-08-27 17:20:14 +02:00
|
|
|
awful.button({ }, 3, awful.tag.viewtoggle),
|
2009-04-17 11:13:22 +02:00
|
|
|
awful.button({ modkey }, 3, awful.client.toggletag),
|
|
|
|
awful.button({ }, 4, awful.tag.viewnext),
|
|
|
|
awful.button({ }, 5, awful.tag.viewprev)
|
|
|
|
)
|
2008-10-19 19:14:55 +02:00
|
|
|
mytasklist = {}
|
2009-04-17 11:13:22 +02:00
|
|
|
mytasklist.buttons = awful.util.table.join(
|
|
|
|
awful.button({ }, 1, function (c)
|
|
|
|
if not c:isvisible() then
|
|
|
|
awful.tag.viewonly(c:tags()[1])
|
|
|
|
end
|
|
|
|
client.focus = c
|
|
|
|
c:raise()
|
|
|
|
end),
|
|
|
|
awful.button({ }, 3, function ()
|
|
|
|
if instance then
|
|
|
|
instance:hide()
|
|
|
|
instance = nil
|
|
|
|
else
|
|
|
|
instance = awful.menu.clients({ width=250 })
|
|
|
|
end
|
|
|
|
end),
|
|
|
|
awful.button({ }, 4, function ()
|
|
|
|
awful.client.focus.byidx(1)
|
|
|
|
if client.focus then client.focus:raise() end
|
|
|
|
end),
|
|
|
|
awful.button({ }, 5, function ()
|
|
|
|
awful.client.focus.byidx(-1)
|
|
|
|
if client.focus then client.focus:raise() end
|
|
|
|
end))
|
2008-10-19 19:14:55 +02:00
|
|
|
|
2008-05-27 16:07:17 +02:00
|
|
|
for s = 1, screen.count() do
|
2008-10-19 19:14:55 +02:00
|
|
|
-- Create a promptbox for each screen
|
2009-08-27 15:47:11 +02:00
|
|
|
mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
|
2008-10-19 19:14:55 +02:00
|
|
|
-- Create an imagebox widget which will contains an icon indicating which layout we're using.
|
|
|
|
-- We need one layoutbox per screen.
|
2009-03-10 19:31:28 +01:00
|
|
|
mylayoutbox[s] = awful.widget.layoutbox(s)
|
2009-08-14 16:46:35 +02:00
|
|
|
mylayoutbox[s]:buttons(awful.util.table.join(
|
2009-04-17 11:13:22 +02:00
|
|
|
awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
|
|
|
|
awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
|
|
|
|
awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
|
2009-08-14 16:46:35 +02:00
|
|
|
awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
|
2008-10-19 19:14:55 +02:00
|
|
|
-- Create a taglist widget
|
2009-05-08 11:59:38 +02:00
|
|
|
mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
|
2008-10-19 19:14:55 +02:00
|
|
|
|
|
|
|
-- Create a tasklist widget
|
2009-05-08 11:59:38 +02:00
|
|
|
mytasklist[s] = awful.widget.tasklist(function(c)
|
|
|
|
return awful.widget.tasklist.label.currenttags(c, s)
|
|
|
|
end, mytasklist.buttons)
|
2008-10-19 19:14:55 +02:00
|
|
|
|
|
|
|
-- Create the wibox
|
2009-05-05 17:32:53 +02:00
|
|
|
mywibox[s] = awful.wibox({ position = "top", screen = s })
|
2008-09-24 12:13:21 +02:00
|
|
|
-- Add widgets to the wibox - order matters
|
2009-03-10 19:31:28 +01:00
|
|
|
mywibox[s].widgets = {
|
|
|
|
{
|
|
|
|
mylauncher,
|
|
|
|
mytaglist[s],
|
|
|
|
mypromptbox[s],
|
|
|
|
layout = awful.widget.layout.horizontal.leftright
|
|
|
|
},
|
|
|
|
mylayoutbox[s],
|
2009-06-30 12:20:45 +02:00
|
|
|
mytextclock,
|
2009-03-10 19:31:28 +01:00
|
|
|
s == 1 and mysystray or nil,
|
|
|
|
mytasklist[s],
|
|
|
|
layout = awful.widget.layout.horizontal.rightleft
|
|
|
|
}
|
2008-05-20 15:39:47 +02:00
|
|
|
end
|
|
|
|
-- }}}
|
|
|
|
|
|
|
|
-- {{{ Mouse bindings
|
2009-08-14 16:46:35 +02:00
|
|
|
root.buttons(awful.util.table.join(
|
2009-04-14 17:53:22 +02:00
|
|
|
awful.button({ }, 3, function () mymainmenu:toggle() end),
|
|
|
|
awful.button({ }, 4, awful.tag.viewnext),
|
2009-08-14 16:46:35 +02:00
|
|
|
awful.button({ }, 5, awful.tag.viewprev)
|
|
|
|
))
|
2008-05-20 15:39:47 +02:00
|
|
|
-- }}}
|
|
|
|
|
|
|
|
-- {{{ Key bindings
|
2009-04-17 11:13:22 +02:00
|
|
|
globalkeys = awful.util.table.join(
|
2009-04-14 17:53:22 +02:00
|
|
|
awful.key({ modkey, }, "Left", awful.tag.viewprev ),
|
|
|
|
awful.key({ modkey, }, "Right", awful.tag.viewnext ),
|
|
|
|
awful.key({ modkey, }, "Escape", awful.tag.history.restore),
|
2009-02-20 15:02:22 +01:00
|
|
|
|
2009-04-14 17:53:22 +02:00
|
|
|
awful.key({ modkey, }, "j",
|
2009-02-24 17:42:21 +01:00
|
|
|
function ()
|
|
|
|
awful.client.focus.byidx( 1)
|
|
|
|
if client.focus then client.focus:raise() end
|
|
|
|
end),
|
2009-04-14 17:53:22 +02:00
|
|
|
awful.key({ modkey, }, "k",
|
2009-02-24 17:42:21 +01:00
|
|
|
function ()
|
|
|
|
awful.client.focus.byidx(-1)
|
|
|
|
if client.focus then client.focus:raise() end
|
|
|
|
end),
|
2009-04-14 17:53:22 +02:00
|
|
|
awful.key({ modkey, }, "w", function () mymainmenu:show(true) end),
|
2009-02-20 15:02:22 +01:00
|
|
|
|
|
|
|
-- Layout manipulation
|
2009-08-21 16:05:02 +02:00
|
|
|
awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
|
|
|
|
awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
|
|
|
|
awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
|
|
|
|
awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
|
2009-04-14 17:53:22 +02:00
|
|
|
awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
|
|
|
|
awful.key({ modkey, }, "Tab",
|
2009-02-24 17:42:21 +01:00
|
|
|
function ()
|
|
|
|
awful.client.focus.history.previous()
|
|
|
|
if client.focus then
|
|
|
|
client.focus:raise()
|
|
|
|
end
|
|
|
|
end),
|
2009-02-20 15:02:22 +01:00
|
|
|
|
|
|
|
-- Standard program
|
2009-04-14 17:53:22 +02:00
|
|
|
awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
|
|
|
|
awful.key({ modkey, "Control" }, "r", awesome.restart),
|
|
|
|
awful.key({ modkey, "Shift" }, "q", awesome.quit),
|
|
|
|
|
|
|
|
awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
|
|
|
|
awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
|
|
|
|
awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
|
|
|
|
awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
|
|
|
|
awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
|
|
|
|
awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
|
|
|
|
awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
|
|
|
|
awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
|
2009-02-20 15:02:22 +01:00
|
|
|
|
|
|
|
-- Prompt
|
2009-04-27 22:08:33 +02:00
|
|
|
awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
|
2009-04-14 17:53:22 +02:00
|
|
|
|
2009-04-17 18:19:37 +02:00
|
|
|
awful.key({ modkey }, "x",
|
2009-04-14 17:53:22 +02:00
|
|
|
function ()
|
|
|
|
awful.prompt.run({ prompt = "Run Lua code: " },
|
2009-04-27 22:08:33 +02:00
|
|
|
mypromptbox[mouse.screen].widget,
|
2009-04-14 17:53:22 +02:00
|
|
|
awful.util.eval, nil,
|
|
|
|
awful.util.getdir("cache") .. "/history_eval")
|
2009-04-17 11:13:22 +02:00
|
|
|
end)
|
|
|
|
)
|
2009-02-20 15:02:22 +01:00
|
|
|
|
2009-04-17 11:13:22 +02:00
|
|
|
clientkeys = awful.util.table.join(
|
2009-04-14 17:53:22 +02:00
|
|
|
awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
|
|
|
|
awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
|
|
|
|
awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
|
|
|
|
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
|
|
|
|
awful.key({ modkey, }, "o", awful.client.movetoscreen ),
|
|
|
|
awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
|
2009-08-25 14:56:17 +02:00
|
|
|
awful.key({ modkey, }, "n", function (c) c.minimized = not c.minimized end),
|
|
|
|
awful.key({ modkey, }, "m",
|
2009-02-20 15:02:22 +01:00
|
|
|
function (c)
|
|
|
|
c.maximized_horizontal = not c.maximized_horizontal
|
|
|
|
c.maximized_vertical = not c.maximized_vertical
|
2009-04-17 11:13:22 +02:00
|
|
|
end)
|
|
|
|
)
|
2009-02-20 15:02:22 +01:00
|
|
|
|
2008-05-20 15:39:47 +02:00
|
|
|
-- Compute the maximum number of digit we need, limited to 9
|
2008-06-09 21:43:09 +02:00
|
|
|
keynumber = 0
|
|
|
|
for s = 1, screen.count() do
|
|
|
|
keynumber = math.min(9, math.max(#tags[s], keynumber));
|
|
|
|
end
|
|
|
|
|
2009-09-18 11:41:55 +02:00
|
|
|
-- Bind all key numbers to tags.
|
|
|
|
-- Be careful: we use keycodes to make it works on any keyboard layout.
|
|
|
|
-- This should map on the top row of your keyboard, usually 1 to 9.
|
2008-05-20 15:39:47 +02:00
|
|
|
for i = 1, keynumber do
|
2009-05-09 20:31:26 +02:00
|
|
|
globalkeys = awful.util.table.join(globalkeys,
|
2009-09-18 11:41:55 +02:00
|
|
|
awful.key({ modkey }, "#" .. i + 9,
|
2009-04-17 11:13:22 +02:00
|
|
|
function ()
|
2009-04-14 17:53:22 +02:00
|
|
|
local screen = mouse.screen
|
|
|
|
if tags[screen][i] then
|
2009-04-17 11:13:22 +02:00
|
|
|
awful.tag.viewonly(tags[screen][i])
|
2009-04-14 17:53:22 +02:00
|
|
|
end
|
2009-05-09 20:31:26 +02:00
|
|
|
end),
|
2009-09-18 11:41:55 +02:00
|
|
|
awful.key({ modkey, "Control" }, "#" .. i + 9,
|
2009-04-17 11:13:22 +02:00
|
|
|
function ()
|
|
|
|
local screen = mouse.screen
|
|
|
|
if tags[screen][i] then
|
2009-08-27 17:20:14 +02:00
|
|
|
awful.tag.viewtoggle(tags[screen][i])
|
2009-04-17 11:13:22 +02:00
|
|
|
end
|
2009-05-09 20:31:26 +02:00
|
|
|
end),
|
2009-09-18 11:41:55 +02:00
|
|
|
awful.key({ modkey, "Shift" }, "#" .. i + 9,
|
2009-04-17 11:13:22 +02:00
|
|
|
function ()
|
|
|
|
if client.focus and tags[client.focus.screen][i] then
|
|
|
|
awful.client.movetotag(tags[client.focus.screen][i])
|
|
|
|
end
|
2009-05-09 20:31:26 +02:00
|
|
|
end),
|
2009-09-18 11:41:55 +02:00
|
|
|
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
|
2009-04-17 11:13:22 +02:00
|
|
|
function ()
|
|
|
|
if client.focus and tags[client.focus.screen][i] then
|
|
|
|
awful.client.toggletag(tags[client.focus.screen][i])
|
|
|
|
end
|
2009-08-17 17:37:38 +02:00
|
|
|
end))
|
2008-05-20 15:39:47 +02:00
|
|
|
end
|
|
|
|
|
2009-08-24 16:27:35 +02:00
|
|
|
clientbuttons = awful.util.table.join(
|
|
|
|
awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
|
|
|
|
awful.button({ modkey }, 1, awful.mouse.client.move),
|
|
|
|
awful.button({ modkey }, 3, awful.mouse.client.resize))
|
|
|
|
|
2009-01-05 16:59:20 +01:00
|
|
|
-- Set keys
|
2009-08-14 16:46:35 +02:00
|
|
|
root.keys(globalkeys)
|
2008-05-20 15:39:47 +02:00
|
|
|
-- }}}
|
|
|
|
|
2009-08-24 16:27:35 +02:00
|
|
|
-- {{{ Rules
|
|
|
|
awful.rules.rules = {
|
|
|
|
-- All clients will match this rule.
|
|
|
|
{ rule = { },
|
|
|
|
properties = { border_width = beautiful.border_width,
|
|
|
|
border_color = beautiful.border_normal,
|
|
|
|
focus = true,
|
|
|
|
keys = clientkeys,
|
|
|
|
buttons = clientbuttons } },
|
|
|
|
{ rule = { class = "MPlayer" },
|
|
|
|
properties = { floating = true } },
|
|
|
|
{ rule = { class = "pinentry" },
|
|
|
|
properties = { floating = true } },
|
|
|
|
{ rule = { class = "gimp" },
|
|
|
|
properties = { floating = true } },
|
|
|
|
-- Set Firefox to always map on tags number 2 of screen 1.
|
2009-08-25 11:09:12 +02:00
|
|
|
-- { rule = { class = "Firefox" },
|
2009-08-24 16:27:35 +02:00
|
|
|
-- properties = { tag = tags[1][2] } },
|
|
|
|
}
|
|
|
|
-- }}}
|
|
|
|
|
2009-08-19 15:49:15 +02:00
|
|
|
-- {{{ Signals
|
|
|
|
-- Signal function to execute when a new client appears.
|
2009-07-10 14:36:04 +02:00
|
|
|
client.add_signal("manage", function (c, startup)
|
2009-08-19 15:49:15 +02:00
|
|
|
-- Enable sloppy focus
|
|
|
|
c:add_signal("mouse::enter", function(c)
|
|
|
|
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
|
|
|
|
and awful.client.focus.filter(c) then
|
|
|
|
client.focus = c
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2009-09-18 11:35:59 +02:00
|
|
|
if not startup then
|
|
|
|
-- Set the windows at the slave,
|
|
|
|
-- i.e. put it at the end of others instead of setting it master.
|
|
|
|
-- awful.client.setslave(c)
|
|
|
|
|
2009-09-23 10:07:02 +02:00
|
|
|
-- Put windows in a smart way, only if they does not set an initial position.
|
|
|
|
if not c.size_hints.user_position and not c.size_hints.program_position then
|
|
|
|
awful.placement.no_overlap(c)
|
|
|
|
awful.placement.no_offscreen(c)
|
|
|
|
end
|
2009-09-18 11:35:59 +02:00
|
|
|
end
|
2008-08-25 15:35:17 +02:00
|
|
|
end)
|
2009-08-21 16:08:38 +02:00
|
|
|
|
|
|
|
client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
|
|
|
|
client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
|
2008-05-20 15:39:47 +02:00
|
|
|
-- }}}
|