1 -- awesome 3 configuration file
3 -- Include awesome library, with lots of useful function!
8 -- {{{ Variable definitions
9 -- This is a file path to a theme file which will defines colors.
10 theme_path
= "@AWESOME_THEMES_PATH@/default"
12 -- This is used later as the default terminal to run.
16 -- Usually, Mod4 is the key with a logo between Control and Alt.
17 -- If you do not like this or do not have such a key,
18 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
19 -- However, you can use another modifier like Mod1, but it may interact with others.
22 -- Table of layouts to cover with awful.layout.inc, order matters.
36 -- Table of clients that should be set floating. The index may be either
37 -- the application class or instance. The instance is useful when running
38 -- a console app in a terminal like (Music on Console)
39 -- xterm -name mocp -e mocp
50 -- Applications to be moved to a pre-defined tag by class or instance.
51 -- Use the screen and tags indices.
54 -- ["Firefox"] = { screen = 1, tag = 2 },
55 -- ["mocp"] = { screen = 2, tag = 4 },
58 -- Define if we want to use titlebar on all applications.
63 -- Initialize theme (colors).
64 beautiful
.init(theme_path
)
66 -- Register theme in awful.
67 -- This allows to not pass plenty of arguments to each function
68 -- to inform it about colors we want it to draw.
69 awful
.beautiful
.register(beautiful
)
71 -- Enable prompt history
72 awful
.prompt
.history
.set()
74 -- Uncomment this to activate autotabbing
75 -- tabulous.autotab_start()
81 for s
= 1, screen
.count() do
82 -- Each screen has its own tag table.
84 -- Create 9 tags per screen.
85 for tagnumber
= 1, 9 do
86 tags
[s
][tagnumber
] = tag({ name
= tagnumber
, layout
= layouts
[1] })
87 -- Add tags to screen one by one
88 tags
[s
][tagnumber
].screen
= s
90 -- I'm sure you want to see at least one tag.
91 tags
[s
][1].selected
= true
96 -- Create a taglist widget
97 mytaglist
= widget({ type = "taglist", name
= "mytaglist" })
98 mytaglist
:mouse_add(mouse({}, 1, function (object
, tag) awful
.tag.viewonly(tag) end))
99 mytaglist
:mouse_add(mouse({ modkey
}, 1, function (object
, tag) awful
.client
.movetotag(tag) end))
100 mytaglist
:mouse_add(mouse({}, 3, function (object
, tag) tag.selected
= not tag.selected
end))
101 mytaglist
:mouse_add(mouse({ modkey
}, 3, function (object
, tag) awful
.client
.toggletag(tag) end))
102 mytaglist
:mouse_add(mouse({ }, 4, awful
.tag.viewnext
))
103 mytaglist
:mouse_add(mouse({ }, 5, awful
.tag.viewprev
))
104 mytaglist
.label
= awful
.widget
.taglist
.label
.all
106 -- Create a tasklist widget
107 mytasklist
= widget({ type = "tasklist", name
= "mytasklist" })
108 mytasklist
:mouse_add(mouse({ }, 1, function (object
, c
) client
.focus
= c
; c
:raise() end))
109 mytasklist
:mouse_add(mouse({ }, 4, function () awful
.client
.focusbyidx(1) end))
110 mytasklist
:mouse_add(mouse({ }, 5, function () awful
.client
.focusbyidx(-1) end))
111 mytasklist
.label
= awful
.widget
.tasklist
.label
.currenttags
113 -- Create a textbox widget
114 mytextbox
= widget({ type = "textbox", name
= "mytextbox", align
= "right" })
115 -- Set the default text in textbox
116 mytextbox
.text
= "<b><small> awesome " .. AWESOME_VERSION
.. " </small></b>"
117 mypromptbox
= widget({ type = "textbox", name
= "mypromptbox", align
= "left" })
119 -- Create an iconbox widget
120 myiconbox
= widget({ type = "textbox", name
= "myiconbox", align
= "left" })
121 myiconbox
.text
= "<bg image=\"@AWESOME_ICON_PATH@/awesome16.png\" resize=\"true\"/>"
124 mysystray
= widget({ type = "systray", name
= "mysystray", align
= "right" })
126 -- Create an iconbox widget which will contains an icon indicating which layout we're using.
127 -- We need one layoutbox per screen.
129 for s
= 1, screen
.count() do
130 mylayoutbox
[s
] = widget({ type = "textbox", name
= "mylayoutbox", align
= "right" })
131 mylayoutbox
[s
]:mouse_add(mouse({ }, 1, function () awful
.layout
.inc(layouts
, 1) end))
132 mylayoutbox
[s
]:mouse_add(mouse({ }, 3, function () awful
.layout
.inc(layouts
, -1) end))
133 mylayoutbox
[s
]:mouse_add(mouse({ }, 4, function () awful
.layout
.inc(layouts
, 1) end))
134 mylayoutbox
[s
]:mouse_add(mouse({ }, 5, function () awful
.layout
.inc(layouts
, -1) end))
135 mylayoutbox
[s
].text
= "<bg image=\"@AWESOME_ICON_PATH@/layouts/tilew.png\" resize=\"true\"/>"
138 -- Create a statusbar for each screen and add it
140 for s
= 1, screen
.count() do
141 mystatusbar
[s
] = statusbar({ position
= "top", name
= "mystatusbar" .. s
,
142 fg
= beautiful
.fg_normal
, bg
= beautiful
.bg_normal
})
143 -- Add widgets to the statusbar - order matters
144 mystatusbar
[s
].widgets
=
151 s
== screen
.count() and mysystray
or nil
153 mystatusbar
[s
].screen
= s
157 -- {{{ Mouse bindings
158 awesome
.mouse_add(mouse({ }, 3, function () awful
.spawn(terminal
) end))
159 awesome
.mouse_add(mouse({ }, 4, awful
.tag.viewnext
))
160 awesome
.mouse_add(mouse({ }, 5, awful
.tag.viewprev
))
165 -- Bind keyboard digits
166 -- Compute the maximum number of digit we need, limited to 9
168 for s
= 1, screen
.count() do
169 keynumber
= math
.min(9, math
.max(#tags
[s
], keynumber
));
172 for i
= 1, keynumber
do
173 keybinding({ modkey
}, i
,
175 local screen
= mouse
.screen
176 if tags
[screen
][i
] then
177 awful
.tag.viewonly(tags
[screen
][i
])
180 keybinding({ modkey
, "Control" }, i
,
182 local screen
= mouse
.screen
183 if tags
[screen
][i
] then
184 tags
[screen
][i
].selected
= not tags
[screen
][i
].selected
187 keybinding({ modkey
, "Shift" }, i
,
189 local sel
= client
.focus
191 if tags
[sel
.screen
][i
] then
192 awful
.client
.movetotag(tags
[sel
.screen
][i
])
196 keybinding({ modkey
, "Control", "Shift" }, i
,
198 local sel
= client
.focus
200 if tags
[sel
.screen
][i
] then
201 awful
.client
.toggletag(tags
[sel
.screen
][i
])
207 keybinding({ modkey
}, "Left", awful
.tag.viewprev
):add()
208 keybinding({ modkey
}, "Right", awful
.tag.viewnext
):add()
209 keybinding({ modkey
}, "Escape", awful
.tag.history
.restore
):add()
212 keybinding({ modkey
}, "Return", function () awful
.spawn(terminal
) end):add()
214 keybinding({ modkey
, "Control" }, "r", awesome
.restart
):add()
215 keybinding({ modkey
, "Shift" }, "q", awesome
.quit
):add()
217 -- Client manipulation
218 keybinding({ modkey
}, "m", awful
.client
.maximize
):add()
219 keybinding({ modkey
, "Shift" }, "c", function () client
.focus
:kill() end):add()
220 keybinding({ modkey
}, "j", function () awful
.client
.focusbyidx(1); client
.focus
:raise() end):add()
221 keybinding({ modkey
}, "k", function () awful
.client
.focusbyidx(-1); client
.focus
:raise() end):add()
222 keybinding({ modkey
, "Shift" }, "j", function () awful
.client
.swap(1) end):add()
223 keybinding({ modkey
, "Shift" }, "k", function () awful
.client
.swap(-1) end):add()
224 keybinding({ modkey
, "Control" }, "j", function () awful
.screen
.focus(1) end):add()
225 keybinding({ modkey
, "Control" }, "k", function () awful
.screen
.focus(-1) end):add()
226 keybinding({ modkey
, "Control" }, "space", awful
.client
.togglefloating
):add()
227 keybinding({ modkey
, "Control" }, "Return", function () client
.focus
:swap(awful
.client
.master()) end):add()
228 keybinding({ modkey
}, "o", awful
.client
.movetoscreen
):add()
229 keybinding({ modkey
}, "Tab", awful
.client
.focus
.history
.previous
):add()
231 -- Layout manipulation
232 keybinding({ modkey
}, "l", function () awful
.tag.incmwfact(0.05) end):add()
233 keybinding({ modkey
}, "h", function () awful
.tag.incmwfact(-0.05) end):add()
234 keybinding({ modkey
, "Shift" }, "h", function () awful
.tag.incnmaster(1) end):add()
235 keybinding({ modkey
, "Shift" }, "l", function () awful
.tag.incnmaster(-1) end):add()
236 keybinding({ modkey
, "Control" }, "h", function () awful
.tag.incncol(1) end):add()
237 keybinding({ modkey
, "Control" }, "l", function () awful
.tag.incncol(-1) end):add()
238 keybinding({ modkey
}, "space", function () awful
.layout
.inc(layouts
, 1) end):add()
239 keybinding({ modkey
, "Shift" }, "space", function () awful
.layout
.inc(layouts
, -1) end):add()
242 keybinding({ modkey
}, "F1", function ()
243 awful
.prompt
.run({ prompt
= "Run: " }, mypromptbox
, awful
.spawn
, awful
.completion
.bash
)
245 keybinding({ modkey
}, "F4", function ()
246 awful
.prompt
.run({ prompt
= "Run Lua code: " }, mypromptbox
, awful
.eval
)
248 keybinding({ modkey
, "Ctrl" }, "i", function ()
249 if mypromptbox
.text
then
250 mypromptbox
.text
= nil
252 mypromptbox
.text
= "Class: " .. client
.focus
.class
.. " Instance: ".. client
.focus
.instance
256 --- Tabulous, tab manipulation
257 keybinding({ modkey
, "Control" }, "y", function ()
258 local tabbedview
= tabulous
.tabindex_get()
259 local nextclient
= awful
.client
.next(1)
261 if not tabbedview
then
262 tabbedview
= tabulous
.tabindex_get(nextclient
)
264 if not tabbedview
then
265 tabbedview
= tabulous
.tab_create()
266 tabulous
.tab(tabbedview
, nextclient
)
268 tabulous
.tab(tabbedview
, client
.focus
)
271 tabulous
.tab(tabbedview
, nextclient
)
275 keybinding({ modkey
, "Shift" }, "y", tabulous
.untab
):add()
277 keybinding({ modkey
}, "y", function ()
278 local tabbedview
= tabulous
.tabindex_get()
281 local n
= tabulous
.next(tabbedview
)
282 tabulous
.display(tabbedview
, n
)
286 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
287 keybinding({ modkey
}, "t", awful
.client
.togglemarked
):add()
288 keybinding({ modkey
, 'Shift' }, "t", function ()
289 local tabbedview
= tabulous
.tabindex_get()
290 local clients
= awful
.client
.getmarked()
292 if not tabbedview
then
293 tabbedview
= tabulous
.tab_create(clients
[1])
294 table.remove(clients
, 1)
297 for k
,c
in pairs(clients
) do
298 tabulous
.tab(tabbedview
, c
)
303 for i
= 1, keynumber
do
304 keybinding({ modkey
, "Shift" }, "F" .. i
,
306 local screen
= mouse
.screen
307 if tags
[screen
][i
] then
308 for k
, c
in pairs(awful
.client
.getmarked()) do
309 awful
.client
.movetotag(tags
[screen
][i
], c
)
317 -- Hook function to execute when focusing a client.
318 function hook_focus(c
)
319 if not awful
.client
.ismarked(c
) then
320 c
.border_color
= beautiful
.border_focus
324 -- Hook function to execute when unfocusing a client.
325 function hook_unfocus(c
)
326 if not awful
.client
.ismarked(c
) then
327 c
.border_color
= beautiful
.border_normal
331 -- Hook function to execute when marking a client
332 function hook_marked(c
)
333 c
.border_color
= beautiful
.border_marked
336 -- Hook function to execute when unmarking a client
337 function hook_unmarked(c
)
338 c
.border_color
= beautiful
.border_focus
341 -- Hook function to execute when the mouse is over a client.
342 function hook_mouseover(c
)
343 -- Sloppy focus, but disabled for magnifier layout
344 if awful
.layout
.get(c
.screen
) ~= "magnifier" then
349 -- Hook function to execute when a new client appears.
350 function hook_manage(c
)
351 -- Set floating placement to be smart!
352 c
.floating_placement
= "smart"
355 awful
.titlebar
.add(c
, { modkey
= modkey
})
357 -- Add mouse bindings
358 c
:mouse_add(mouse({ }, 1, function (c
) client
.focus
= c
; c
:raise() end))
359 c
:mouse_add(mouse({ modkey
}, 1, function (c
) c
:mouse_move() end))
360 c
:mouse_add(mouse({ modkey
}, 3, function (c
) c
:mouse_resize() end))
361 -- New client may not receive focus
362 -- if they're not focusable, so set border anyway.
363 c
.border_width
= beautiful
.border_width
364 c
.border_color
= beautiful
.border_normal
367 -- Check if the application should be floating.
369 local inst
= c
.instance
370 if floatapps
[cls
] then
371 c
.floating
= floatapps
[cls
]
372 elseif floatapps
[inst
] then
373 c
.floating
= floatapps
[inst
]
376 -- Check application->screen/tag mappings.
379 target
= apptags
[cls
]
380 elseif apptags
[inst
] then
381 target
= apptags
[inst
]
384 c
.screen
= target
.screen
385 awful
.client
.movetotag(tags
[target
.screen
][target
.tag], c
)
389 c
.honorsizehints
= true
392 -- Hook function to execute when arranging the screen
393 -- (tag switch, new client, etc)
394 function hook_arrange(screen
)
395 local layout
= awful
.layout
.get(screen
)
397 mylayoutbox
[screen
].text
=
398 "<bg image=\"@AWESOME_ICON_PATH@/layouts/" .. awful
.layout
.get(screen
) .. "w.png\" resize=\"true\"/>"
400 mylayoutbox
[screen
].text
= "No layout."
403 -- If no window has focus, give focus to the latest in history
404 if not client
.focus
then
405 local c
= awful
.client
.focus
.history
.get(screen
, 0)
406 if c
then client
.focus
= c
end
409 -- Uncomment if you want mouse warping
411 local sel = client.focus
413 local c_c = sel.coords
414 local m_c = mouse.coords
416 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
417 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
418 if table.maxn(m_c.buttons) == 0 then
419 mouse.coords = { x = c_c.x + 5, y = c_c.y + 5}
426 -- Hook called every second
427 function hook_timer ()
428 -- For unix time_t lovers
429 mytextbox
.text
= " " .. os
.time() .. " time_t "
431 -- mytextbox.text = " " .. os.date() .. " "
435 awful
.hooks
.focus
.register(hook_focus
)
436 awful
.hooks
.unfocus
.register(hook_unfocus
)
437 awful
.hooks
.marked
.register(hook_marked
)
438 awful
.hooks
.unmarked
.register(hook_unmarked
)
439 awful
.hooks
.manage
.register(hook_manage
)
440 awful
.hooks
.mouseover
.register(hook_mouseover
)
441 awful
.hooks
.arrange
.register(hook_arrange
)
442 awful
.hooks
.timer
.register(1, hook_timer
)