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.
47 -- Table of clients that should be set floating. The index may be either
48 -- the application class or instance. The instance is useful when running
49 -- a console app in a terminal like (Music on Console)
50 -- xterm -name mocp -e mocp
61 -- Applications to be moved to a pre-defined tag by class or instance.
62 -- Use the screen and tags indices.
65 -- ["Firefox"] = { screen = 1, tag = 2 },
66 -- ["mocp"] = { screen = 2, tag = 4 },
69 -- Define if we want to use titlebar on all applications.
76 for s
= 1, screen
.count() do
77 -- Each screen has its own tag table.
79 -- Create 9 tags per screen.
80 for tagnumber
= 1, 9 do
81 tags
[s
][tagnumber
] = tag({ name
= tagnumber
, layout
= layouts
[1] })
82 -- Add tags to screen one by one
83 tags
[s
][tagnumber
].screen
= s
85 -- I'm sure you want to see at least one tag.
86 tags
[s
][1].selected
= true
91 -- Create a textbox widget
92 mytextbox
= widget({ type = "textbox", align
= "right" })
93 -- Set the default text in textbox
94 mytextbox
.text
= "<b><small> " .. AWESOME_RELEASE
.. " </small></b>"
96 -- Create a laucher widget and a main menu
98 { "manual", terminal
.. " -e man awesome" },
99 { "edit config", editor_cmd
.. " " .. awful
.util
.getdir("config") .. "/rc.lua" },
100 { "restart", awesome
.restart
},
101 { "quit", awesome
.quit
}
104 mymainmenu
= awful
.menu
.new({ items
= { { "awesome", myawesomemenu
, beautiful
.awesome_icon
},
105 { "open terminal", terminal
}
109 mylauncher
= awful
.widget
.launcher({ image
= beautiful
.awesome_icon
,
113 mysystray
= widget({ type = "systray", align
= "right" })
115 -- Create a wibox for each screen and add it
120 mytaglist
.buttons
= { button({ }, 1, awful
.tag.viewonly
),
121 button({ modkey
}, 1, awful
.client
.movetotag
),
122 button({ }, 3, function (tag) tag.selected
= not tag.selected
end),
123 button({ modkey
}, 3, awful
.client
.toggletag
),
124 button({ }, 4, awful
.tag.viewnext
),
125 button({ }, 5, awful
.tag.viewprev
) }
127 mytasklist
.buttons
= { button({ }, 1, function (c
) client
.focus
= c
; c
:raise() end),
128 button({ }, 3, function () awful
.menu
.clients({ width
=250 }) end),
129 button({ }, 4, function () awful
.client
.focus
.byidx(1) end),
130 button({ }, 5, function () awful
.client
.focus
.byidx(-1) end) }
132 for s
= 1, screen
.count() do
133 -- Create a promptbox for each screen
134 mypromptbox
[s
] = widget({ type = "textbox", align
= "left" })
135 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
136 -- We need one layoutbox per screen.
137 mylayoutbox
[s
] = widget({ type = "imagebox", align
= "right" })
138 mylayoutbox
[s
]:buttons({ button({ }, 1, function () awful
.layout
.inc(layouts
, 1) end),
139 button({ }, 3, function () awful
.layout
.inc(layouts
, -1) end),
140 button({ }, 4, function () awful
.layout
.inc(layouts
, 1) end),
141 button({ }, 5, function () awful
.layout
.inc(layouts
, -1) end) })
142 -- Create a taglist widget
143 mytaglist
[s
] = awful
.widget
.taglist
.new(s
, awful
.widget
.taglist
.label
.all
, mytaglist
.buttons
)
145 -- Create a tasklist widget
146 mytasklist
[s
] = awful
.widget
.tasklist
.new(function(c
)
147 return awful
.widget
.tasklist
.label
.currenttags(c
, s
)
148 end, mytasklist
.buttons
)
151 mywibox
[s
] = wibox({ position
= "top", fg
= beautiful
.fg_normal
, bg
= beautiful
.bg_normal
})
152 -- Add widgets to the wibox - order matters
153 mywibox
[s
].widgets
= { mylauncher
,
159 s
== 1 and mysystray
or nil }
160 mywibox
[s
].screen
= s
164 -- {{{ Mouse bindings
166 button({ }, 3, function () mymainmenu
:toggle() end),
167 button({ }, 4, awful
.tag.viewnext
),
168 button({ }, 5, awful
.tag.viewprev
)
174 -- Bind keyboard digits
175 -- Compute the maximum number of digit we need, limited to 9
177 for s
= 1, screen
.count() do
178 keynumber
= math
.min(9, math
.max(#tags
[s
], keynumber
));
181 for i
= 1, keynumber
do
182 keybinding({ modkey
}, i
,
184 local screen
= mouse
.screen
185 if tags
[screen
][i
] then
186 awful
.tag.viewonly(tags
[screen
][i
])
189 keybinding({ modkey
, "Control" }, i
,
191 local screen
= mouse
.screen
192 if tags
[screen
][i
] then
193 tags
[screen
][i
].selected
= not tags
[screen
][i
].selected
196 keybinding({ modkey
, "Shift" }, i
,
198 if client
.focus
and tags
[client
.focus
.screen
][i
] then
199 awful
.client
.movetotag(tags
[client
.focus
.screen
][i
])
202 keybinding({ modkey
, "Control", "Shift" }, i
,
204 if client
.focus
and tags
[client
.focus
.screen
][i
] then
205 awful
.client
.toggletag(tags
[client
.focus
.screen
][i
])
210 keybinding({ modkey
}, "Left", awful
.tag.viewprev
):add()
211 keybinding({ modkey
}, "Right", awful
.tag.viewnext
):add()
212 keybinding({ modkey
}, "Escape", awful
.tag.history
.restore
):add()
215 keybinding({ modkey
}, "Return", function () awful
.util
.spawn(terminal
) end):add()
217 keybinding({ modkey
, "Control" }, "r", function ()
218 mypromptbox
[mouse
.screen
].text
=
219 awful
.util
.escape(awful
.util
.restart())
221 keybinding({ modkey
, "Shift" }, "q", awesome
.quit
):add()
223 -- Client manipulation
224 keybinding({ modkey
}, "m", function () if client
.focus
then client
.focus
.maximized_horizontal
= not client
.focus
.maximized_horizontal
225 client
.focus
.maximized_vertical
= not client
.focus
.maximized_vertical
end end):add()
226 keybinding({ modkey
}, "f", function () if client
.focus
then client
.focus
.fullscreen
= not client
.focus
.fullscreen
end end):add()
227 keybinding({ modkey
, "Shift" }, "c", function () if client
.focus
then client
.focus
:kill() end end):add()
228 keybinding({ modkey
}, "j", function () awful
.client
.focus
.byidx(1); if client
.focus
then client
.focus
:raise() end end):add()
229 keybinding({ modkey
}, "k", function () awful
.client
.focus
.byidx(-1); if client
.focus
then client
.focus
:raise() end end):add()
230 keybinding({ modkey
, "Shift" }, "j", function () awful
.client
.swap
.byidx(1) end):add()
231 keybinding({ modkey
, "Shift" }, "k", function () awful
.client
.swap
.byidx(-1) end):add()
232 keybinding({ modkey
, "Control" }, "j", function () awful
.screen
.focus(1) end):add()
233 keybinding({ modkey
, "Control" }, "k", function () awful
.screen
.focus(-1) end):add()
234 keybinding({ modkey
, "Control" }, "space", awful
.client
.togglefloating
):add()
235 keybinding({ modkey
, "Control" }, "Return", function () if client
.focus
then client
.focus
:swap(awful
.client
.getmaster()) end end):add()
236 keybinding({ modkey
}, "o", awful
.client
.movetoscreen
):add()
237 keybinding({ modkey
}, "Tab", awful
.client
.focus
.history
.previous
):add()
238 keybinding({ modkey
}, "u", awful
.client
.urgent
.jumpto
):add()
239 keybinding({ modkey
, "Shift" }, "r", function () if client
.focus
then client
.focus
:redraw() end end):add()
241 -- Layout manipulation
242 keybinding({ modkey
}, "l", function () awful
.tag.incmwfact(0.05) end):add()
243 keybinding({ modkey
}, "h", function () awful
.tag.incmwfact(-0.05) end):add()
244 keybinding({ modkey
, "Shift" }, "h", function () awful
.tag.incnmaster(1) end):add()
245 keybinding({ modkey
, "Shift" }, "l", function () awful
.tag.incnmaster(-1) end):add()
246 keybinding({ modkey
, "Control" }, "h", function () awful
.tag.incncol(1) end):add()
247 keybinding({ modkey
, "Control" }, "l", function () awful
.tag.incncol(-1) end):add()
248 keybinding({ modkey
}, "space", function () awful
.layout
.inc(layouts
, 1) end):add()
249 keybinding({ modkey
, "Shift" }, "space", function () awful
.layout
.inc(layouts
, -1) end):add()
252 keybinding({ modkey
}, "F1", function ()
253 awful
.prompt
.run({ prompt
= "Run: " }, mypromptbox
[mouse
.screen
], awful
.util
.spawn
, awful
.completion
.bash
,
254 awful
.util
.getdir("cache") .. "/history")
256 keybinding({ modkey
}, "F4", function ()
257 awful
.prompt
.run({ prompt
= "Run Lua code: " }, mypromptbox
[mouse
.screen
], awful
.util
.eval
, awful
.prompt
.bash
,
258 awful
.util
.getdir("cache") .. "/history_eval")
261 keybinding({ modkey
, "Ctrl" }, "i", function ()
262 local s
= mouse
.screen
263 if mypromptbox
[s
].text
then
264 mypromptbox
[s
].text
= nil
265 elseif client
.focus
then
266 mypromptbox
[s
].text
= nil
267 if client
.focus
.class
then
268 mypromptbox
[s
].text
= "Class: " .. client
.focus
.class
.. " "
270 if client
.focus
.instance
then
271 mypromptbox
[s
].text
= mypromptbox
[s
].text
.. "Instance: ".. client
.focus
.instance
.. " "
273 if client
.focus
.role
then
274 mypromptbox
[s
].text
= mypromptbox
[s
].text
.. "Role: ".. client
.focus
.role
279 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
280 keybinding({ modkey
}, "t", awful
.client
.togglemarked
):add()
282 for i
= 1, keynumber
do
283 keybinding({ modkey
, "Shift" }, "F" .. i
,
285 local screen
= mouse
.screen
286 if tags
[screen
][i
] then
287 for k
, c
in pairs(awful
.client
.getmarked()) do
288 awful
.client
.movetotag(tags
[screen
][i
], c
)
296 -- Hook function to execute when focusing a client.
297 awful
.hooks
.focus
.register(function (c
)
298 if not awful
.client
.ismarked(c
) then
299 c
.border_color
= beautiful
.border_focus
303 -- Hook function to execute when unfocusing a client.
304 awful
.hooks
.unfocus
.register(function (c
)
305 if not awful
.client
.ismarked(c
) then
306 c
.border_color
= beautiful
.border_normal
310 -- Hook function to execute when marking a client
311 awful
.hooks
.marked
.register(function (c
)
312 c
.border_color
= beautiful
.border_marked
315 -- Hook function to execute when unmarking a client.
316 awful
.hooks
.unmarked
.register(function (c
)
317 c
.border_color
= beautiful
.border_focus
320 -- Hook function to execute when the mouse enters a client.
321 awful
.hooks
.mouse_enter
.register(function (c
)
322 -- Sloppy focus, but disabled for magnifier layout
323 if awful
.layout
.get(c
.screen
) ~= "magnifier"
324 and awful
.client
.focus
.filter(c
) then
329 -- Hook function to execute when a new client appears.
330 awful
.hooks
.manage
.register(function (c
)
333 awful
.titlebar
.add(c
, { modkey
= modkey
})
335 -- Add mouse bindings
337 button({ }, 1, function (c
) client
.focus
= c
; c
:raise() end),
338 button({ modkey
}, 1, awful
.mouse
.client
.move
),
339 button({ modkey
}, 3, awful
.mouse
.client
.resize
)
341 -- New client may not receive focus
342 -- if they're not focusable, so set border anyway.
343 c
.border_width
= beautiful
.border_width
344 c
.border_color
= beautiful
.border_normal
346 -- Check if the application should be floating.
348 local inst
= c
.instance
349 if floatapps
[cls
] then
350 c
.floating
= floatapps
[cls
]
351 elseif floatapps
[inst
] then
352 c
.floating
= floatapps
[inst
]
355 -- Check application->screen/tag mappings.
358 target
= apptags
[cls
]
359 elseif apptags
[inst
] then
360 target
= apptags
[inst
]
363 c
.screen
= target
.screen
364 awful
.client
.movetotag(tags
[target
.screen
][target
.tag], c
)
367 -- Do this after tag mapping, so you don't see it on the wrong tag for a split second.
370 -- Set the windows at the slave,
371 -- i.e. put it at the end of others instead of setting it master.
372 -- awful.client.setslave(c)
374 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
375 -- c.honorsizehints = false
378 -- Hook function to execute when arranging the screen.
379 -- (tag switch, new client, etc)
380 awful
.hooks
.arrange
.register(function (screen
)
381 local layout
= awful
.layout
.get(screen
)
383 mylayoutbox
[screen
].image
= image(beautiful
["layout_" .. layout
])
385 mylayoutbox
[screen
].image
= nil
388 -- Give focus to the latest client in history if no window has focus
389 -- or if the current window is a desktop or a dock one.
390 if not client
.focus
then
391 local c
= awful
.client
.focus
.history
.get(screen
, 0)
392 if c
then client
.focus
= c
end
395 -- Uncomment if you want mouse warping
398 local c_c = client.focus:fullgeometry()
399 local m_c = mouse.coords()
401 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
402 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
403 if table.maxn(m_c.buttons) == 0 then
404 mouse.coords({ x = c_c.x + 5, y = c_c.y + 5})
411 -- Hook called every second
412 awful
.hooks
.timer
.register(1, function ()
413 -- For unix time_t lovers
414 mytextbox
.text
= " " .. os
.time() .. " time_t "
416 -- mytextbox.text = " " .. os.date() .. " "