1 -- awesome 3 configuration file
3 -- Include awesome library, with lots of useful function!
7 -- Uncomment this to activate autotabbing
8 -- tabulous.autotab_start()
10 -- {{{ Variable definitions
11 -- This is used later as the default terminal to run.
15 -- Usually, Mod4 is the key with a logo between Control and Alt.
16 -- If you do not like this or do not have such a key,
17 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
18 -- However, you can use another modifier like Mod1, but it may interact with others.
21 -- Table of layouts to cover with awful.layout.inc, order matters.
35 -- Color & Appearance definitions, we use these later to display things
41 border_normal
= "#000000"
45 border_focus
= bg_focus
46 border_marked
= "#91231C"
48 awesome
.font_set(font
)
49 awesome
.colors_set({ fg
= fg_normal
, bg
= bg_normal
})
50 awesome
.resizehints_set(true)
57 for s
= 1, screen
.count() do
58 -- Each screen has its own tag table
60 -- Create 9 tags per screen
61 for tagnumber
= 1, 9 do
62 tags
[s
][tagnumber
] = tag.new({ name
= tagnumber
})
63 -- Add tags to screen one by one
64 tags
[s
][tagnumber
]:mwfact_set(0.618033988769)
65 tags
[s
][tagnumber
]:add(s
)
67 -- I'm sure you want to see at least one tag.
73 -- Create a taglist widget
74 mytaglist
= widget
.new({ type = "taglist", name
= "mytaglist" })
75 mytaglist
:mouse_add(mouse
.new({}, 1, function (object
, tag) awful
.tag.viewonly(tag) end))
76 mytaglist
:mouse_add(mouse
.new({ modkey
}, 1, function (object
, tag) awful
.client
.movetotag(tag) end))
77 mytaglist
:mouse_add(mouse
.new({}, 3, function (object
, tag) tag:view(not tag:isselected()) end))
78 mytaglist
:mouse_add(mouse
.new({ modkey
}, 3, function (object
, tag) awful
.client
.toggletag(tag) end))
79 mytaglist
:mouse_add(mouse
.new({ }, 4, awful
.tag.viewnext
))
80 mytaglist
:mouse_add(mouse
.new({ }, 5, awful
.tag.viewprev
))
81 mytaglist
:set("text_focus", "<bg color='"..bg_focus
.."'/> <span color='"..fg_focus
.."'><title/></span> ")
83 -- Create a tasklist widget
84 mytasklist
= widget
.new({ type = "tasklist", name
= "mytasklist" })
85 mytasklist
:mouse_add(mouse
.new({ }, 1, function (object
, c
) c
:focus_set(); c
:raise() end))
86 mytasklist
:mouse_add(mouse
.new({ }, 4, function () awful
.client
.focus(1) end))
87 mytasklist
:mouse_add(mouse
.new({ }, 5, function () awful
.client
.focus(-1) end))
88 mytasklist
:set("text_focus", "<bg color='"..bg_focus
.."'/> <span color='"..fg_focus
.."'><title/></span> ")
90 -- Create a textbox widget
91 mytextbox
= widget
.new({ type = "textbox", name
= "mytextbox", align
= "right" })
92 -- Set the default text in textbox
93 mytextbox
:set("text", "<b><small> awesome " .. AWESOME_VERSION
.. " </small></b>")
94 mymenubox
= widget
.new({ type = "textbox", name
= "mymenubox", align
= "left" })
96 -- Create an iconbox widget
97 myiconbox
= widget
.new({ type = "iconbox", name
= "myiconbox", align
= "left" })
98 myiconbox
:set("image", "@AWESOME_ICON_PATH@/awesome16.png")
101 mysystray
= widget
.new({ type = "systray", name
= "mysystray", align
= "right" })
103 -- Create an iconbox widget which will contains an icon indicating which layout we're using.
104 -- We need one layoutbox per screen.
106 for s
= 1, screen
.count() do
107 mylayoutbox
[s
] = widget
.new({ type = "iconbox", name
= "mylayoutbox", align
= "right" })
108 mylayoutbox
[s
]:mouse_add(mouse
.new({ }, 1, function () awful
.layout
.inc(layouts
, 1) end))
109 mylayoutbox
[s
]:mouse_add(mouse
.new({ }, 3, function () awful
.layout
.inc(layouts
, -1) end))
110 mylayoutbox
[s
]:mouse_add(mouse
.new({ }, 4, function () awful
.layout
.inc(layouts
, 1) end))
111 mylayoutbox
[s
]:mouse_add(mouse
.new({ }, 5, function () awful
.layout
.inc(layouts
, -1) end))
112 mylayoutbox
[s
]:set("image", "@AWESOME_ICON_PATH@/layouts/tilew.png")
115 -- Create a statusbar for each screen and add it
117 for s
= 1, screen
.count() do
118 mystatusbar
[s
] = statusbar
.new({ position
= "top", name
= "mystatusbar" .. s
,
119 fg
= fg_normal
, bg
= bg_normal
})
120 -- Add widgets to the statusbar - order matters
121 mystatusbar
[s
]:widget_add(mytaglist
)
122 mystatusbar
[s
]:widget_add(myiconbox
)
123 mystatusbar
[s
]:widget_add(mytasklist
)
124 mystatusbar
[s
]:widget_add(mymenubox
)
125 mystatusbar
[s
]:widget_add(mytextbox
)
126 mystatusbar
[s
]:widget_add(mylayoutbox
[s
])
127 mystatusbar
[s
]:add(s
)
129 mystatusbar
[screen
.count()]:widget_add(mysystray
)
132 -- {{{ Mouse bindings
133 awesome
.mouse_add(mouse
.new({ }, 3, function () awful
.spawn(terminal
) end))
134 awesome
.mouse_add(mouse
.new({ }, 4, awful
.tag.viewnext
))
135 awesome
.mouse_add(mouse
.new({ }, 5, awful
.tag.viewprev
))
140 -- Bind keyboard digits
141 -- Compute the maximum number of digit we need, limited to 9
143 for s
= 1, screen
.count() do
144 keynumber
= math
.min(9, math
.max(#tags
[s
], keynumber
));
147 for i
= 1, keynumber
do
148 keybinding
.new({ modkey
}, i
,
150 local screen
= mouse
.screen_get()
151 if tags
[screen
][i
] then
152 awful
.tag.viewonly(tags
[screen
][i
])
155 keybinding
.new({ modkey
, "Control" }, i
,
157 local screen
= mouse
.screen_get()
158 if tags
[screen
][i
] then
159 tags
[i
]:view(not tags
[screen
][i
]:isselected())
162 keybinding
.new({ modkey
, "Shift" }, i
,
164 local screen
= mouse
.screen_get()
165 if tags
[screen
][i
] then
166 awful
.client
.movetotag(tags
[screen
][i
])
169 keybinding
.new({ modkey
, "Control", "Shift" }, i
,
171 local screen
= mouse
.screen_get()
172 if tags
[screen
][i
] then
173 awful
.client
.toggletag(tags
[screen
][i
])
178 keybinding
.new({ modkey
}, "Left", awful
.tag.viewprev
):add()
179 keybinding
.new({ modkey
}, "Right", awful
.tag.viewnext
):add()
182 keybinding
.new({ modkey
}, "Return", function () awful
.spawn(terminal
) end):add()
184 keybinding
.new({ modkey
, "Control" }, "r", awesome
.restart
):add()
185 keybinding
.new({ modkey
, "Shift" }, "q", awesome
.quit
):add()
187 -- Client manipulation
188 keybinding
.new({ modkey
, "Shift" }, "c", function () client
.focus_get():kill() end):add()
189 keybinding
.new({ modkey
}, "j", function () awful
.client
.focus(1); client
.focus_get():raise() end):add()
190 keybinding
.new({ modkey
}, "k", function () awful
.client
.focus(-1); client
.focus_get():raise() end):add()
191 keybinding
.new({ modkey
, "Shift" }, "j", function () awful
.client
.swap(1) end):add()
192 keybinding
.new({ modkey
, "Shift" }, "k", function () awful
.client
.swap(-1) end):add()
193 keybinding
.new({ modkey
, "Control" }, "j", function () awful
.screen
.focus(1) end):add()
194 keybinding
.new({ modkey
, "Control" }, "k", function () awful
.screen
.focus(-1) end):add()
195 keybinding
.new({ modkey
, "Control" }, "space", awful
.client
.togglefloating
):add()
196 keybinding
.new({ modkey
, "Control" }, "Return", function () client
.focus_get():swap(awful
.client
.master()) end):add()
197 keybinding
.new({ modkey
}, "o", awful
.client
.movetoscreen
):add()
199 -- Layout manipulation
200 keybinding
.new({ modkey
}, "l", function () awful
.tag.incmwfact(0.05) end):add()
201 keybinding
.new({ modkey
}, "h", function () awful
.tag.incmwfact(-0.05) end):add()
202 keybinding
.new({ modkey
, "Shift" }, "h", function () awful
.tag.incnmaster(1) end):add()
203 keybinding
.new({ modkey
, "Shift" }, "l", function () awful
.tag.incnmaster(-1) end):add()
204 keybinding
.new({ modkey
, "Control" }, "h", function () awful
.tag.incncol(1) end):add()
205 keybinding
.new({ modkey
, "Control" }, "l", function () awful
.tag.incncol(-1) end):add()
206 keybinding
.new({ modkey
}, "space", function () awful
.layout
.inc(layouts
, 1) end):add()
207 keybinding
.new({ modkey
, "Shift" }, "space", function () awful
.layout
.inc(layouts
, -1) end):add()
210 keybinding
.new({ modkey
}, "F1", function ()
211 awful
.menu({ prompt
= "Run: ", cursor_fg
= fg_focus
, cursor_bg
= bg_focus
}, mymenubox
, awful
.spawn
, awful
.completion
.bash
)
213 keybinding
.new({ modkey
}, "F4", function ()
214 awful
.menu({ prompt
= "Run Lua code: ", cursor_fg
= fg_focus
, cursor_bg
= bg_focus
}, mymenubox
, awful
.eval
, awful
.completion
.bash
)
217 --- Tabulous, tab manipulation
218 keybinding
.new({ modkey
, "Control" }, "y", function ()
219 local tabbedview
= tabulous
.tabindex_get()
220 local nextclient
= awful
.client
.next(1)
222 if tabbedview
== nil then
223 tabbedview
= tabulous
.tabindex_get(nextclient
)
225 if tabbedview
== nil then
226 tabbedview
= tabulous
.tab_create()
227 tabulous
.tab(tabbedview
, nextclient
)
229 tabulous
.tab(tabbedview
, client
.focus_get())
232 tabulous
.tab(tabbedview
, nextclient
)
236 keybinding
.new({ modkey
, "Shift" }, "y", tabulous
.untab
):add()
238 keybinding
.new({ modkey
}, "y", function ()
239 local tabbedview
= tabulous
.tabindex_get()
241 if tabbedview
~= nil then
242 local n
= tabulous
.next(tabbedview
)
243 tabulous
.display(tabbedview
, n
)
247 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
248 keybinding
.new({ modkey
}, "t", awful
.client
.togglemarked
):add()
249 keybinding
.new({ modkey
, 'Shift' }, "t", function ()
250 local tabbedview
= tabulous
.tabindex_get()
251 local clients
= awful
.client
.getmarked()
253 if tabbedview
== nil then
254 tabbedview
= tabulous
.tab_create(clients
[1])
255 table.remove(clients
, 1)
258 for k
,c
in pairs(clients
) do
259 tabulous
.tab(tabbedview
, c
)
264 for i
= 1, keynumber
do
265 keybinding
.new({ modkey
, "Shift" }, "F" .. i
,
267 local screen
= mouse
.screen_get()
268 if tags
[screen
][i
] then
269 for k
, c
in pairs(awful
.client
.getmarked()) do
270 awful
.client
.movetotag(tags
[screen
][i
], c
)
278 -- Hook function to execute when focusing a client.
279 function hook_focus(c
)
280 if not awful
.client
.ismarked(c
) then
281 c
:border_set({ width
= border_width
, color
= border_focus
})
285 -- Hook function to execute when unfocusing a client.
286 function hook_unfocus(c
)
287 if not awful
.client
.ismarked(c
) then
288 c
:border_set({ width
= border_width
, color
= border_normal
})
292 -- Hook function to execute when marking a client
293 function hook_marked(c
)
294 c
:border_set({ width
= border_width
, color
= border_marked
})
297 -- Hook function to execute when unmarking a client
298 function hook_unmarked(c
)
299 c
:border_set({ width
= border_width
, color
= border_focus
})
302 -- Hook function to execute when the mouse is over a client.
303 function hook_mouseover(c
)
304 -- Sloppy focus, but disabled for magnifier layout
305 if awful
.layout
.get(c
:screen_get()) ~= "magnifier" then
310 -- Hook function to execute when a new client appears.
311 function hook_manage(c
)
312 -- Add mouse bindings
313 c
:mouse_add(mouse
.new({ }, 1, function (c
) c
:focus_set(); c
:raise() end))
314 c
:mouse_add(mouse
.new({ modkey
}, 1, function (c
) c
:mouse_move() end))
315 c
:mouse_add(mouse
.new({ modkey
}, 3, function (c
) c
:mouse_resize() end))
316 -- New client may not receive focus
317 -- if they're not focusable, so set border anyway.
318 c
:border_set({ width
= border_width
, color
= border_normal
})
320 if c
:name_get():lower():find("pinentry") then
323 if c
:name_get():find("mplayer") then
328 -- Hook function to execute when arranging the screen
329 -- (tag switch, new client, etc)
330 function hook_arrange(screen
)
331 local layout
= awful
.layout
.get(screen
)
332 mylayoutbox
[screen
]:set("image", "@AWESOME_ICON_PATH@/layouts/" .. layout
.. "w.png")
334 -- Uncomment if you want mouse warping
336 local sel = client.focus_get()
338 local c_c = sel:coords_get()
339 local m_c = mouse.coords_get()
341 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
342 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
343 if table.maxn(m_c.buttons) == 0 then
344 mouse.coords_set(c_c.x + 5, c_c.y + 5)
351 -- Hook called every second
352 function hook_timer ()
353 -- For unix time_t lovers
354 mytextbox
:set("text", " " .. os
.time() .. " time_t ")
356 -- mytextbox:set("text", " " .. os.date() .. " ")
360 awful
.hooks
.focus(hook_focus
)
361 awful
.hooks
.unfocus(hook_unfocus
)
362 awful
.hooks
.marked(hook_marked
)
363 awful
.hooks
.unmarked(hook_unmarked
)
364 awful
.hooks
.manage(hook_manage
)
365 awful
.hooks
.mouseover(hook_mouseover
)
366 awful
.hooks
.arrange(hook_arrange
)
367 awful
.hooks
.timer(1, hook_timer
)