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 -- Uncomment this to activate autotabbing
72 -- tabulous.autotab_start()
78 for s
= 1, screen
.count() do
79 -- Each screen has its own tag table.
81 -- Create 9 tags per screen.
82 for tagnumber
= 1, 9 do
83 tags
[s
][tagnumber
] = tag({ name
= tagnumber
, layout
= layouts
[1] })
84 -- Add tags to screen one by one
85 tags
[s
][tagnumber
].screen
= s
87 -- I'm sure you want to see at least one tag.
88 tags
[s
][1].selected
= true
93 -- Create a taglist widget
94 mytaglist
= widget({ type = "taglist", name
= "mytaglist" })
95 mytaglist
:mouse_add(mouse({}, 1, function (object
, tag) awful
.tag.viewonly(tag) end))
96 mytaglist
:mouse_add(mouse({ modkey
}, 1, function (object
, tag) awful
.client
.movetotag(tag) end))
97 mytaglist
:mouse_add(mouse({}, 3, function (object
, tag) tag.selected
= not tag.selected
end))
98 mytaglist
:mouse_add(mouse({ modkey
}, 3, function (object
, tag) awful
.client
.toggletag(tag) end))
99 mytaglist
:mouse_add(mouse({ }, 4, awful
.tag.viewnext
))
100 mytaglist
:mouse_add(mouse({ }, 5, awful
.tag.viewprev
))
101 mytaglist
.label
= awful
.widget
.taglist
.label
.all
103 -- Create a tasklist widget
104 mytasklist
= widget({ type = "tasklist", name
= "mytasklist" })
105 mytasklist
:mouse_add(mouse({ }, 1, function (object
, c
) client
.focus
= c
; c
:raise() end))
106 mytasklist
:mouse_add(mouse({ }, 4, function () awful
.client
.focusbyidx(1) end))
107 mytasklist
:mouse_add(mouse({ }, 5, function () awful
.client
.focusbyidx(-1) end))
108 mytasklist
.label
= awful
.widget
.tasklist
.label
.currenttags
110 -- Create a textbox widget
111 mytextbox
= widget({ type = "textbox", name
= "mytextbox", align
= "right" })
112 -- Set the default text in textbox
113 mytextbox
.text
= "<b><small> awesome " .. AWESOME_VERSION
.. " </small></b>"
114 mypromptbox
= widget({ type = "textbox", name
= "mypromptbox", align
= "left" })
116 -- Create an iconbox widget
117 myiconbox
= widget({ type = "textbox", name
= "myiconbox", align
= "left" })
118 myiconbox
.text
= "<bg image=\"@AWESOME_ICON_PATH@/awesome16.png\" resize=\"true\"/>"
121 mysystray
= widget({ type = "systray", name
= "mysystray", align
= "right" })
123 -- Create an iconbox widget which will contains an icon indicating which layout we're using.
124 -- We need one layoutbox per screen.
126 for s
= 1, screen
.count() do
127 mylayoutbox
[s
] = widget({ type = "textbox", name
= "mylayoutbox", align
= "right" })
128 mylayoutbox
[s
]:mouse_add(mouse({ }, 1, function () awful
.layout
.inc(layouts
, 1) end))
129 mylayoutbox
[s
]:mouse_add(mouse({ }, 3, function () awful
.layout
.inc(layouts
, -1) end))
130 mylayoutbox
[s
]:mouse_add(mouse({ }, 4, function () awful
.layout
.inc(layouts
, 1) end))
131 mylayoutbox
[s
]:mouse_add(mouse({ }, 5, function () awful
.layout
.inc(layouts
, -1) end))
132 mylayoutbox
[s
].text
= "<bg image=\"@AWESOME_ICON_PATH@/layouts/tilew.png\" resize=\"true\"/>"
135 -- Create a statusbar for each screen and add it
137 for s
= 1, screen
.count() do
138 mystatusbar
[s
] = statusbar({ position
= "top", name
= "mystatusbar" .. s
,
139 fg
= beautiful
.fg_normal
, bg
= beautiful
.bg_normal
})
140 -- Add widgets to the statusbar - order matters
141 mystatusbar
[s
]:widgets({
148 s
== screen
.count() and mysystray
or nil
150 mystatusbar
[s
].screen
= s
154 -- {{{ Mouse bindings
155 awesome
.mouse_add(mouse({ }, 3, function () awful
.spawn(terminal
) end))
156 awesome
.mouse_add(mouse({ }, 4, awful
.tag.viewnext
))
157 awesome
.mouse_add(mouse({ }, 5, awful
.tag.viewprev
))
162 -- Bind keyboard digits
163 -- Compute the maximum number of digit we need, limited to 9
165 for s
= 1, screen
.count() do
166 keynumber
= math
.min(9, math
.max(#tags
[s
], keynumber
));
169 for i
= 1, keynumber
do
170 keybinding({ modkey
}, i
,
172 local screen
= mouse
.screen
173 if tags
[screen
][i
] then
174 awful
.tag.viewonly(tags
[screen
][i
])
177 keybinding({ modkey
, "Control" }, i
,
179 local screen
= mouse
.screen
180 if tags
[screen
][i
] then
181 tags
[screen
][i
].selected
= not tags
[screen
][i
].selected
184 keybinding({ modkey
, "Shift" }, i
,
186 local sel
= client
.focus
188 if tags
[sel
.screen
][i
] then
189 awful
.client
.movetotag(tags
[sel
.screen
][i
])
193 keybinding({ modkey
, "Control", "Shift" }, i
,
195 local sel
= client
.focus
197 if tags
[sel
.screen
][i
] then
198 awful
.client
.toggletag(tags
[sel
.screen
][i
])
204 keybinding({ modkey
}, "Left", awful
.tag.viewprev
):add()
205 keybinding({ modkey
}, "Right", awful
.tag.viewnext
):add()
206 keybinding({ modkey
}, "Escape", awful
.tag.history
.restore
):add()
209 keybinding({ modkey
}, "Return", function () awful
.spawn(terminal
) end):add()
211 keybinding({ modkey
, "Control" }, "r", awesome
.restart
):add()
212 keybinding({ modkey
, "Shift" }, "q", awesome
.quit
):add()
214 -- Client manipulation
215 keybinding({ modkey
}, "m", awful
.client
.maximize
):add()
216 keybinding({ modkey
, "Shift" }, "c", function () client
.focus
:kill() end):add()
217 keybinding({ modkey
}, "j", function () awful
.client
.focusbyidx(1); client
.focus
:raise() end):add()
218 keybinding({ modkey
}, "k", function () awful
.client
.focusbyidx(-1); client
.focus
:raise() end):add()
219 keybinding({ modkey
, "Shift" }, "j", function () awful
.client
.swap(1) end):add()
220 keybinding({ modkey
, "Shift" }, "k", function () awful
.client
.swap(-1) end):add()
221 keybinding({ modkey
, "Control" }, "j", function () awful
.screen
.focus(1) end):add()
222 keybinding({ modkey
, "Control" }, "k", function () awful
.screen
.focus(-1) end):add()
223 keybinding({ modkey
, "Control" }, "space", awful
.client
.togglefloating
):add()
224 keybinding({ modkey
, "Control" }, "Return", function () client
.focus
:swap(awful
.client
.master()) end):add()
225 keybinding({ modkey
}, "o", awful
.client
.movetoscreen
):add()
226 keybinding({ modkey
}, "Tab", awful
.client
.focus
.history
.previous
):add()
227 keybinding({ modkey
}, "u", awful
.client
.urgent
.jumpto
):add()
228 keybinding({ modkey
, "Shift" }, "r", function () client
.focus
:redraw() end):add()
230 -- Layout manipulation
231 keybinding({ modkey
}, "l", function () awful
.tag.incmwfact(0.05) end):add()
232 keybinding({ modkey
}, "h", function () awful
.tag.incmwfact(-0.05) end):add()
233 keybinding({ modkey
, "Shift" }, "h", function () awful
.tag.incnmaster(1) end):add()
234 keybinding({ modkey
, "Shift" }, "l", function () awful
.tag.incnmaster(-1) end):add()
235 keybinding({ modkey
, "Control" }, "h", function () awful
.tag.incncol(1) end):add()
236 keybinding({ modkey
, "Control" }, "l", function () awful
.tag.incncol(-1) end):add()
237 keybinding({ modkey
}, "space", function () awful
.layout
.inc(layouts
, 1) end):add()
238 keybinding({ modkey
, "Shift" }, "space", function () awful
.layout
.inc(layouts
, -1) end):add()
241 keybinding({ modkey
}, "F1", function ()
242 awful
.prompt
.run({ prompt
= "Run: " }, mypromptbox
, awful
.spawn
, awful
.completion
.bash
,
243 os
.getenv("HOME") .. "/.cache/awesome/history") end):add()
244 keybinding({ modkey
}, "F4", function ()
245 awful
.prompt
.run({ prompt
= "Run Lua code: " }, mypromptbox
, awful
.eval
, awful
.prompt
.bash
,
246 os
.getenv("HOME") .. "/.cache/awesome/history_eval") end):add()
247 keybinding({ modkey
, "Ctrl" }, "i", function ()
248 if mypromptbox
.text
then
249 mypromptbox
.text
= nil
251 mypromptbox
.text
= "Class: " .. client
.focus
.class
.. " Instance: ".. client
.focus
.instance
255 --- Tabulous, tab manipulation
256 keybinding({ modkey
, "Control" }, "y", function ()
257 local tabbedview
= tabulous
.tabindex_get()
258 local nextclient
= awful
.client
.next(1)
260 if not tabbedview
then
261 tabbedview
= tabulous
.tabindex_get(nextclient
)
263 if not tabbedview
then
264 tabbedview
= tabulous
.tab_create()
265 tabulous
.tab(tabbedview
, nextclient
)
267 tabulous
.tab(tabbedview
, client
.focus
)
270 tabulous
.tab(tabbedview
, nextclient
)
274 keybinding({ modkey
, "Shift" }, "y", tabulous
.untab
):add()
276 keybinding({ modkey
}, "y", function ()
277 local tabbedview
= tabulous
.tabindex_get()
280 local n
= tabulous
.next(tabbedview
)
281 tabulous
.display(tabbedview
, n
)
285 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
286 keybinding({ modkey
}, "t", awful
.client
.togglemarked
):add()
287 keybinding({ modkey
, 'Shift' }, "t", function ()
288 local tabbedview
= tabulous
.tabindex_get()
289 local clients
= awful
.client
.getmarked()
291 if not tabbedview
then
292 tabbedview
= tabulous
.tab_create(clients
[1])
293 table.remove(clients
, 1)
296 for k
,c
in pairs(clients
) do
297 tabulous
.tab(tabbedview
, c
)
302 for i
= 1, keynumber
do
303 keybinding({ modkey
, "Shift" }, "F" .. i
,
305 local screen
= mouse
.screen
306 if tags
[screen
][i
] then
307 for k
, c
in pairs(awful
.client
.getmarked()) do
308 awful
.client
.movetotag(tags
[screen
][i
], c
)
316 -- Hook function to execute when focusing a client.
317 function hook_focus(c
)
318 if not awful
.client
.ismarked(c
) then
319 c
.border_color
= beautiful
.border_focus
323 -- Hook function to execute when unfocusing a client.
324 function hook_unfocus(c
)
325 if not awful
.client
.ismarked(c
) then
326 c
.border_color
= beautiful
.border_normal
330 -- Hook function to execute when marking a client
331 function hook_marked(c
)
332 c
.border_color
= beautiful
.border_marked
335 -- Hook function to execute when unmarking a client
336 function hook_unmarked(c
)
337 c
.border_color
= beautiful
.border_focus
340 -- Hook function to execute when the mouse is over a client.
341 function hook_mouseover(c
)
342 -- Sloppy focus, but disabled for magnifier layout
343 if awful
.layout
.get(c
.screen
) ~= "magnifier" then
348 -- Hook function to execute when a new client appears.
349 function hook_manage(c
)
350 -- Set floating placement to be smart!
351 c
.floating_placement
= "smart"
354 awful
.titlebar
.add(c
, { modkey
= modkey
})
356 -- Add mouse bindings
357 c
:mouse_add(mouse({ }, 1, function (c
) client
.focus
= c
; c
:raise() end))
358 c
:mouse_add(mouse({ modkey
}, 1, function (c
) c
:mouse_move() end))
359 c
:mouse_add(mouse({ modkey
}, 3, function (c
) c
:mouse_resize() end))
360 -- New client may not receive focus
361 -- if they're not focusable, so set border anyway.
362 c
.border_width
= beautiful
.border_width
363 c
.border_color
= beautiful
.border_normal
366 -- Check if the application should be floating.
368 local inst
= c
.instance
369 if floatapps
[cls
] then
370 c
.floating
= floatapps
[cls
]
371 elseif floatapps
[inst
] then
372 c
.floating
= floatapps
[inst
]
375 -- Check application->screen/tag mappings.
378 target
= apptags
[cls
]
379 elseif apptags
[inst
] then
380 target
= apptags
[inst
]
383 c
.screen
= target
.screen
384 awful
.client
.movetotag(tags
[target
.screen
][target
.tag], c
)
388 c
.honorsizehints
= true
391 -- Hook function to execute when arranging the screen
392 -- (tag switch, new client, etc)
393 function hook_arrange(screen
)
394 local layout
= awful
.layout
.get(screen
)
396 mylayoutbox
[screen
].text
=
397 "<bg image=\"@AWESOME_ICON_PATH@/layouts/" .. awful
.layout
.get(screen
) .. "w.png\" resize=\"true\"/>"
399 mylayoutbox
[screen
].text
= "No layout."
402 -- If no window has focus, give focus to the latest in history
403 if not client
.focus
then
404 local c
= awful
.client
.focus
.history
.get(screen
, 0)
405 if c
then client
.focus
= c
end
408 -- Uncomment if you want mouse warping
410 local sel = client.focus
412 local c_c = sel:coords()
413 local m_c = mouse.coords()
415 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
416 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
417 if table.maxn(m_c.buttons) == 0 then
418 mouse.coords({ x = c_c.x + 5, y = c_c.y + 5})
425 -- Hook called every second
426 function hook_timer ()
427 -- For unix time_t lovers
428 mytextbox
.text
= " " .. os
.time() .. " time_t "
430 -- mytextbox.text = " " .. os.date() .. " "
434 awful
.hooks
.focus
.register(hook_focus
)
435 awful
.hooks
.unfocus
.register(hook_unfocus
)
436 awful
.hooks
.marked
.register(hook_marked
)
437 awful
.hooks
.unmarked
.register(hook_unmarked
)
438 awful
.hooks
.manage
.register(hook_manage
)
439 awful
.hooks
.mouseover
.register(hook_mouseover
)
440 awful
.hooks
.arrange
.register(hook_arrange
)
441 awful
.hooks
.timer
.register(1, hook_timer
)