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
= awful
.util
.table.join(
120 awful
.button({ }, 1, awful
.tag.viewonly
),
121 awful
.button({ modkey
}, 1, awful
.client
.movetotag
),
122 awful
.button({ }, 3, function (tag) tag.selected
= not tag.selected
end),
123 awful
.button({ modkey
}, 3, awful
.client
.toggletag
),
124 awful
.button({ }, 4, awful
.tag.viewnext
),
125 awful
.button({ }, 5, awful
.tag.viewprev
)
128 mytasklist
.buttons
= awful
.util
.table.join(
129 awful
.button({ }, 1, function (c
)
130 if not c
:isvisible() then
131 awful
.tag.viewonly(c
:tags()[1])
136 awful
.button({ }, 3, function ()
141 instance
= awful
.menu
.clients({ width
=250 })
144 awful
.button({ }, 4, function ()
145 awful
.client
.focus
.byidx(1)
146 if client
.focus
then client
.focus
:raise() end
148 awful
.button({ }, 5, function ()
149 awful
.client
.focus
.byidx(-1)
150 if client
.focus
then client
.focus
:raise() end
153 for s
= 1, screen
.count() do
154 -- Create a promptbox for each screen
155 mypromptbox
[s
] = widget({ type = "textbox", align
= "left" })
156 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
157 -- We need one layoutbox per screen.
158 mylayoutbox
[s
] = widget({ type = "imagebox", align
= "right" })
159 mylayoutbox
[s
]:buttons(awful
.util
.table.join(
160 awful
.button({ }, 1, function () awful
.layout
.inc(layouts
, 1) end),
161 awful
.button({ }, 3, function () awful
.layout
.inc(layouts
, -1) end),
162 awful
.button({ }, 4, function () awful
.layout
.inc(layouts
, 1) end),
163 awful
.button({ }, 5, function () awful
.layout
.inc(layouts
, -1) end)))
164 -- Create a taglist widget
165 mytaglist
[s
] = awful
.widget
.taglist
.new(s
, awful
.widget
.taglist
.label
.all
, mytaglist
.buttons
)
167 -- Create a tasklist widget
168 mytasklist
[s
] = awful
.widget
.tasklist
.new(function(c
)
169 return awful
.widget
.tasklist
.label
.currenttags(c
, s
)
170 end, mytasklist
.buttons
)
173 mywibox
[s
] = wibox({ position
= "top", fg
= beautiful
.fg_normal
, bg
= beautiful
.bg_normal
})
174 -- Add widgets to the wibox - order matters
175 mywibox
[s
].widgets
= { mylauncher
,
181 s
== 1 and mysystray
or nil }
182 mywibox
[s
].screen
= s
186 -- {{{ Mouse bindings
187 root
.buttons(awful
.util
.table.join(
188 awful
.button({ }, 3, function () mymainmenu
:toggle() end),
189 awful
.button({ }, 4, awful
.tag.viewnext
),
190 awful
.button({ }, 5, awful
.tag.viewprev
)
195 globalkeys
= awful
.util
.table.join(
196 awful
.key({ modkey
, }, "Left", awful
.tag.viewprev
),
197 awful
.key({ modkey
, }, "Right", awful
.tag.viewnext
),
198 awful
.key({ modkey
, }, "Escape", awful
.tag.history
.restore
),
200 awful
.key({ modkey
, }, "j",
202 awful
.client
.focus
.byidx( 1)
203 if client
.focus
then client
.focus
:raise() end
205 awful
.key({ modkey
, }, "k",
207 awful
.client
.focus
.byidx(-1)
208 if client
.focus
then client
.focus
:raise() end
210 awful
.key({ modkey
, }, "w", function () mymainmenu
:show(true) end),
212 -- Layout manipulation
213 awful
.key({ modkey
, "Shift" }, "j", function () awful
.client
.swap
.byidx( 1) end),
214 awful
.key({ modkey
, "Shift" }, "k", function () awful
.client
.swap
.byidx( -1) end),
215 awful
.key({ modkey
, "Control" }, "j", function () awful
.screen
.focus( 1) end),
216 awful
.key({ modkey
, "Control" }, "k", function () awful
.screen
.focus(-1) end),
217 awful
.key({ modkey
, }, "u", awful
.client
.urgent
.jumpto
),
218 awful
.key({ modkey
, }, "Tab",
220 awful
.client
.focus
.history
.previous()
227 awful
.key({ modkey
, }, "Return", function () awful
.util
.spawn(terminal
) end),
228 awful
.key({ modkey
, "Control" }, "r", awesome
.restart
),
229 awful
.key({ modkey
, "Shift" }, "q", awesome
.quit
),
231 awful
.key({ modkey
, }, "l", function () awful
.tag.incmwfact( 0.05) end),
232 awful
.key({ modkey
, }, "h", function () awful
.tag.incmwfact(-0.05) end),
233 awful
.key({ modkey
, "Shift" }, "h", function () awful
.tag.incnmaster( 1) end),
234 awful
.key({ modkey
, "Shift" }, "l", function () awful
.tag.incnmaster(-1) end),
235 awful
.key({ modkey
, "Control" }, "h", function () awful
.tag.incncol( 1) end),
236 awful
.key({ modkey
, "Control" }, "l", function () awful
.tag.incncol(-1) end),
237 awful
.key({ modkey
, }, "space", function () awful
.layout
.inc(layouts
, 1) end),
238 awful
.key({ modkey
, "Shift" }, "space", function () awful
.layout
.inc(layouts
, -1) end),
241 awful
.key({ modkey
}, "r",
243 awful
.prompt
.run({ prompt
= "Run: " },
244 mypromptbox
[mouse
.screen
],
245 awful
.util
.spawn
, awful
.completion
.shell
,
246 awful
.util
.getdir("cache") .. "/history")
249 awful
.key({ modkey
}, "x",
251 awful
.prompt
.run({ prompt
= "Run Lua code: " },
252 mypromptbox
[mouse
.screen
],
253 awful
.util
.eval
, nil,
254 awful
.util
.getdir("cache") .. "/history_eval")
258 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
259 clientkeys
= awful
.util
.table.join(
260 awful
.key({ modkey
, }, "f", function (c
) c
.fullscreen
= not c
.fullscreen
end),
261 awful
.key({ modkey
, "Shift" }, "c", function (c
) c
:kill() end),
262 awful
.key({ modkey
, "Control" }, "space", awful
.client
.floating
.toggle
),
263 awful
.key({ modkey
, "Control" }, "Return", function (c
) c
:swap(awful
.client
.getmaster()) end),
264 awful
.key({ modkey
, }, "o", awful
.client
.movetoscreen
),
265 awful
.key({ modkey
, "Shift" }, "r", function (c
) c
:redraw() end),
266 awful
.key({ modkey
}, "t", awful
.client
.togglemarked
),
267 awful
.key({ modkey
,}, "m",
269 c
.maximized_horizontal
= not c
.maximized_horizontal
270 c
.maximized_vertical
= not c
.maximized_vertical
274 -- Compute the maximum number of digit we need, limited to 9
276 for s
= 1, screen
.count() do
277 keynumber
= math
.min(9, math
.max(#tags
[s
], keynumber
));
280 for i
= 1, keynumber
do
281 table.foreach(awful
.key({ modkey
}, i
,
283 local screen
= mouse
.screen
284 if tags
[screen
][i
] then
285 awful
.tag.viewonly(tags
[screen
][i
])
287 end), function(_
, k
) table.insert(globalkeys
, k
) end)
288 table.foreach(awful
.key({ modkey
, "Control" }, i
,
290 local screen
= mouse
.screen
291 if tags
[screen
][i
] then
292 tags
[screen
][i
].selected
= not tags
[screen
][i
].selected
294 end), function(_
, k
) table.insert(globalkeys
, k
) end)
295 table.foreach(awful
.key({ modkey
, "Shift" }, i
,
297 if client
.focus
and tags
[client
.focus
.screen
][i
] then
298 awful
.client
.movetotag(tags
[client
.focus
.screen
][i
])
300 end), function(_
, k
) table.insert(globalkeys
, k
) end)
301 table.foreach(awful
.key({ modkey
, "Control", "Shift" }, i
,
303 if client
.focus
and tags
[client
.focus
.screen
][i
] then
304 awful
.client
.toggletag(tags
[client
.focus
.screen
][i
])
306 end), function(_
, k
) table.insert(globalkeys
, k
) end)
307 table.foreach(awful
.key({ modkey
, "Shift" }, "F" .. i
,
309 local screen
= mouse
.screen
310 if tags
[screen
][i
] then
311 for k
, c
in pairs(awful
.client
.getmarked()) do
312 awful
.client
.movetotag(tags
[screen
][i
], c
)
315 end), function(_
, k
) table.insert(globalkeys
, k
) end)
319 root
.keys(globalkeys
)
323 -- Hook function to execute when focusing a client.
324 awful
.hooks
.focus
.register(function (c
)
325 if not awful
.client
.ismarked(c
) then
326 c
.border_color
= beautiful
.border_focus
330 -- Hook function to execute when unfocusing a client.
331 awful
.hooks
.unfocus
.register(function (c
)
332 if not awful
.client
.ismarked(c
) then
333 c
.border_color
= beautiful
.border_normal
337 -- Hook function to execute when marking a client
338 awful
.hooks
.marked
.register(function (c
)
339 c
.border_color
= beautiful
.border_marked
342 -- Hook function to execute when unmarking a client.
343 awful
.hooks
.unmarked
.register(function (c
)
344 c
.border_color
= beautiful
.border_focus
347 -- Hook function to execute when the mouse enters a client.
348 awful
.hooks
.mouse_enter
.register(function (c
)
349 -- Sloppy focus, but disabled for magnifier layout
350 if awful
.layout
.get(c
.screen
) ~= awful
.layout
.suit
.magnifier
351 and awful
.client
.focus
.filter(c
) then
356 -- Hook function to execute when a new client appears.
357 awful
.hooks
.manage
.register(function (c
, startup
)
358 -- If we are not managing this application at startup,
359 -- move it to the screen where the mouse is.
360 -- We only do it for filtered windows (i.e. no dock, etc).
361 if not startup
and awful
.client
.focus
.filter(c
) then
362 c
.screen
= mouse
.screen
367 awful
.titlebar
.add(c
, { modkey
= modkey
})
369 -- Add mouse bindings
370 c
:buttons(awful
.util
.table.join(
371 awful
.button({ }, 1, function (c
) client
.focus
= c
; c
:raise() end),
372 awful
.button({ modkey
}, 1, awful
.mouse
.client
.move
),
373 awful
.button({ modkey
}, 3, awful
.mouse
.client
.resize
)
375 -- New client may not receive focus
376 -- if they're not focusable, so set border anyway.
377 c
.border_width
= beautiful
.border_width
378 c
.border_color
= beautiful
.border_normal
380 -- Check if the application should be floating.
382 local inst
= c
.instance
383 if floatapps
[cls
] then
384 awful
.client
.floating
.set(c
, floatapps
[cls
])
385 elseif floatapps
[inst
] then
386 awful
.client
.floating
.set(c
, floatapps
[inst
])
389 -- Check application->screen/tag mappings.
392 target
= apptags
[cls
]
393 elseif apptags
[inst
] then
394 target
= apptags
[inst
]
397 c
.screen
= target
.screen
398 awful
.client
.movetotag(tags
[target
.screen
][target
.tag], c
)
401 -- Do this after tag mapping, so you don't see it on the wrong tag for a split second.
407 -- Set the windows at the slave,
408 -- i.e. put it at the end of others instead of setting it master.
409 -- awful.client.setslave(c)
411 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
412 -- c.size_hints_honor = false
415 -- Hook function to execute when arranging the screen.
416 -- (tag switch, new client, etc)
417 awful
.hooks
.arrange
.register(function (screen
)
418 local layout
= awful
.layout
.getname(awful
.layout
.get(screen
))
419 if layout
and beautiful
["layout_" ..layout
] then
420 mylayoutbox
[screen
].image
= image(beautiful
["layout_" .. layout
])
422 mylayoutbox
[screen
].image
= nil
425 -- Give focus to the latest client in history if no window has focus
426 -- or if the current window is a desktop or a dock one.
427 if not client
.focus
then
428 local c
= awful
.client
.focus
.history
.get(screen
, 0)
429 if c
then client
.focus
= c
end
433 -- Hook called every minute
434 awful
.hooks
.timer
.register(60, function ()
435 mytextbox
.text
= os
.date(" %a %b %d, %H:%M ")