1 -- awesome 3 configuration file
3 -- Include awesome library, with lots of useful function!
7 -- {{{ Variable definitions
8 -- This is a file path to a theme file which will defines colors.
9 theme_path
= "@AWESOME_THEMES_PATH@/default"
11 -- This is used later as the default terminal and editor to run.
13 editor
= os
.getenv("EDITOR") or "nano"
14 editor_cmd
= terminal
.. " -e " .. editor
17 -- Usually, Mod4 is the key with a logo between Control and Alt.
18 -- If you do not like this or do not have such a key,
19 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
20 -- However, you can use another modifier like Mod1, but it may interact with others.
23 -- Table of layouts to cover with awful.layout.inc, order matters.
40 -- Table of clients that should be set floating. The index may be either
41 -- the application class or instance. The instance is useful when running
42 -- a console app in a terminal like (Music on Console)
43 -- xterm -name mocp -e mocp
54 -- Applications to be moved to a pre-defined tag by class or instance.
55 -- Use the screen and tags indices.
58 -- ["Firefox"] = { screen = 1, tag = 2 },
59 -- ["mocp"] = { screen = 2, tag = 4 },
62 -- Define if we want to use titlebar on all applications.
67 -- Initialize theme (colors).
68 beautiful
.init(theme_path
)
70 -- Register theme in awful.
71 -- This allows to not pass plenty of arguments to each function
72 -- to inform it about colors we want it to draw.
73 awful
.beautiful
.register(beautiful
)
79 for s
= 1, screen
.count() do
80 -- Each screen has its own tag table.
82 -- Create 9 tags per screen.
83 for tagnumber
= 1, 9 do
84 tags
[s
][tagnumber
] = tag({ name
= tagnumber
, layout
= layouts
[1] })
85 -- Add tags to screen one by one
86 tags
[s
][tagnumber
].screen
= s
88 -- I'm sure you want to see at least one tag.
89 tags
[s
][1].selected
= true
94 -- Create a textbox widget
95 mytextbox
= widget({ type = "textbox", name
= "mytextbox", align
= "right" })
96 -- Set the default text in textbox
97 mytextbox
.text
= "<b><small> " .. AWESOME_RELEASE
.. " </small></b>"
99 -- Create a laucher widget and a main menu
101 {"manual", terminal
.. " -e man awesome" },
102 {"edit config", editor_cmd
.. " " .. awful
.util
.getdir("config") .. "/rc.lua" },
103 {"restart", awesome
.restart
},
104 {"quit", awesome
.quit
}
108 {"awesome", myawesomemenu
, "@AWESOME_ICON_PATH@/awesome16.png" },
109 {"open terminal", terminal
}
112 mylauncher
= awful
.widget
.launcher({ name
= "mylauncher",
113 image
= "@AWESOME_ICON_PATH@/awesome16.png",
114 menu
= { id
="mymainmenu", items
=mymainmenu
, menu_toggle
=true } })
117 mysystray
= widget({ type = "systray", name
= "mysystray", align
= "right" })
119 -- Create a wibox for each screen and add it
124 mytaglist
.buttons
= { button({ }, 1, awful
.tag.viewonly
),
125 button({ modkey
}, 1, awful
.client
.movetotag
),
126 button({ }, 3, function (tag) tag.selected
= not tag.selected
end),
127 button({ modkey
}, 3, awful
.client
.toggletag
),
128 button({ }, 4, awful
.tag.viewnext
),
129 button({ }, 5, awful
.tag.viewprev
) }
131 mytasklist
.buttons
= { button({ }, 1, function (c
) client
.focus
= c
; c
:raise() end),
132 button({ }, 3, function () awful
.menu
.clients({ width
=250 }) end),
133 button({ }, 4, function () awful
.client
.focus
.byidx(1) end),
134 button({ }, 5, function () awful
.client
.focus
.byidx(-1) end) }
136 for s
= 1, screen
.count() do
137 -- Create a promptbox for each screen
138 mypromptbox
[s
] = widget({ type = "textbox", name
= "mypromptbox" .. s
, align
= "left" })
139 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
140 -- We need one layoutbox per screen.
141 mylayoutbox
[s
] = widget({ type = "imagebox", name
= "mylayoutbox", align
= "right" })
142 mylayoutbox
[s
]:buttons({ button({ }, 1, function () awful
.layout
.inc(layouts
, 1) end),
143 button({ }, 3, function () awful
.layout
.inc(layouts
, -1) end),
144 button({ }, 4, function () awful
.layout
.inc(layouts
, 1) end),
145 button({ }, 5, function () awful
.layout
.inc(layouts
, -1) end) })
146 -- Create a taglist widget
147 mytaglist
[s
] = awful
.widget
.taglist
.new(s
, awful
.widget
.taglist
.label
.all
, mytaglist
.buttons
)
149 -- Create a tasklist widget
150 mytasklist
[s
] = awful
.widget
.tasklist
.new(function(c
)
151 return awful
.widget
.tasklist
.label
.currenttags(c
, s
)
152 end, mytasklist
.buttons
)
155 mywibox
[s
] = wibox({ position
= "top", fg
= beautiful
.fg_normal
, bg
= beautiful
.bg_normal
})
156 -- Add widgets to the wibox - order matters
157 mywibox
[s
].widgets
= { mytaglist
[s
],
163 s
== 1 and mysystray
or nil }
164 mywibox
[s
].screen
= s
168 -- {{{ Mouse bindings
170 button({ }, 3, function () awful
.menu
.new({ id
="mymainmenu", items
=mymainmenu
}) end),
171 button({ }, 4, awful
.tag.viewnext
),
172 button({ }, 5, awful
.tag.viewprev
)
178 -- Bind keyboard digits
179 -- Compute the maximum number of digit we need, limited to 9
181 for s
= 1, screen
.count() do
182 keynumber
= math
.min(9, math
.max(#tags
[s
], keynumber
));
185 for i
= 1, keynumber
do
186 keybinding({ modkey
}, i
,
188 local screen
= mouse
.screen
189 if tags
[screen
][i
] then
190 awful
.tag.viewonly(tags
[screen
][i
])
193 keybinding({ modkey
, "Control" }, i
,
195 local screen
= mouse
.screen
196 if tags
[screen
][i
] then
197 tags
[screen
][i
].selected
= not tags
[screen
][i
].selected
200 keybinding({ modkey
, "Shift" }, i
,
203 if tags
[client
.focus
.screen
][i
] then
204 awful
.client
.movetotag(tags
[client
.focus
.screen
][i
])
208 keybinding({ modkey
, "Control", "Shift" }, i
,
211 if tags
[client
.focus
.screen
][i
] then
212 awful
.client
.toggletag(tags
[client
.focus
.screen
][i
])
218 keybinding({ modkey
}, "Left", awful
.tag.viewprev
):add()
219 keybinding({ modkey
}, "Right", awful
.tag.viewnext
):add()
220 keybinding({ modkey
}, "Escape", awful
.tag.history
.restore
):add()
223 keybinding({ modkey
}, "Return", function () awful
.util
.spawn(terminal
) end):add()
225 keybinding({ modkey
, "Control" }, "r", function ()
226 mypromptbox
[mouse
.screen
].text
=
227 awful
.util
.escape(awful
.util
.restart())
229 keybinding({ modkey
, "Shift" }, "q", awesome
.quit
):add()
231 -- Client manipulation
232 keybinding({ modkey
}, "m", awful
.client
.maximize
):add()
233 keybinding({ modkey
}, "f", function () client
.focus
.fullscreen
= not client
.focus
.fullscreen
end):add()
234 keybinding({ modkey
, "Shift" }, "c", function () client
.focus
:kill() end):add()
235 keybinding({ modkey
}, "j", function () awful
.client
.focus
.byidx(1); client
.focus
:raise() end):add()
236 keybinding({ modkey
}, "k", function () awful
.client
.focus
.byidx(-1); client
.focus
:raise() end):add()
237 keybinding({ modkey
, "Shift" }, "j", function () awful
.client
.swap(1) end):add()
238 keybinding({ modkey
, "Shift" }, "k", function () awful
.client
.swap(-1) end):add()
239 keybinding({ modkey
, "Control" }, "j", function () awful
.screen
.focus(1) end):add()
240 keybinding({ modkey
, "Control" }, "k", function () awful
.screen
.focus(-1) end):add()
241 keybinding({ modkey
, "Control" }, "space", awful
.client
.togglefloating
):add()
242 keybinding({ modkey
, "Control" }, "Return", function () client
.focus
:swap(awful
.client
.master()) end):add()
243 keybinding({ modkey
}, "o", awful
.client
.movetoscreen
):add()
244 keybinding({ modkey
}, "Tab", awful
.client
.focus
.history
.previous
):add()
245 keybinding({ modkey
}, "u", awful
.client
.urgent
.jumpto
):add()
246 keybinding({ modkey
, "Shift" }, "r", function () client
.focus
:redraw() end):add()
248 -- Layout manipulation
249 keybinding({ modkey
}, "l", function () awful
.tag.incmwfact(0.05) end):add()
250 keybinding({ modkey
}, "h", function () awful
.tag.incmwfact(-0.05) end):add()
251 keybinding({ modkey
, "Shift" }, "h", function () awful
.tag.incnmaster(1) end):add()
252 keybinding({ modkey
, "Shift" }, "l", function () awful
.tag.incnmaster(-1) end):add()
253 keybinding({ modkey
, "Control" }, "h", function () awful
.tag.incncol(1) end):add()
254 keybinding({ modkey
, "Control" }, "l", function () awful
.tag.incncol(-1) end):add()
255 keybinding({ modkey
}, "space", function () awful
.layout
.inc(layouts
, 1) end):add()
256 keybinding({ modkey
, "Shift" }, "space", function () awful
.layout
.inc(layouts
, -1) end):add()
259 keybinding({ modkey
}, "F1", function ()
260 awful
.prompt
.run({ prompt
= "Run: " }, mypromptbox
[mouse
.screen
], awful
.util
.spawn
, awful
.completion
.bash
,
261 awful
.util
.getdir("cache") .. "/history")
263 keybinding({ modkey
}, "F4", function ()
264 awful
.prompt
.run({ prompt
= "Run Lua code: " }, mypromptbox
[mouse
.screen
], awful
.util
.eval
, awful
.prompt
.bash
,
265 awful
.util
.getdir("cache") .. "/history_eval")
268 keybinding({ modkey
, "Ctrl" }, "i", function ()
269 local s
= mouse
.screen
270 if mypromptbox
[s
].text
then
271 mypromptbox
[s
].text
= nil
273 mypromptbox
[s
].text
= nil
274 if client
.focus
.class
then
275 mypromptbox
[s
].text
= "Class: " .. client
.focus
.class
.. " "
277 if client
.focus
.instance
then
278 mypromptbox
[s
].text
= mypromptbox
[s
].text
.. "Instance: ".. client
.focus
.instance
.. " "
280 if client
.focus
.role
then
281 mypromptbox
[s
].text
= mypromptbox
[s
].text
.. "Role: ".. client
.focus
.role
286 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
287 keybinding({ modkey
}, "t", awful
.client
.togglemarked
):add()
289 for i
= 1, keynumber
do
290 keybinding({ modkey
, "Shift" }, "F" .. i
,
292 local screen
= mouse
.screen
293 if tags
[screen
][i
] then
294 for k
, c
in pairs(awful
.client
.getmarked()) do
295 awful
.client
.movetotag(tags
[screen
][i
], c
)
303 -- Hook function to execute when focusing a client.
304 awful
.hooks
.focus
.register(function (c
)
305 if not awful
.client
.ismarked(c
) then
306 c
.border_color
= beautiful
.border_focus
310 -- Hook function to execute when unfocusing a client.
311 awful
.hooks
.unfocus
.register(function (c
)
312 if not awful
.client
.ismarked(c
) then
313 c
.border_color
= beautiful
.border_normal
317 -- Hook function to execute when marking a client
318 awful
.hooks
.marked
.register(function (c
)
319 c
.border_color
= beautiful
.border_marked
322 -- Hook function to execute when unmarking a client.
323 awful
.hooks
.unmarked
.register(function (c
)
324 c
.border_color
= beautiful
.border_focus
327 -- Hook function to execute when the mouse enters a client.
328 awful
.hooks
.mouse_enter
.register(function (c
)
329 -- Sloppy focus, but disabled for magnifier layout
330 if awful
.layout
.get(c
.screen
) ~= "magnifier"
331 and awful
.client
.focus
.filter(c
) then
336 -- Hook function to execute when a new client appears.
337 awful
.hooks
.manage
.register(function (c
)
340 awful
.titlebar
.add(c
, { modkey
= modkey
})
342 -- Add mouse bindings
344 button({ }, 1, function (c
) client
.focus
= c
; c
:raise() end),
345 button({ modkey
}, 1, function (c
) c
:mouse_move() end),
346 button({ modkey
}, 3, function (c
) c
:mouse_resize() end)
348 -- New client may not receive focus
349 -- if they're not focusable, so set border anyway.
350 c
.border_width
= beautiful
.border_width
351 c
.border_color
= beautiful
.border_normal
354 -- Check if the application should be floating.
356 local inst
= c
.instance
357 if floatapps
[cls
] then
358 c
.floating
= floatapps
[cls
]
359 elseif floatapps
[inst
] then
360 c
.floating
= floatapps
[inst
]
363 -- Check application->screen/tag mappings.
366 target
= apptags
[cls
]
367 elseif apptags
[inst
] then
368 target
= apptags
[inst
]
371 c
.screen
= target
.screen
372 awful
.client
.movetotag(tags
[target
.screen
][target
.tag], c
)
375 -- Set the windows at the slave,
376 -- i.e. put it at the end of others instead of setting it master.
377 -- awful.client.setslave(c)
379 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
380 -- c.honorsizehints = false
383 -- Hook function to execute when arranging the screen.
384 -- (tag switch, new client, etc)
385 awful
.hooks
.arrange
.register(function (screen
)
386 local layout
= awful
.layout
.get(screen
)
388 mylayoutbox
[screen
].image
= image("@AWESOME_ICON_PATH@/layouts/" .. layout
.. "w.png")
390 mylayoutbox
[screen
].image
= nil
393 -- Give focus to the latest client in history if no window has focus
394 -- or if the current window is a desktop or a dock one.
395 if not client
.focus
then
396 local c
= awful
.client
.focus
.history
.get(screen
, 0)
397 if c
then client
.focus
= c
end
400 -- Uncomment if you want mouse warping
403 local c_c = client.focus:fullgeometry()
404 local m_c = mouse.coords()
406 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
407 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
408 if table.maxn(m_c.buttons) == 0 then
409 mouse.coords({ x = c_c.x + 5, y = c_c.y + 5})
416 -- Hook called every second
417 awful
.hooks
.timer
.register(1, function ()
418 -- For unix time_t lovers
419 mytextbox
.text
= " " .. os
.time() .. " time_t "
421 -- mytextbox.text = " " .. os.date() .. " "