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.
39 -- Table of clients that should be set floating. The index may be either
40 -- the application class or instance. The instance is useful when running
41 -- a console app in a terminal like (Music on Console)
42 -- xterm -name mocp -e mocp
53 -- Applications to be moved to a pre-defined tag by class or instance.
54 -- Use the screen and tags indices.
57 -- ["Firefox"] = { screen = 1, tag = 2 },
58 -- ["mocp"] = { screen = 2, tag = 4 },
61 -- Define if we want to use titlebar on all applications.
66 -- Initialize theme (colors).
67 beautiful
.init(theme_path
)
69 -- Register theme in awful.
70 -- This allows to not pass plenty of arguments to each function
71 -- to inform it about colors we want it to draw.
72 awful
.beautiful
.register(beautiful
)
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" })
99 button({ }, 1, function (object
, tag) awful
.tag.viewonly(tag) end),
100 button({ modkey
}, 1, function (object
, tag) awful
.client
.movetotag(tag) end),
101 button({ }, 3, function (object
, tag) tag.selected
= not tag.selected
end),
102 button({ modkey
}, 3, function (object
, tag) awful
.client
.toggletag(tag) end),
103 button({ }, 4, awful
.tag.viewnext
),
104 button({ }, 5, awful
.tag.viewprev
)
106 mytaglist
.label
= awful
.widget
.taglist
.label
.all
108 -- Create a tasklist widget
109 mytasklist
= widget({ type = "tasklist", name
= "mytasklist" })
111 button({ }, 1, function (object
, c
) client
.focus
= c
; c
:raise() end),
112 button({ }, 4, function () awful
.client
.focus
.byidx(1) end),
113 button({ }, 5, function () awful
.client
.focus
.byidx(-1) end)
115 mytasklist
.label
= awful
.widget
.tasklist
.label
.currenttags
117 -- Create a textbox widget
118 mytextbox
= widget({ type = "textbox", name
= "mytextbox", align
= "right" })
119 -- Set the default text in textbox
120 mytextbox
.text
= "<b><small> " .. AWESOME_RELEASE
.. " </small></b>"
122 -- Create a laucher widget
123 mylauncher
= awful
.widget
.launcher({ name
= "mylauncher",
124 image
= "@AWESOME_ICON_PATH@/awesome16.png",
125 command
= terminal
.. " -e man awesome"})
128 mysystray
= widget({ type = "systray", name
= "mysystray", align
= "right" })
130 -- Create an iconbox widget which will contains an icon indicating which layout we're using.
131 -- We need one layoutbox per screen.
133 for s
= 1, screen
.count() do
134 mylayoutbox
[s
] = widget({ type = "imagebox", name
= "mylayoutbox", align
= "right" })
135 mylayoutbox
[s
]:buttons({
136 button({ }, 1, function () awful
.layout
.inc(layouts
, 1) end),
137 button({ }, 3, function () awful
.layout
.inc(layouts
, -1) end),
138 button({ }, 4, function () awful
.layout
.inc(layouts
, 1) end),
139 button({ }, 5, function () awful
.layout
.inc(layouts
, -1) end)
141 mylayoutbox
[s
].image
= image("@AWESOME_ICON_PATH@/layouts/tilew.png")
144 -- Create a wibox for each screen and add it
147 for s
= 1, screen
.count() do
148 mywibox
[s
] = wibox({ position
= "top", name
= "mywibox" .. s
,
149 fg
= beautiful
.fg_normal
, bg
= beautiful
.bg_normal
})
150 mypromptbox
[s
] = widget({ type = "textbox", name
= "mypromptbox" .. s
, align
= "left" })
151 -- Add widgets to the wibox - order matters
159 s
== 1 and mysystray
or nil
161 mywibox
[s
].screen
= s
165 -- {{{ Mouse bindings
167 button({ }, 3, function () awful
.util
.spawn(terminal
) end),
168 button({ }, 4, awful
.tag.viewnext
),
169 button({ }, 5, awful
.tag.viewprev
)
175 -- Bind keyboard digits
176 -- Compute the maximum number of digit we need, limited to 9
178 for s
= 1, screen
.count() do
179 keynumber
= math
.min(9, math
.max(#tags
[s
], keynumber
));
182 for i
= 1, keynumber
do
183 keybinding({ modkey
}, i
,
185 local screen
= mouse
.screen
186 if tags
[screen
][i
] then
187 awful
.tag.viewonly(tags
[screen
][i
])
190 keybinding({ modkey
, "Control" }, i
,
192 local screen
= mouse
.screen
193 if tags
[screen
][i
] then
194 tags
[screen
][i
].selected
= not tags
[screen
][i
].selected
197 keybinding({ modkey
, "Shift" }, i
,
200 if tags
[client
.focus
.screen
][i
] then
201 awful
.client
.movetotag(tags
[client
.focus
.screen
][i
])
205 keybinding({ modkey
, "Control", "Shift" }, i
,
208 if tags
[client
.focus
.screen
][i
] then
209 awful
.client
.toggletag(tags
[client
.focus
.screen
][i
])
215 keybinding({ modkey
}, "Left", awful
.tag.viewprev
):add()
216 keybinding({ modkey
}, "Right", awful
.tag.viewnext
):add()
217 keybinding({ modkey
}, "Escape", awful
.tag.history
.restore
):add()
220 keybinding({ modkey
}, "Return", function () awful
.util
.spawn(terminal
) end):add()
222 keybinding({ modkey
, "Control" }, "r", function ()
223 mypromptbox
[mouse
.screen
].text
=
224 awful
.util
.escape(awful
.util
.restart())
226 keybinding({ modkey
, "Shift" }, "q", awesome
.quit
):add()
228 -- Client manipulation
229 keybinding({ modkey
}, "m", awful
.client
.maximize
):add()
230 keybinding({ modkey
}, "f", function () client
.focus
.fullscreen
= not client
.focus
.fullscreen
end):add()
231 keybinding({ modkey
, "Shift" }, "c", function () client
.focus
:kill() end):add()
232 keybinding({ modkey
}, "j", function () awful
.client
.focus
.byidx(1); client
.focus
:raise() end):add()
233 keybinding({ modkey
}, "k", function () awful
.client
.focus
.byidx(-1); client
.focus
:raise() end):add()
234 keybinding({ modkey
, "Shift" }, "j", function () awful
.client
.swap(1) end):add()
235 keybinding({ modkey
, "Shift" }, "k", function () awful
.client
.swap(-1) end):add()
236 keybinding({ modkey
, "Control" }, "j", function () awful
.screen
.focus(1) end):add()
237 keybinding({ modkey
, "Control" }, "k", function () awful
.screen
.focus(-1) end):add()
238 keybinding({ modkey
, "Control" }, "space", awful
.client
.togglefloating
):add()
239 keybinding({ modkey
, "Control" }, "Return", function () client
.focus
:swap(awful
.client
.master()) end):add()
240 keybinding({ modkey
}, "o", awful
.client
.movetoscreen
):add()
241 keybinding({ modkey
}, "Tab", awful
.client
.focus
.history
.previous
):add()
242 keybinding({ modkey
}, "u", awful
.client
.urgent
.jumpto
):add()
243 keybinding({ modkey
, "Shift" }, "r", function () client
.focus
:redraw() end):add()
245 -- Layout manipulation
246 keybinding({ modkey
}, "l", function () awful
.tag.incmwfact(0.05) end):add()
247 keybinding({ modkey
}, "h", function () awful
.tag.incmwfact(-0.05) end):add()
248 keybinding({ modkey
, "Shift" }, "h", function () awful
.tag.incnmaster(1) end):add()
249 keybinding({ modkey
, "Shift" }, "l", function () awful
.tag.incnmaster(-1) end):add()
250 keybinding({ modkey
, "Control" }, "h", function () awful
.tag.incncol(1) end):add()
251 keybinding({ modkey
, "Control" }, "l", function () awful
.tag.incncol(-1) end):add()
252 keybinding({ modkey
}, "space", function () awful
.layout
.inc(layouts
, 1) end):add()
253 keybinding({ modkey
, "Shift" }, "space", function () awful
.layout
.inc(layouts
, -1) end):add()
256 keybinding({ modkey
}, "F1", function ()
257 awful
.prompt
.run({ prompt
= "Run: " }, mypromptbox
[mouse
.screen
], awful
.util
.spawn
, awful
.completion
.bash
,
258 os
.getenv("HOME") .. "/.cache/awesome/history") end):add()
259 keybinding({ modkey
}, "F4", function ()
260 awful
.prompt
.run({ prompt
= "Run Lua code: " }, mypromptbox
[mouse
.screen
], awful
.util
.eval
, awful
.prompt
.bash
,
261 os
.getenv("HOME") .. "/.cache/awesome/history_eval") end):add()
262 keybinding({ modkey
, "Ctrl" }, "i", function ()
263 local s
= mouse
.screen
264 if mypromptbox
[s
].text
then
265 mypromptbox
[s
].text
= nil
267 mypromptbox
[s
].text
= nil
268 if client
.focus
.class
then
269 mypromptbox
[s
].text
= "Class: " .. client
.focus
.class
.. " "
271 if client
.focus
.instance
then
272 mypromptbox
[s
].text
= mypromptbox
[s
].text
.. "Instance: ".. client
.focus
.instance
.. " "
274 if client
.focus
.role
then
275 mypromptbox
[s
].text
= mypromptbox
[s
].text
.. "Role: ".. client
.focus
.role
280 --- Tabulous, tab manipulation
281 keybinding({ modkey
, "Control" }, "y", function ()
282 local tabbedview
= tabulous
.tabindex_get()
283 local nextclient
= awful
.client
.next(1)
285 if not tabbedview
then
286 tabbedview
= tabulous
.tabindex_get(nextclient
)
288 if not tabbedview
then
289 tabbedview
= tabulous
.tab_create()
290 tabulous
.tab(tabbedview
, nextclient
)
292 tabulous
.tab(tabbedview
, client
.focus
)
295 tabulous
.tab(tabbedview
, nextclient
)
299 keybinding({ modkey
, "Shift" }, "y", tabulous
.untab
):add()
301 keybinding({ modkey
}, "y", function ()
302 local tabbedview
= tabulous
.tabindex_get()
305 local n
= tabulous
.next(tabbedview
)
306 tabulous
.display(tabbedview
, n
)
310 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
311 keybinding({ modkey
}, "t", awful
.client
.togglemarked
):add()
312 keybinding({ modkey
, 'Shift' }, "t", function ()
313 local tabbedview
= tabulous
.tabindex_get()
314 local clients
= awful
.client
.getmarked()
316 if not tabbedview
then
317 tabbedview
= tabulous
.tab_create(clients
[1])
318 table.remove(clients
, 1)
321 for k
,c
in pairs(clients
) do
322 tabulous
.tab(tabbedview
, c
)
327 for i
= 1, keynumber
do
328 keybinding({ modkey
, "Shift" }, "F" .. i
,
330 local screen
= mouse
.screen
331 if tags
[screen
][i
] then
332 for k
, c
in pairs(awful
.client
.getmarked()) do
333 awful
.client
.movetotag(tags
[screen
][i
], c
)
341 -- Hook function to execute when focusing a client.
342 awful
.hooks
.focus
.register(function (c
)
343 if not awful
.client
.ismarked(c
) then
344 c
.border_color
= beautiful
.border_focus
348 -- Hook function to execute when unfocusing a client.
349 awful
.hooks
.unfocus
.register(function (c
)
350 if not awful
.client
.ismarked(c
) then
351 c
.border_color
= beautiful
.border_normal
355 -- Hook function to execute when marking a client
356 awful
.hooks
.marked
.register(function (c
)
357 c
.border_color
= beautiful
.border_marked
360 -- Hook function to execute when unmarking a client
361 awful
.hooks
.unmarked
.register(function (c
)
362 c
.border_color
= beautiful
.border_focus
365 -- Hook function to execute when the mouse is over a client.
366 awful
.hooks
.mouse_enter
.register(function (c
)
367 -- Sloppy focus, but disabled for magnifier layout
368 if awful
.layout
.get(c
.screen
) ~= "magnifier"
369 and awful
.client
.focus
.filter(c
) then
374 -- Hook function to execute when a new client appears.
375 awful
.hooks
.manage
.register(function (c
)
378 awful
.titlebar
.add(c
, { modkey
= modkey
})
380 -- Add mouse bindings
382 button({ }, 1, function (c
) client
.focus
= c
; c
:raise() end),
383 button({ modkey
}, 1, function (c
) c
:mouse_move() end),
384 button({ modkey
}, 3, function (c
) c
:mouse_resize() end)
386 -- New client may not receive focus
387 -- if they're not focusable, so set border anyway.
388 c
.border_width
= beautiful
.border_width
389 c
.border_color
= beautiful
.border_normal
392 -- Check if the application should be floating.
394 local inst
= c
.instance
395 if floatapps
[cls
] then
396 c
.floating
= floatapps
[cls
]
397 elseif floatapps
[inst
] then
398 c
.floating
= floatapps
[inst
]
401 -- Check application->screen/tag mappings.
404 target
= apptags
[cls
]
405 elseif apptags
[inst
] then
406 target
= apptags
[inst
]
409 c
.screen
= target
.screen
410 awful
.client
.movetotag(tags
[target
.screen
][target
.tag], c
)
413 -- Set the windows at the slave,
414 -- i.e. put it at the end of others instead of setting it master.
415 -- awful.client.setslave(c)
417 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
418 -- c.honorsizehints = false
421 -- Hook function to execute when arranging the screen
422 -- (tag switch, new client, etc)
423 awful
.hooks
.arrange
.register(function (screen
)
424 local layout
= awful
.layout
.get(screen
)
426 mylayoutbox
[screen
].image
= image("@AWESOME_ICON_PATH@/layouts/" .. layout
.. "w.png")
428 mylayoutbox
[screen
].image
= nil
431 -- Give focus to the latest client in history if no window has focus
432 -- or if the current window is a desktop or a dock one.
433 if not client
.focus
then
434 local c
= awful
.client
.focus
.history
.get(screen
, 0)
435 if c
then client
.focus
= c
end
438 -- Uncomment if you want mouse warping
441 local c_c = client.focus:coords()
442 local m_c = mouse.coords()
444 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
445 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
446 if table.maxn(m_c.buttons) == 0 then
447 mouse.coords({ x = c_c.x + 5, y = c_c.y + 5})
454 -- Hook called every second
455 awful
.hooks
.timer
.register(1, function ()
456 -- For unix time_t lovers
457 mytextbox
.text
= " " .. os
.time() .. " time_t "
459 -- mytextbox.text = " " .. os.date() .. " "