1 -- Standard awesome library
3 -- Theme handling library
5 -- Notification library
8 -- {{{ Variable definitions
9 -- Themes define colours, icons, and wallpapers
10 -- The default is a dark theme
11 theme_path
= "@AWESOME_THEMES_PATH@/default/theme"
12 -- Uncommment this for a lighter theme
13 -- theme_path = "@AWESOME_THEMES_PATH@/sky/theme"
15 -- Actually load theme
16 beautiful
.init(theme_path
)
18 -- This is used later as the default terminal and editor to run.
20 editor
= os
.getenv("EDITOR") or "nano"
21 editor_cmd
= terminal
.. " -e " .. editor
24 -- Usually, Mod4 is the key with a logo between Control and Alt.
25 -- If you do not like this or do not have such a key,
26 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
27 -- However, you can use another modifier like Mod1, but it may interact with others.
30 -- Table of layouts to cover with awful.layout.inc, order matters.
33 awful
.layout
.suit
.tile
,
34 awful
.layout
.suit
.tile
.left
,
35 awful
.layout
.suit
.tile
.bottom
,
36 awful
.layout
.suit
.tile
.top
,
37 awful
.layout
.suit
.fair
,
38 awful
.layout
.suit
.fair
.horizontal
,
39 awful
.layout
.suit
.max,
40 awful
.layout
.suit
.max.fullscreen
,
41 awful
.layout
.suit
.magnifier
,
42 awful
.layout
.suit
.floating
45 -- Table of clients that should be set floating. The index may be either
46 -- the application class or instance. The instance is useful when running
47 -- a console app in a terminal like (Music on Console)
48 -- xterm -name mocp -e mocp
59 -- Applications to be moved to a pre-defined tag by class or instance.
60 -- Use the screen and tags indices.
63 -- ["Firefox"] = { screen = 1, tag = 2 },
64 -- ["mocp"] = { screen = 2, tag = 4 },
67 -- Define if we want to use titlebar on all applications.
74 for s
= 1, screen
.count() do
75 -- Each screen has its own tag table.
77 -- Create 9 tags per screen.
78 for tagnumber
= 1, 9 do
79 tags
[s
][tagnumber
] = tag(tagnumber
)
80 -- Add tags to screen one by one
81 tags
[s
][tagnumber
].screen
= s
82 awful
.layout
.set(layouts
[1], tags
[s
][tagnumber
])
84 -- I'm sure you want to see at least one tag.
85 tags
[s
][1].selected
= true
90 -- Create a textbox widget
91 mytextbox
= widget({ type = "textbox", align
= "right" })
92 -- Set the default text in textbox
93 mytextbox
.text
= "<b><small> " .. AWESOME_RELEASE
.. " </small></b>"
95 -- Create a laucher widget and a main menu
97 { "manual", terminal
.. " -e man awesome" },
98 { "edit config", editor_cmd
.. " " .. awful
.util
.getdir("config") .. "/rc.lua" },
99 { "restart", awesome
.restart
},
100 { "quit", awesome
.quit
}
103 mymainmenu
= awful
.menu
.new({ items
= { { "awesome", myawesomemenu
, beautiful
.awesome_icon
},
104 { "open terminal", terminal
}
108 mylauncher
= awful
.widget
.launcher({ image
= image(beautiful
.awesome_icon
),
112 mysystray
= widget({ type = "systray", align
= "right" })
114 -- Create a wibox for each screen and add it
119 mytaglist
.buttons
= { button({ }, 1, awful
.tag.viewonly
),
120 button({ modkey
}, 1, awful
.client
.movetotag
),
121 button({ }, 3, function (tag) tag.selected
= not tag.selected
end),
122 button({ modkey
}, 3, awful
.client
.toggletag
),
123 button({ }, 4, awful
.tag.viewnext
),
124 button({ }, 5, awful
.tag.viewprev
) }
126 mytasklist
.buttons
= { button({ }, 1, function (c
)
127 if not c
:isvisible() then
128 awful
.tag.viewonly(c
:tags()[1])
133 button({ }, 3, function () if instance
then instance
:hide() end instance
= awful
.menu
.clients({ width
=250 }) end),
134 button({ }, 4, function () awful
.client
.focus
.byidx(1) end),
135 button({ }, 5, function () awful
.client
.focus
.byidx(-1) end) }
137 for s
= 1, screen
.count() do
138 -- Create a promptbox for each screen
139 mypromptbox
[s
] = widget({ type = "textbox", align
= "left" })
140 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
141 -- We need one layoutbox per screen.
142 mylayoutbox
[s
] = widget({ type = "imagebox", align
= "right" })
143 mylayoutbox
[s
]:buttons({ button({ }, 1, function () awful
.layout
.inc(layouts
, 1) end),
144 button({ }, 3, function () awful
.layout
.inc(layouts
, -1) end),
145 button({ }, 4, function () awful
.layout
.inc(layouts
, 1) end),
146 button({ }, 5, function () awful
.layout
.inc(layouts
, -1) end) })
147 -- Create a taglist widget
148 mytaglist
[s
] = awful
.widget
.taglist
.new(s
, awful
.widget
.taglist
.label
.all
, mytaglist
.buttons
)
150 -- Create a tasklist widget
151 mytasklist
[s
] = awful
.widget
.tasklist
.new(function(c
)
152 return awful
.widget
.tasklist
.label
.currenttags(c
, s
)
153 end, mytasklist
.buttons
)
156 mywibox
[s
] = wibox({ position
= "top", fg
= beautiful
.fg_normal
, bg
= beautiful
.bg_normal
})
157 -- Add widgets to the wibox - order matters
158 mywibox
[s
].widgets
= { mylauncher
,
164 s
== 1 and mysystray
or nil }
165 mywibox
[s
].screen
= s
169 -- {{{ Mouse bindings
171 button({ }, 3, function () mymainmenu
:toggle() end),
172 button({ }, 4, awful
.tag.viewnext
),
173 button({ }, 5, awful
.tag.viewprev
)
178 -- Bind keyboard digits
179 -- Compute the maximum number of digit we need, limited to 9
181 for s
= 1, screen
.count() do
182 keynumber
= math
.min(9, math
.max(#tags
[s
], keynumber
));
188 for i
= 1, keynumber
do
189 table.insert(globalkeys
,
192 local screen
= mouse
.screen
193 if tags
[screen
][i
] then
194 awful
.tag.viewonly(tags
[screen
][i
])
197 table.insert(globalkeys
,
198 key({ modkey
, "Control" }, i
,
200 local screen
= mouse
.screen
201 if tags
[screen
][i
] then
202 tags
[screen
][i
].selected
= not tags
[screen
][i
].selected
205 table.insert(globalkeys
,
206 key({ modkey
, "Shift" }, i
,
208 if client
.focus
and tags
[client
.focus
.screen
][i
] then
209 awful
.client
.movetotag(tags
[client
.focus
.screen
][i
])
212 table.insert(globalkeys
,
213 key({ modkey
, "Control", "Shift" }, i
,
215 if client
.focus
and tags
[client
.focus
.screen
][i
] then
216 awful
.client
.toggletag(tags
[client
.focus
.screen
][i
])
221 table.insert(globalkeys
, key({ modkey
}, "Left", awful
.tag.viewprev
))
222 table.insert(globalkeys
, key({ modkey
}, "Right", awful
.tag.viewnext
))
223 table.insert(globalkeys
, key({ modkey
}, "Escape", awful
.tag.history
.restore
))
225 table.insert(globalkeys
, key({ modkey
}, "j", function () awful
.client
.focus
.byidx(1); if client
.focus
then client
.focus
:raise() end end))
226 table.insert(globalkeys
, key({ modkey
}, "k", function () awful
.client
.focus
.byidx(-1); if client
.focus
then client
.focus
:raise() end end))
227 table.insert(globalkeys
, key({ modkey
, "Shift" }, "j", function () awful
.client
.swap
.byidx(1) end))
228 table.insert(globalkeys
, key({ modkey
, "Shift" }, "k", function () awful
.client
.swap
.byidx(-1) end))
230 table.insert(globalkeys
, key({ modkey
, "Control" }, "j", function () awful
.screen
.focus(1) end))
231 table.insert(globalkeys
, key({ modkey
, "Control" }, "k", function () awful
.screen
.focus(-1) end))
233 table.insert(globalkeys
, key({ modkey
}, "Tab", function () awful
.client
.focus
.history
.previous(); if client
.focus
then client
.focus
:raise() end end))
235 table.insert(globalkeys
, key({ modkey
}, "u", awful
.client
.urgent
.jumpto
))
238 table.insert(globalkeys
, key({ modkey
}, "Return", function () awful
.util
.spawn(terminal
) end))
240 table.insert(globalkeys
, key({ modkey
, "Control" }, "r", function ()
241 mypromptbox
[mouse
.screen
].text
=
242 awful
.util
.escape(awful
.util
.restart())
244 table.insert(globalkeys
, key({ modkey
, "Shift" }, "q", awesome
.quit
))
246 -- Client manipulation
247 table.insert(clientkeys
, key({ modkey
}, "m", function (c
) c
.maximized_horizontal
= not c
.maximized_horizontal
248 c
.maximized_vertical
= not c
.maximized_vertical
end))
249 table.insert(clientkeys
, key({ modkey
}, "f", function (c
) c
.fullscreen
= not c
.fullscreen
end))
250 table.insert(clientkeys
, key({ modkey
, "Shift" }, "c", function (c
) c
:kill() end))
251 table.insert(clientkeys
, key({ modkey
, "Control" }, "space", awful
.client
.floating
.toggle
))
252 table.insert(clientkeys
, key({ modkey
, "Control" }, "Return", function (c
) c
:swap(awful
.client
.getmaster()) end))
253 table.insert(clientkeys
, key({ modkey
}, "o", awful
.client
.movetoscreen
))
254 table.insert(clientkeys
, key({ modkey
, "Shift" }, "r", function (c
) c
:redraw() end))
256 -- Layout manipulation
257 table.insert(globalkeys
, key({ modkey
}, "l", function () awful
.tag.incmwfact(0.05) end))
258 table.insert(globalkeys
, key({ modkey
}, "h", function () awful
.tag.incmwfact(-0.05) end))
259 table.insert(globalkeys
, key({ modkey
, "Shift" }, "h", function () awful
.tag.incnmaster(1) end))
260 table.insert(globalkeys
, key({ modkey
, "Shift" }, "l", function () awful
.tag.incnmaster(-1) end))
261 table.insert(globalkeys
, key({ modkey
, "Control" }, "h", function () awful
.tag.incncol(1) end))
262 table.insert(globalkeys
, key({ modkey
, "Control" }, "l", function () awful
.tag.incncol(-1) end))
263 table.insert(globalkeys
, key({ modkey
}, "space", function () awful
.layout
.inc(layouts
, 1) end))
264 table.insert(globalkeys
, key({ modkey
, "Shift" }, "space", function () awful
.layout
.inc(layouts
, -1) end))
267 table.insert(globalkeys
, key({ modkey
}, "F1", function ()
268 awful
.prompt
.run({ prompt
= "Run: " },
269 mypromptbox
[mouse
.screen
],
270 awful
.util
.spawn
, awful
.completion
.bash
,
271 awful
.util
.getdir("cache") .. "/history")
273 table.insert(globalkeys
, key({ modkey
}, "F4", function ()
274 awful
.prompt
.run({ prompt
= "Run Lua code: " },
275 mypromptbox
[mouse
.screen
],
276 awful
.util
.eval
, awful
.prompt
.bash
,
277 awful
.util
.getdir("cache") .. "/history_eval")
280 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
281 table.insert(clientkeys
, key({ modkey
}, "t", awful
.client
.togglemarked
))
283 for i
= 1, keynumber
do
284 table.insert(globalkeys
, key({ modkey
, "Shift" }, "F" .. i
,
286 local screen
= mouse
.screen
287 if tags
[screen
][i
] then
288 for k
, c
in pairs(awful
.client
.getmarked()) do
289 awful
.client
.movetotag(tags
[screen
][i
], c
)
296 root
.keys(globalkeys
)
300 -- Hook function to execute when focusing a client.
301 awful
.hooks
.focus
.register(function (c
)
302 if not awful
.client
.ismarked(c
) then
303 c
.border_color
= beautiful
.border_focus
307 -- Hook function to execute when unfocusing a client.
308 awful
.hooks
.unfocus
.register(function (c
)
309 if not awful
.client
.ismarked(c
) then
310 c
.border_color
= beautiful
.border_normal
314 -- Hook function to execute when marking a client
315 awful
.hooks
.marked
.register(function (c
)
316 c
.border_color
= beautiful
.border_marked
319 -- Hook function to execute when unmarking a client.
320 awful
.hooks
.unmarked
.register(function (c
)
321 c
.border_color
= beautiful
.border_focus
324 -- Hook function to execute when the mouse enters a client.
325 awful
.hooks
.mouse_enter
.register(function (c
)
326 -- Sloppy focus, but disabled for magnifier layout
327 if awful
.layout
.get(c
.screen
) ~= awful
.layout
.suit
.magnifier
328 and awful
.client
.focus
.filter(c
) then
333 -- Hook function to execute when a new client appears.
334 awful
.hooks
.manage
.register(function (c
, startup
)
335 -- If we are not managing this application at startup,
336 -- move it to the screen where the mouse is.
337 -- We only do it for filtered windows (i.e. no dock, etc).
338 if not startup
and awful
.client
.focus
.filter(c
) then
339 c
.screen
= mouse
.screen
344 awful
.titlebar
.add(c
, { modkey
= modkey
})
346 -- Add mouse bindings
348 button({ }, 1, function (c
) client
.focus
= c
; c
:raise() end),
349 button({ modkey
}, 1, awful
.mouse
.client
.move
),
350 button({ modkey
}, 3, awful
.mouse
.client
.resize
)
352 -- New client may not receive focus
353 -- if they're not focusable, so set border anyway.
354 c
.border_width
= beautiful
.border_width
355 c
.border_color
= beautiful
.border_normal
357 -- Check if the application should be floating.
359 local inst
= c
.instance
360 if floatapps
[cls
] then
361 awful
.client
.floating
.set(c
, floatapps
[cls
])
362 elseif floatapps
[inst
] then
363 awful
.client
.floating
.set(c
, floatapps
[inst
])
366 -- Check application->screen/tag mappings.
369 target
= apptags
[cls
]
370 elseif apptags
[inst
] then
371 target
= apptags
[inst
]
374 c
.screen
= target
.screen
375 awful
.client
.movetotag(tags
[target
.screen
][target
.tag], c
)
378 -- Do this after tag mapping, so you don't see it on the wrong tag for a split second.
384 -- Set the windows at the slave,
385 -- i.e. put it at the end of others instead of setting it master.
386 -- awful.client.setslave(c)
388 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
389 -- c.size_hints_honor = false
392 -- Hook function to execute when arranging the screen.
393 -- (tag switch, new client, etc)
394 awful
.hooks
.arrange
.register(function (screen
)
395 local layout
= awful
.layout
.getname(awful
.layout
.get(screen
))
396 if layout
and beautiful
["layout_" ..layout
] then
397 mylayoutbox
[screen
].image
= image(beautiful
["layout_" .. layout
])
399 mylayoutbox
[screen
].image
= nil
402 -- Give focus to the latest client in history if no window has focus
403 -- or if the current window is a desktop or a dock one.
404 if not client
.focus
then
405 local c
= awful
.client
.focus
.history
.get(screen
, 0)
406 if c
then client
.focus
= c
end
410 -- Hook called every second
411 awful
.hooks
.timer
.register(1, function ()
412 -- For unix time_t lovers
413 mytextbox
.text
= " " .. os
.time() .. " time_t "
415 -- mytextbox.text = " " .. os.date() .. " "