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
= { button({ }, 1, awful
.tag.viewonly
),
120 button({ modkey
}, 1, awful
.client
.movetotag
),
121 button({ }, 3, function (tag) tag.selected
= not tag.selected
end),
122 button({ modkey
}, 3, awful
.client
.toggletag
),
123 button({ }, 4, awful
.tag.viewnext
),
124 button({ }, 5, awful
.tag.viewprev
) }
126 mytasklist
.buttons
= { button({ }, 1, function (c
)
127 if not c
:isvisible() then
128 awful
.tag.viewonly(c
:tags()[1])
133 button({ }, 3, function () if instance
then instance
:hide() instance
= nil else instance
= awful
.menu
.clients({ width
=250 }) end end),
134 button({ }, 4, function ()
135 awful
.client
.focus
.byidx(1)
136 if client
.focus
then client
.focus
:raise() end
138 button({ }, 5, function ()
139 awful
.client
.focus
.byidx(-1)
140 if client
.focus
then client
.focus
:raise() end
143 for s
= 1, screen
.count() do
144 -- Create a promptbox for each screen
145 mypromptbox
[s
] = widget({ type = "textbox", align
= "left" })
146 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
147 -- We need one layoutbox per screen.
148 mylayoutbox
[s
] = widget({ type = "imagebox", align
= "right" })
149 mylayoutbox
[s
]:buttons({ button({ }, 1, function () awful
.layout
.inc(layouts
, 1) end),
150 button({ }, 3, function () awful
.layout
.inc(layouts
, -1) end),
151 button({ }, 4, function () awful
.layout
.inc(layouts
, 1) end),
152 button({ }, 5, function () awful
.layout
.inc(layouts
, -1) end) })
153 -- Create a taglist widget
154 mytaglist
[s
] = awful
.widget
.taglist
.new(s
, awful
.widget
.taglist
.label
.all
, mytaglist
.buttons
)
156 -- Create a tasklist widget
157 mytasklist
[s
] = awful
.widget
.tasklist
.new(function(c
)
158 return awful
.widget
.tasklist
.label
.currenttags(c
, s
)
159 end, mytasklist
.buttons
)
162 mywibox
[s
] = wibox({ position
= "top", fg
= beautiful
.fg_normal
, bg
= beautiful
.bg_normal
})
163 -- Add widgets to the wibox - order matters
164 mywibox
[s
].widgets
= { mylauncher
,
170 s
== 1 and mysystray
or nil }
171 mywibox
[s
].screen
= s
175 -- {{{ Mouse bindings
177 button({ }, 3, function () mymainmenu
:toggle() end),
178 button({ }, 4, awful
.tag.viewnext
),
179 button({ }, 5, awful
.tag.viewprev
)
186 key({ modkey
, }, "Left", awful
.tag.viewprev
),
187 key({ modkey
, }, "Right", awful
.tag.viewnext
),
188 key({ modkey
, }, "Escape", awful
.tag.history
.restore
),
190 key({ modkey
, }, "j",
192 awful
.client
.focus
.byidx( 1)
193 if client
.focus
then client
.focus
:raise() end
195 key({ modkey
, }, "k",
197 awful
.client
.focus
.byidx(-1)
198 if client
.focus
then client
.focus
:raise() end
200 key({ modkey
, }, "w", function () mymainmenu
:show(true) end),
202 -- Layout manipulation
203 key({ modkey
, "Shift" }, "j", function () awful
.client
.swap
.byidx( 1) end),
204 key({ modkey
, "Shift" }, "k", function () awful
.client
.swap
.byidx( -1) end),
205 key({ modkey
, "Control" }, "j", function () awful
.screen
.focus( 1) end),
206 key({ modkey
, "Control" }, "k", function () awful
.screen
.focus(-1) end),
207 key({ modkey
, }, "u", awful
.client
.urgent
.jumpto
),
208 key({ modkey
, }, "Tab",
210 awful
.client
.focus
.history
.previous()
217 key({ modkey
, }, "Return", function () awful
.util
.spawn(terminal
) end),
218 key({ modkey
, "Control" }, "r", awesome
.restart
),
219 key({ modkey
, "Shift" }, "q", awesome
.quit
),
221 key({ modkey
, }, "l", function () awful
.tag.incmwfact( 0.05) end),
222 key({ modkey
, }, "h", function () awful
.tag.incmwfact(-0.05) end),
223 key({ modkey
, "Shift" }, "h", function () awful
.tag.incnmaster( 1) end),
224 key({ modkey
, "Shift" }, "l", function () awful
.tag.incnmaster(-1) end),
225 key({ modkey
, "Control" }, "h", function () awful
.tag.incncol( 1) end),
226 key({ modkey
, "Control" }, "l", function () awful
.tag.incncol(-1) end),
227 key({ modkey
, }, "space", function () awful
.layout
.inc(layouts
, 1) end),
228 key({ modkey
, "Shift" }, "space", function () awful
.layout
.inc(layouts
, -1) end),
231 key({ modkey
}, "F1",
233 awful
.prompt
.run({ prompt
= "Run: " },
234 mypromptbox
[mouse
.screen
],
235 awful
.util
.spawn
, awful
.completion
.shell
,
236 awful
.util
.getdir("cache") .. "/history")
239 key({ modkey
}, "F4",
241 awful
.prompt
.run({ prompt
= "Run Lua code: " },
242 mypromptbox
[mouse
.screen
],
243 awful
.util
.eval
, nil,
244 awful
.util
.getdir("cache") .. "/history_eval")
248 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
251 key({ modkey
, }, "f", function (c
) c
.fullscreen
= not c
.fullscreen
end),
252 key({ modkey
, "Shift" }, "c", function (c
) c
:kill() end),
253 key({ modkey
, "Control" }, "space", awful
.client
.floating
.toggle
),
254 key({ modkey
, "Control" }, "Return", function (c
) c
:swap(awful
.client
.getmaster()) end),
255 key({ modkey
, }, "o", awful
.client
.movetoscreen
),
256 key({ modkey
, "Shift" }, "r", function (c
) c
:redraw() end),
257 key({ modkey
}, "t", awful
.client
.togglemarked
),
260 c
.maximized_horizontal
= not c
.maximized_horizontal
261 c
.maximized_vertical
= not c
.maximized_vertical
265 -- Compute the maximum number of digit we need, limited to 9
267 for s
= 1, screen
.count() do
268 keynumber
= math
.min(9, math
.max(#tags
[s
], keynumber
));
271 for i
= 1, keynumber
do
272 table.insert(globalkeys
,
275 local screen
= mouse
.screen
276 if tags
[screen
][i
] then
277 awful
.tag.viewonly(tags
[screen
][i
])
280 table.insert(globalkeys
,
281 key({ modkey
, "Control" }, i
,
283 local screen
= mouse
.screen
284 if tags
[screen
][i
] then
285 tags
[screen
][i
].selected
= not tags
[screen
][i
].selected
288 table.insert(globalkeys
,
289 key({ modkey
, "Shift" }, i
,
291 if client
.focus
and tags
[client
.focus
.screen
][i
] then
292 awful
.client
.movetotag(tags
[client
.focus
.screen
][i
])
295 table.insert(globalkeys
,
296 key({ modkey
, "Control", "Shift" }, i
,
298 if client
.focus
and tags
[client
.focus
.screen
][i
] then
299 awful
.client
.toggletag(tags
[client
.focus
.screen
][i
])
302 table.insert(globalkeys
,
303 key({ 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 root
.keys(globalkeys
)
320 -- Hook function to execute when focusing a client.
321 awful
.hooks
.focus
.register(function (c
)
322 if not awful
.client
.ismarked(c
) then
323 c
.border_color
= beautiful
.border_focus
327 -- Hook function to execute when unfocusing a client.
328 awful
.hooks
.unfocus
.register(function (c
)
329 if not awful
.client
.ismarked(c
) then
330 c
.border_color
= beautiful
.border_normal
334 -- Hook function to execute when marking a client
335 awful
.hooks
.marked
.register(function (c
)
336 c
.border_color
= beautiful
.border_marked
339 -- Hook function to execute when unmarking a client.
340 awful
.hooks
.unmarked
.register(function (c
)
341 c
.border_color
= beautiful
.border_focus
344 -- Hook function to execute when the mouse enters a client.
345 awful
.hooks
.mouse_enter
.register(function (c
)
346 -- Sloppy focus, but disabled for magnifier layout
347 if awful
.layout
.get(c
.screen
) ~= awful
.layout
.suit
.magnifier
348 and awful
.client
.focus
.filter(c
) then
353 -- Hook function to execute when a new client appears.
354 awful
.hooks
.manage
.register(function (c
, startup
)
355 -- If we are not managing this application at startup,
356 -- move it to the screen where the mouse is.
357 -- We only do it for filtered windows (i.e. no dock, etc).
358 if not startup
and awful
.client
.focus
.filter(c
) then
359 c
.screen
= mouse
.screen
364 awful
.titlebar
.add(c
, { modkey
= modkey
})
366 -- Add mouse bindings
368 button({ }, 1, function (c
) client
.focus
= c
; c
:raise() end),
369 button({ modkey
}, 1, awful
.mouse
.client
.move
),
370 button({ modkey
}, 3, awful
.mouse
.client
.resize
)
372 -- New client may not receive focus
373 -- if they're not focusable, so set border anyway.
374 c
.border_width
= beautiful
.border_width
375 c
.border_color
= beautiful
.border_normal
377 -- Check if the application should be floating.
379 local inst
= c
.instance
380 if floatapps
[cls
] then
381 awful
.client
.floating
.set(c
, floatapps
[cls
])
382 elseif floatapps
[inst
] then
383 awful
.client
.floating
.set(c
, floatapps
[inst
])
386 -- Check application->screen/tag mappings.
389 target
= apptags
[cls
]
390 elseif apptags
[inst
] then
391 target
= apptags
[inst
]
394 c
.screen
= target
.screen
395 awful
.client
.movetotag(tags
[target
.screen
][target
.tag], c
)
398 -- Do this after tag mapping, so you don't see it on the wrong tag for a split second.
404 -- Set the windows at the slave,
405 -- i.e. put it at the end of others instead of setting it master.
406 -- awful.client.setslave(c)
408 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
409 -- c.size_hints_honor = false
412 -- Hook function to execute when arranging the screen.
413 -- (tag switch, new client, etc)
414 awful
.hooks
.arrange
.register(function (screen
)
415 local layout
= awful
.layout
.getname(awful
.layout
.get(screen
))
416 if layout
and beautiful
["layout_" ..layout
] then
417 mylayoutbox
[screen
].image
= image(beautiful
["layout_" .. layout
])
419 mylayoutbox
[screen
].image
= nil
422 -- Give focus to the latest client in history if no window has focus
423 -- or if the current window is a desktop or a dock one.
424 if not client
.focus
then
425 local c
= awful
.client
.focus
.history
.get(screen
, 0)
426 if c
then client
.focus
= c
end
430 -- Hook called every minute
431 awful
.hooks
.timer
.register(60, function ()
432 mytextbox
.text
= os
.date(" %a %b %d, %H:%M ")