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
) client
.focus
= c
; c
:raise() end),
127 button({ }, 3, function () if instance
then instance
:hide() end instance
= awful
.menu
.clients({ width
=250 }) end),
128 button({ }, 4, function () awful
.client
.focus
.byidx(1) end),
129 button({ }, 5, function () awful
.client
.focus
.byidx(-1) end) }
131 for s
= 1, screen
.count() do
132 -- Create a promptbox for each screen
133 mypromptbox
[s
] = widget({ type = "textbox", align
= "left" })
134 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
135 -- We need one layoutbox per screen.
136 mylayoutbox
[s
] = widget({ type = "imagebox", align
= "right" })
137 mylayoutbox
[s
]:buttons({ button({ }, 1, function () awful
.layout
.inc(layouts
, 1) end),
138 button({ }, 3, function () awful
.layout
.inc(layouts
, -1) end),
139 button({ }, 4, function () awful
.layout
.inc(layouts
, 1) end),
140 button({ }, 5, function () awful
.layout
.inc(layouts
, -1) end) })
141 -- Create a taglist widget
142 mytaglist
[s
] = awful
.widget
.taglist
.new(s
, awful
.widget
.taglist
.label
.all
, mytaglist
.buttons
)
144 -- Create a tasklist widget
145 mytasklist
[s
] = awful
.widget
.tasklist
.new(function(c
)
146 return awful
.widget
.tasklist
.label
.currenttags(c
, s
)
147 end, mytasklist
.buttons
)
150 mywibox
[s
] = wibox({ position
= "top", fg
= beautiful
.fg_normal
, bg
= beautiful
.bg_normal
})
151 -- Add widgets to the wibox - order matters
152 mywibox
[s
].widgets
= { mylauncher
,
158 s
== 1 and mysystray
or nil }
159 mywibox
[s
].screen
= s
163 -- {{{ Mouse bindings
165 button({ }, 3, function () mymainmenu
:toggle() end),
166 button({ }, 4, awful
.tag.viewnext
),
167 button({ }, 5, awful
.tag.viewprev
)
172 -- Bind keyboard digits
173 -- Compute the maximum number of digit we need, limited to 9
175 for s
= 1, screen
.count() do
176 keynumber
= math
.min(9, math
.max(#tags
[s
], keynumber
));
182 for i
= 1, keynumber
do
183 table.insert(globalkeys
,
186 local screen
= mouse
.screen
187 if tags
[screen
][i
] then
188 awful
.tag.viewonly(tags
[screen
][i
])
191 table.insert(globalkeys
,
192 key({ modkey
, "Control" }, i
,
194 local screen
= mouse
.screen
195 if tags
[screen
][i
] then
196 tags
[screen
][i
].selected
= not tags
[screen
][i
].selected
199 table.insert(globalkeys
,
200 key({ modkey
, "Shift" }, i
,
202 if client
.focus
and tags
[client
.focus
.screen
][i
] then
203 awful
.client
.movetotag(tags
[client
.focus
.screen
][i
])
206 table.insert(globalkeys
,
207 key({ modkey
, "Control", "Shift" }, i
,
209 if client
.focus
and tags
[client
.focus
.screen
][i
] then
210 awful
.client
.toggletag(tags
[client
.focus
.screen
][i
])
215 table.insert(globalkeys
, key({ modkey
}, "Left", awful
.tag.viewprev
))
216 table.insert(globalkeys
, key({ modkey
}, "Right", awful
.tag.viewnext
))
217 table.insert(globalkeys
, key({ modkey
}, "Escape", awful
.tag.history
.restore
))
219 table.insert(globalkeys
, key({ modkey
}, "j", function () awful
.client
.focus
.byidx(1); if client
.focus
then client
.focus
:raise() end end))
220 table.insert(globalkeys
, key({ modkey
}, "k", function () awful
.client
.focus
.byidx(-1); if client
.focus
then client
.focus
:raise() end end))
221 table.insert(globalkeys
, key({ modkey
, "Shift" }, "j", function () awful
.client
.swap
.byidx(1) end))
222 table.insert(globalkeys
, key({ modkey
, "Shift" }, "k", function () awful
.client
.swap
.byidx(-1) end))
224 table.insert(globalkeys
, key({ modkey
, "Control" }, "j", function () awful
.screen
.focus(1) end))
225 table.insert(globalkeys
, key({ modkey
, "Control" }, "k", function () awful
.screen
.focus(-1) end))
227 table.insert(globalkeys
, key({ modkey
}, "Tab", function () awful
.client
.focus
.history
.previous(); if client
.focus
then client
.focus
:raise() end end))
229 table.insert(globalkeys
, key({ modkey
}, "u", awful
.client
.urgent
.jumpto
))
232 table.insert(globalkeys
, key({ modkey
}, "Return", function () awful
.util
.spawn(terminal
) end))
234 table.insert(globalkeys
, key({ modkey
, "Control" }, "r", function ()
235 mypromptbox
[mouse
.screen
].text
=
236 awful
.util
.escape(awful
.util
.restart())
238 table.insert(globalkeys
, key({ modkey
, "Shift" }, "q", awesome
.quit
))
240 -- Client manipulation
241 table.insert(clientkeys
, key({ modkey
}, "m", function (c
) c
.maximized_horizontal
= not c
.maximized_horizontal
242 c
.maximized_vertical
= not c
.maximized_vertical
end))
243 table.insert(clientkeys
, key({ modkey
}, "f", function (c
) c
.fullscreen
= not c
.fullscreen
end))
244 table.insert(clientkeys
, key({ modkey
, "Shift" }, "c", function (c
) c
:kill() end))
245 table.insert(clientkeys
, key({ modkey
, "Control" }, "space", awful
.client
.floating
.toggle
))
246 table.insert(clientkeys
, key({ modkey
, "Control" }, "Return", function (c
) c
:swap(awful
.client
.getmaster()) end))
247 table.insert(clientkeys
, key({ modkey
}, "o", awful
.client
.movetoscreen
))
248 table.insert(clientkeys
, key({ modkey
, "Shift" }, "r", function (c
) c
:redraw() end))
250 -- Layout manipulation
251 table.insert(globalkeys
, key({ modkey
}, "l", function () awful
.tag.incmwfact(0.05) end))
252 table.insert(globalkeys
, key({ modkey
}, "h", function () awful
.tag.incmwfact(-0.05) end))
253 table.insert(globalkeys
, key({ modkey
, "Shift" }, "h", function () awful
.tag.incnmaster(1) end))
254 table.insert(globalkeys
, key({ modkey
, "Shift" }, "l", function () awful
.tag.incnmaster(-1) end))
255 table.insert(globalkeys
, key({ modkey
, "Control" }, "h", function () awful
.tag.incncol(1) end))
256 table.insert(globalkeys
, key({ modkey
, "Control" }, "l", function () awful
.tag.incncol(-1) end))
257 table.insert(globalkeys
, key({ modkey
}, "space", function () awful
.layout
.inc(layouts
, 1) end))
258 table.insert(globalkeys
, key({ modkey
, "Shift" }, "space", function () awful
.layout
.inc(layouts
, -1) end))
261 table.insert(globalkeys
, key({ modkey
}, "F1", function ()
262 awful
.prompt
.run({ prompt
= "Run: " },
263 mypromptbox
[mouse
.screen
],
264 awful
.util
.spawn
, awful
.completion
.bash
,
265 awful
.util
.getdir("cache") .. "/history")
267 table.insert(globalkeys
, key({ modkey
}, "F4", function ()
268 awful
.prompt
.run({ prompt
= "Run Lua code: " },
269 mypromptbox
[mouse
.screen
],
270 awful
.util
.eval
, awful
.prompt
.bash
,
271 awful
.util
.getdir("cache") .. "/history_eval")
274 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
275 table.insert(clientkeys
, key({ modkey
}, "t", awful
.client
.togglemarked
))
277 for i
= 1, keynumber
do
278 table.insert(globalkeys
, key({ modkey
, "Shift" }, "F" .. i
,
280 local screen
= mouse
.screen
281 if tags
[screen
][i
] then
282 for k
, c
in pairs(awful
.client
.getmarked()) do
283 awful
.client
.movetotag(tags
[screen
][i
], c
)
290 root
.keys(globalkeys
)
294 -- Hook function to execute when focusing a client.
295 awful
.hooks
.focus
.register(function (c
)
296 if not awful
.client
.ismarked(c
) then
297 c
.border_color
= beautiful
.border_focus
301 -- Hook function to execute when unfocusing a client.
302 awful
.hooks
.unfocus
.register(function (c
)
303 if not awful
.client
.ismarked(c
) then
304 c
.border_color
= beautiful
.border_normal
308 -- Hook function to execute when marking a client
309 awful
.hooks
.marked
.register(function (c
)
310 c
.border_color
= beautiful
.border_marked
313 -- Hook function to execute when unmarking a client.
314 awful
.hooks
.unmarked
.register(function (c
)
315 c
.border_color
= beautiful
.border_focus
318 -- Hook function to execute when the mouse enters a client.
319 awful
.hooks
.mouse_enter
.register(function (c
)
320 -- Sloppy focus, but disabled for magnifier layout
321 if awful
.layout
.get(c
.screen
) ~= awful
.layout
.suit
.magnifier
322 and awful
.client
.focus
.filter(c
) then
327 -- Hook function to execute when a new client appears.
328 awful
.hooks
.manage
.register(function (c
, startup
)
329 -- If we are not managing this application at startup,
330 -- move it to the screen where the mouse is.
331 -- We only do it for filtered windows (i.e. no dock, etc).
332 if not startup
and awful
.client
.focus
.filter(c
) then
333 c
.screen
= mouse
.screen
338 awful
.titlebar
.add(c
, { modkey
= modkey
})
340 -- Add mouse bindings
342 button({ }, 1, function (c
) client
.focus
= c
; c
:raise() end),
343 button({ modkey
}, 1, awful
.mouse
.client
.move
),
344 button({ modkey
}, 3, awful
.mouse
.client
.resize
)
346 -- New client may not receive focus
347 -- if they're not focusable, so set border anyway.
348 c
.border_width
= beautiful
.border_width
349 c
.border_color
= beautiful
.border_normal
351 -- Check if the application should be floating.
353 local inst
= c
.instance
354 if floatapps
[cls
] then
355 awful
.client
.floating
.set(c
, floatapps
[cls
])
356 elseif floatapps
[inst
] then
357 awful
.client
.floating
.set(c
, floatapps
[inst
])
360 -- Check application->screen/tag mappings.
363 target
= apptags
[cls
]
364 elseif apptags
[inst
] then
365 target
= apptags
[inst
]
368 c
.screen
= target
.screen
369 awful
.client
.movetotag(tags
[target
.screen
][target
.tag], c
)
372 -- Do this after tag mapping, so you don't see it on the wrong tag for a split second.
378 -- Set the windows at the slave,
379 -- i.e. put it at the end of others instead of setting it master.
380 -- awful.client.setslave(c)
382 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
383 -- c.size_hints_honor = false
386 -- Hook function to execute when arranging the screen.
387 -- (tag switch, new client, etc)
388 awful
.hooks
.arrange
.register(function (screen
)
389 local layout
= awful
.layout
.getname(awful
.layout
.get(screen
))
390 if layout
and beautiful
["layout_" ..layout
] then
391 mylayoutbox
[screen
].image
= image(beautiful
["layout_" .. layout
])
393 mylayoutbox
[screen
].image
= nil
396 -- Give focus to the latest client in history if no window has focus
397 -- or if the current window is a desktop or a dock one.
398 if not client
.focus
then
399 local c
= awful
.client
.focus
.history
.get(screen
, 0)
400 if c
then client
.focus
= c
end
404 -- Hook called every second
405 awful
.hooks
.timer
.register(1, function ()
406 -- For unix time_t lovers
407 mytextbox
.text
= " " .. os
.time() .. " time_t "
409 -- mytextbox.text = " " .. os.date() .. " "