1 -- Standard awesome library
2 gears = require("gears")
3 awful = require("awful")
4 awful.rules = require("awful.rules")
5 require("awful.autofocus")
6 -- Widget and layout library
7 wibox = require("wibox")
8 -- Theme handling library
9 beautiful = require("beautiful")
10 -- Notification library
11 naughty = require("naughty")
12 menubar = require("menubar")
14 --local APW = require("apw/widget")
17 -- Check if awesome encountered an error during startup and fell back to
18 -- another config (This code will only ever execute for the fallback config)
19 if awesome.startup_errors then
20 naughty.notify({ preset = naughty.config.presets.critical,
21 title = "Oops, there were errors during startup!",
22 text = awesome.startup_errors })
25 -- Handle runtime errors after startup
27 local in_error = false
28 awesome.connect_signal("debug::error", function (err)
29 -- Make sure we don't go into an endless error loop
30 if in_error then return end
33 naughty.notify({ preset = naughty.config.presets.critical,
34 title = "Oops, an error happened!",
41 -- {{{ Variable definitions
42 -- Themes define colours, icons, and wallpapers
43 beautiful.init("/usr/share/awesome/themes/default/theme.lua")
45 -- This is used later as the default terminal and editor to run.
47 editor = os.getenv("EDITOR") or "vim"
48 editor_cmd = terminal .. " -e " .. editor
51 -- Usually, Mod4 is the key with a logo between Control and Alt.
52 -- If you do not like this or do not have such a key,
53 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
54 -- However, you can use another modifier like Mod1, but it may interact with others.
62 if beautiful.wallpaper then
63 for s = 1, screen.count() do
64 gears.wallpaper.maximized(beautiful.wallpaper, s, true)
70 -- Setup global menu keys
71 awful.menu.menu_keys.up = { "k", "Up"}
72 awful.menu.menu_keys.down = { "j", "Down"}
73 awful.menu.menu_keys.enter = { "l", "Right"}
74 awful.menu.menu_keys.back = { "h", "Left"}
76 -- Create a laucher widget and a main menu
78 { "manual", terminal .. " -e man awesome" },
79 { "edit config", editor_cmd .. " " .. awesome.conffile },
80 { "restart", awesome.restart },
81 { "quit", awesome.quit }
84 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
85 { "open terminal", terminal }
89 mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
92 -- Menubar configuration
93 menubar.utils.terminal = terminal -- Set the terminal for applications that require it
97 -- Create a textclock widget
98 mytextclock = awful.widget.textclock()
100 -- Create a wibox for each screen and add it
105 mytaglist.buttons = awful.util.table.join(
106 awful.button({ }, 1, awful.tag.viewonly),
107 awful.button({ modkey }, 1, awful.client.movetotag),
108 awful.button({ }, 3, awful.tag.viewtoggle),
109 awful.button({ modkey }, 3, awful.client.toggletag),
110 awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
111 awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
114 mytasklist.buttons = awful.util.table.join(
115 awful.button({ }, 1, function (c)
116 if c == client.focus then
119 -- Without this, the following
120 -- :isvisible() makes no sense
122 if not c:isvisible() then
123 awful.tag.viewonly(c:tags()[1])
125 -- This will also un-minimize
126 -- the client, if needed
131 awful.button({ }, 2, function (c) c:kill() end),
132 awful.button({ }, 3, function ()
137 instance = awful.menu.clients({ width=250 })
140 awful.button({ }, 4, function ()
141 awful.client.focus.byidx(1)
142 if client.focus then client.focus:raise() end
144 awful.button({ }, 5, function ()
145 awful.client.focus.byidx(-1)
146 if client.focus then client.focus:raise() end
149 for s = 1, screen.count() do
150 -- Create a promptbox for each screen
151 mypromptbox[s] = awful.widget.prompt()
152 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
153 -- We need one layoutbox per screen.
154 mylayoutbox[s] = awful.widget.layoutbox(s)
155 mylayoutbox[s]:buttons(awful.util.table.join(
156 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
157 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
158 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
159 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
160 -- Create a taglist widget
161 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
163 -- Create a tasklist widget
164 mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
167 mywibox[s] = awful.wibox({ position = "top", screen = s })
169 -- Widgets that are aligned to the left
170 local left_layout = wibox.layout.fixed.horizontal()
171 left_layout:add(mylauncher)
172 left_layout:add(mytaglist[s])
173 left_layout:add(mypromptbox[s])
175 -- Widgets that are aligned to the right
176 local right_layout = wibox.layout.fixed.horizontal()
177 if s == 1 then right_layout:add(wibox.widget.systray()) end
178 --right_layout:add(APW)
179 right_layout:add(mytextclock)
180 right_layout:add(mylayoutbox[s])
182 -- Now bring it all together (with the tasklist in the middle)
183 local layout = wibox.layout.align.horizontal()
184 layout:set_left(left_layout)
185 layout:set_middle(mytasklist[s])
186 layout:set_right(right_layout)
188 mywibox[s]:set_widget(layout)
192 -- Mouse/Key Bindings
199 -- Signal function to execute when a new client appears.
200 client.connect_signal("manage", function (c, startup)
201 -- Enable sloppy focus
202 c:connect_signal("mouse::enter", function(c)
203 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
204 and awful.client.focus.filter(c) then
210 -- Set the windows at the slave,
211 -- i.e. put it at the end of others instead of setting it master.
212 -- awful.client.setslave(c)
214 -- Put windows in a smart way, only if they does not set an initial position.
215 if not c.size_hints.user_position and not c.size_hints.program_position then
216 awful.placement.no_overlap(c)
217 awful.placement.no_offscreen(c)
222 client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
223 client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
226 -- {{{ Autostart applications