1 -- Include awesome libraries, with lots of useful function!
5 -- {{{ Variable definitions
6 -- Themes define colours, icons, and wallpapers
7 -- The default is a dark theme
8 theme_path
= "@AWESOME_THEMES_PATH@/default/theme"
9 -- Uncommment this for a lighter theme
10 -- theme_path = "@AWESOME_THEMES_PATH@/sky/theme"
12 -- Actually load theme
13 beautiful
.init(theme_path
)
15 -- This is used later as the default terminal and editor to run.
17 editor
= os
.getenv("EDITOR") or "nano"
18 editor_cmd
= terminal
.. " -e " .. editor
21 -- Usually, Mod4 is the key with a logo between Control and Alt.
22 -- If you do not like this or do not have such a key,
23 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
24 -- However, you can use another modifier like Mod1, but it may interact with others.
27 -- Table of layouts to cover with awful.layout.inc, order matters.
44 -- Table of clients that should be set floating. The index may be either
45 -- the application class or instance. The instance is useful when running
46 -- a console app in a terminal like (Music on Console)
47 -- xterm -name mocp -e mocp
58 -- Applications to be moved to a pre-defined tag by class or instance.
59 -- Use the screen and tags indices.
62 -- ["Firefox"] = { screen = 1, tag = 2 },
63 -- ["mocp"] = { screen = 2, tag = 4 },
66 -- Define if we want to use titlebar on all applications.
73 for s
= 1, screen
.count() do
74 -- Each screen has its own tag table.
76 -- Create 9 tags per screen.
77 for tagnumber
= 1, 9 do
78 tags
[s
][tagnumber
] = tag({ name
= tagnumber
, layout
= layouts
[1] })
79 -- Add tags to screen one by one
80 tags
[s
][tagnumber
].screen
= s
82 -- I'm sure you want to see at least one tag.
83 tags
[s
][1].selected
= true
88 -- Create a textbox widget
89 mytextbox
= widget({ type = "textbox", align
= "right" })
90 -- Set the default text in textbox
91 mytextbox
.text
= "<b><small> " .. AWESOME_RELEASE
.. " </small></b>"
93 -- Create a laucher widget and a main menu
95 { "manual", terminal
.. " -e man awesome" },
96 { "edit config", editor_cmd
.. " " .. awful
.util
.getdir("config") .. "/rc.lua" },
97 { "restart", awesome
.restart
},
98 { "quit", awesome
.quit
}
101 mymainmenu
= awful
.menu
.new({ items
= { { "awesome", myawesomemenu
, beautiful
.awesome_icon
},
102 { "open terminal", terminal
}
106 mylauncher
= awful
.widget
.launcher({ image
= beautiful
.awesome_icon
,
110 mysystray
= widget({ type = "systray", align
= "right" })
112 -- Create a wibox for each screen and add it
117 mytaglist
.buttons
= { button({ }, 1, awful
.tag.viewonly
),
118 button({ modkey
}, 1, awful
.client
.movetotag
),
119 button({ }, 3, function (tag) tag.selected
= not tag.selected
end),
120 button({ modkey
}, 3, awful
.client
.toggletag
),
121 button({ }, 4, awful
.tag.viewnext
),
122 button({ }, 5, awful
.tag.viewprev
) }
124 mytasklist
.buttons
= { button({ }, 1, function (c
) client
.focus
= c
; c
:raise() end),
125 button({ }, 3, function () awful
.menu
.clients({ width
=250 }) end),
126 button({ }, 4, function () awful
.client
.focus
.byidx(1) end),
127 button({ }, 5, function () awful
.client
.focus
.byidx(-1) end) }
129 for s
= 1, screen
.count() do
130 -- Create a promptbox for each screen
131 mypromptbox
[s
] = widget({ type = "textbox", align
= "left" })
132 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
133 -- We need one layoutbox per screen.
134 mylayoutbox
[s
] = widget({ type = "imagebox", align
= "right" })
135 mylayoutbox
[s
]:buttons({ button({ }, 1, function () awful
.layout
.inc(layouts
, 1) end),
136 button({ }, 3, function () awful
.layout
.inc(layouts
, -1) end),
137 button({ }, 4, function () awful
.layout
.inc(layouts
, 1) end),
138 button({ }, 5, function () awful
.layout
.inc(layouts
, -1) end) })
139 -- Create a taglist widget
140 mytaglist
[s
] = awful
.widget
.taglist
.new(s
, awful
.widget
.taglist
.label
.all
, mytaglist
.buttons
)
142 -- Create a tasklist widget
143 mytasklist
[s
] = awful
.widget
.tasklist
.new(function(c
)
144 return awful
.widget
.tasklist
.label
.currenttags(c
, s
)
145 end, mytasklist
.buttons
)
148 mywibox
[s
] = wibox({ position
= "top", fg
= beautiful
.fg_normal
, bg
= beautiful
.bg_normal
})
149 -- Add widgets to the wibox - order matters
150 mywibox
[s
].widgets
= { mylauncher
,
156 s
== 1 and mysystray
or nil }
157 mywibox
[s
].screen
= s
161 -- {{{ Mouse bindings
163 button({ }, 3, function () mymainmenu
:toggle() end),
164 button({ }, 4, awful
.tag.viewnext
),
165 button({ }, 5, awful
.tag.viewprev
)
171 -- Bind keyboard digits
172 -- Compute the maximum number of digit we need, limited to 9
174 for s
= 1, screen
.count() do
175 keynumber
= math
.min(9, math
.max(#tags
[s
], keynumber
));
178 for i
= 1, keynumber
do
179 keybinding({ modkey
}, i
,
181 local screen
= mouse
.screen
182 if tags
[screen
][i
] then
183 awful
.tag.viewonly(tags
[screen
][i
])
186 keybinding({ modkey
, "Control" }, i
,
188 local screen
= mouse
.screen
189 if tags
[screen
][i
] then
190 tags
[screen
][i
].selected
= not tags
[screen
][i
].selected
193 keybinding({ modkey
, "Shift" }, i
,
196 if tags
[client
.focus
.screen
][i
] then
197 awful
.client
.movetotag(tags
[client
.focus
.screen
][i
])
201 keybinding({ modkey
, "Control", "Shift" }, i
,
204 if tags
[client
.focus
.screen
][i
] then
205 awful
.client
.toggletag(tags
[client
.focus
.screen
][i
])
211 keybinding({ modkey
}, "Left", awful
.tag.viewprev
):add()
212 keybinding({ modkey
}, "Right", awful
.tag.viewnext
):add()
213 keybinding({ modkey
}, "Escape", awful
.tag.history
.restore
):add()
216 keybinding({ modkey
}, "Return", function () awful
.util
.spawn(terminal
) end):add()
218 keybinding({ modkey
, "Control" }, "r", function ()
219 mypromptbox
[mouse
.screen
].text
=
220 awful
.util
.escape(awful
.util
.restart())
222 keybinding({ modkey
, "Shift" }, "q", awesome
.quit
):add()
224 -- Client manipulation
225 keybinding({ modkey
}, "m", awful
.client
.maximize
):add()
226 keybinding({ modkey
}, "f", function () client
.focus
.fullscreen
= not client
.focus
.fullscreen
end):add()
227 keybinding({ modkey
, "Shift" }, "c", function () client
.focus
:kill() end):add()
228 keybinding({ modkey
}, "j", function () awful
.client
.focus
.byidx(1); client
.focus
:raise() end):add()
229 keybinding({ modkey
}, "k", function () awful
.client
.focus
.byidx(-1); client
.focus
:raise() end):add()
230 keybinding({ modkey
, "Shift" }, "j", function () awful
.client
.swap
.byidx(1) end):add()
231 keybinding({ modkey
, "Shift" }, "k", function () awful
.client
.swap(-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 () client
.focus
:swap(awful
.client
.getmaster()) 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 () client
.focus
:redraw() 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
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, function (c
) c
:mouse_move() end),
339 button({ modkey
}, 3, function (c
) c
:mouse_resize() end)
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
347 -- Check if the application should be floating.
349 local inst
= c
.instance
350 if floatapps
[cls
] then
351 c
.floating
= floatapps
[cls
]
352 elseif floatapps
[inst
] then
353 c
.floating
= floatapps
[inst
]
356 -- Check application->screen/tag mappings.
359 target
= apptags
[cls
]
360 elseif apptags
[inst
] then
361 target
= apptags
[inst
]
364 c
.screen
= target
.screen
365 awful
.client
.movetotag(tags
[target
.screen
][target
.tag], c
)
368 -- Set the windows at the slave,
369 -- i.e. put it at the end of others instead of setting it master.
370 -- awful.client.setslave(c)
372 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
373 -- c.honorsizehints = false
376 -- Hook function to execute when arranging the screen.
377 -- (tag switch, new client, etc)
378 awful
.hooks
.arrange
.register(function (screen
)
379 local layout
= awful
.layout
.get(screen
)
381 mylayoutbox
[screen
].image
= image(beautiful
["layout_" .. layout
])
383 mylayoutbox
[screen
].image
= nil
386 -- Give focus to the latest client in history if no window has focus
387 -- or if the current window is a desktop or a dock one.
388 if not client
.focus
then
389 local c
= awful
.client
.focus
.history
.get(screen
, 0)
390 if c
then client
.focus
= c
end
393 -- Uncomment if you want mouse warping
396 local c_c = client.focus:fullgeometry()
397 local m_c = mouse.coords()
399 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
400 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
401 if table.maxn(m_c.buttons) == 0 then
402 mouse.coords({ x = c_c.x + 5, y = c_c.y + 5})
409 -- Hook called every second
410 awful
.hooks
.timer
.register(1, function ()
411 -- For unix time_t lovers
412 mytextbox
.text
= " " .. os
.time() .. " time_t "
414 -- mytextbox.text = " " .. os.date() .. " "