1 -- Standard awesome library
2 local gears = require("gears")
3 local awful = require("awful")
4 awful.rules = require("awful.rules")
5 require("awful.autofocus")
6 -- Widget and layout library
7 local wibox = require("wibox")
8 -- Theme handling library
9 local beautiful = require("beautiful")
10 -- Notification library
11 local naughty = require("naughty")
12 local menubar = require("menubar")
15 -- Check if awesome encountered an error during startup and fell back to
16 -- another config (This code will only ever execute for the fallback config)
17 if awesome.startup_errors then
18 naughty.notify({ preset = naughty.config.presets.critical,
19 title = "Oops, there were errors during startup!",
20 text = awesome.startup_errors })
23 -- Handle runtime errors after startup
25 local in_error = false
26 awesome.connect_signal("debug::error", function (err)
27 -- Make sure we don't go into an endless error loop
28 if in_error then return end
31 naughty.notify({ preset = naughty.config.presets.critical,
32 title = "Oops, an error happened!",
39 -- {{{ Variable definitions
40 -- Themes define colours, icons, and wallpapers
41 beautiful.init("/usr/share/awesome/themes/default/theme.lua")
43 -- This is used later as the default terminal and editor to run.
45 editor = os.getenv("EDITOR") or "nano"
46 editor_cmd = terminal .. " -e " .. editor
49 -- Usually, Mod4 is the key with a logo between Control and Alt.
50 -- If you do not like this or do not have such a key,
51 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
52 -- However, you can use another modifier like Mod1, but it may interact with others.
55 -- Table of layouts to cover with awful.layout.inc, order matters.
58 awful.layout.suit.floating,
59 awful.layout.suit.tile,
60 awful.layout.suit.tile.left,
61 awful.layout.suit.tile.bottom,
62 awful.layout.suit.tile.top,
63 awful.layout.suit.fair,
64 awful.layout.suit.fair.horizontal,
65 awful.layout.suit.spiral,
66 awful.layout.suit.spiral.dwindle,
67 awful.layout.suit.max,
68 awful.layout.suit.max.fullscreen,
69 awful.layout.suit.magnifier
74 if beautiful.wallpaper then
75 for s = 1, screen.count() do
76 gears.wallpaper.maximized(beautiful.wallpaper, s, true)
82 -- Define a tag table which hold all screen tags.
84 for s = 1, screen.count() do
85 -- Each screen has its own tag table.
86 tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])
91 -- Create a laucher widget and a main menu
93 { "manual", terminal .. " -e man awesome" },
94 { "edit config", editor_cmd .. " " .. awesome.conffile },
95 { "restart", awesome.restart },
96 { "quit", awesome.quit }
99 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
100 { "open terminal", terminal }
104 mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
107 -- Menubar configuration
108 menubar.utils.terminal = terminal -- Set the terminal for applications that require it
112 -- Create a textclock widget
113 mytextclock = awful.widget.textclock()
115 -- BEGIN OF AWESOMPD WIDGET DECLARATION
117 local awesompd = require('awesompd/awesompd')
119 musicwidget = awesompd:create() -- Create awesompd widget
120 musicwidget.font = "Liberation Mono" -- Set widget font
121 -- musicwidget.font_color = "#FFFFFF" --Set widget font color
122 -- musicwidget.background = "#000000" --Set widget background color
123 musicwidget.scrolling = true -- If true, the text in the widget will be scrolled
124 musicwidget.output_size = 30 -- Set the size of widget in symbols
125 musicwidget.update_interval = 10 -- Set the update interval in seconds
127 -- Set the folder where icons are located (change username to your login name)
128 musicwidget.path_to_icons = "/home/unlogic/.config/awesome/icons"
130 -- Set the path to the icon to be displayed on the widget itself
131 -- musicwidget.widget_icon = "/path/to/icon"
133 -- Set the default music format for Jamendo streams. You can change
134 -- this option on the fly in awesompd itself.
135 -- possible formats: awesompd.FORMAT_MP3, awesompd.FORMAT_OGG
136 musicwidget.jamendo_format = awesompd.FORMAT_MP3
138 -- Specify the browser you use so awesompd can open links from
140 musicwidget.browser = "firefox"
142 -- If true, song notifications for Jamendo tracks and local tracks
143 -- will also contain album cover image.
144 musicwidget.show_album_cover = true
146 -- Specify how big in pixels should an album cover be. Maximum value
148 musicwidget.album_cover_size = 50
150 -- This option is necessary if you want the album covers to be shown
151 -- for your local tracks.
152 musicwidget.mpd_config = "/home/unlogic/.mpdconf"
154 -- Specify decorators on the left and the right side of the
155 -- widget. Or just leave empty strings if you decorate the widget
157 musicwidget.ldecorator = " "
158 musicwidget.rdecorator = " "
160 -- Set all the servers to work with (here can be any servers you use)
161 musicwidget.servers = {
162 { server = "localhost",
164 { server = "192.168.0.72",
168 -- Set the buttons of the widget. Keyboard keys are working in the
169 -- entire Awesome environment. Also look at the line 352.
170 musicwidget:register_buttons(
171 { { "", awesompd.MOUSE_LEFT, musicwidget:command_playpause() },
172 { "Control", awesompd.MOUSE_SCROLL_UP, musicwidget:command_prev_track() },
173 { "Control", awesompd.MOUSE_SCROLL_DOWN, musicwidget:command_next_track() },
174 { "", awesompd.MOUSE_SCROLL_UP, musicwidget:command_volume_up() },
175 { "", awesompd.MOUSE_SCROLL_DOWN, musicwidget:command_volume_down() },
176 { "", awesompd.MOUSE_RIGHT, musicwidget:command_show_menu() },
177 { "", "XF86AudioLowerVolume", musicwidget:command_volume_down() },
178 { "", "XF86AudioRaiseVolume", musicwidget:command_volume_up() },
179 { modkey, "Pause", musicwidget:command_playpause() } })
181 musicwidget:run() -- After all configuration is done, run the widget
183 -- END OF AWESOMPD WIDGET DECLARATION
184 -- Don't forget to add the widget to the wibox. It is done on the line 244.
186 -- Create a wibox for each screen and add it
191 mytaglist.buttons = awful.util.table.join(
192 awful.button({ }, 1, awful.tag.viewonly),
193 awful.button({ modkey }, 1, awful.client.movetotag),
194 awful.button({ }, 3, awful.tag.viewtoggle),
195 awful.button({ modkey }, 3, awful.client.toggletag),
196 awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
197 awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
200 mytasklist.buttons = awful.util.table.join(
201 awful.button({ }, 1, function (c)
202 if c == client.focus then
205 -- Without this, the following
206 -- :isvisible() makes no sense
208 if not c:isvisible() then
209 awful.tag.viewonly(c:tags()[1])
211 -- This will also un-minimize
212 -- the client, if needed
217 awful.button({ }, 3, function ()
222 instance = awful.menu.clients({ width=250 })
225 awful.button({ }, 4, function ()
226 awful.client.focus.byidx(1)
227 if client.focus then client.focus:raise() end
229 awful.button({ }, 5, function ()
230 awful.client.focus.byidx(-1)
231 if client.focus then client.focus:raise() end
234 for s = 1, screen.count() do
235 -- Create a promptbox for each screen
236 mypromptbox[s] = awful.widget.prompt()
237 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
238 -- We need one layoutbox per screen.
239 mylayoutbox[s] = awful.widget.layoutbox(s)
240 mylayoutbox[s]:buttons(awful.util.table.join(
241 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
242 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
243 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
244 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
245 -- Create a taglist widget
246 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
248 -- Create a tasklist widget
249 mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
252 mywibox[s] = awful.wibox({ position = "top", screen = s })
254 -- Widgets that are aligned to the left
255 local left_layout = wibox.layout.fixed.horizontal()
256 left_layout:add(mylauncher)
257 left_layout:add(mytaglist[s])
258 left_layout:add(mypromptbox[s])
260 -- Widgets that are aligned to the right
261 local right_layout = wibox.layout.fixed.horizontal()
262 if s == 1 then right_layout:add(wibox.widget.systray()) end
263 right_layout:add(musicwidget.widget) -- Widget is added here.
264 right_layout:add(mytextclock)
265 right_layout:add(mylayoutbox[s])
267 -- Now bring it all together (with the tasklist in the middle)
268 local layout = wibox.layout.align.horizontal()
269 layout:set_left(left_layout)
270 layout:set_middle(mytasklist[s])
271 layout:set_right(right_layout)
273 mywibox[s]:set_widget(layout)
277 -- {{{ Mouse bindings
278 root.buttons(awful.util.table.join(
279 awful.button({ }, 3, function () mymainmenu:toggle() end),
280 awful.button({ }, 4, awful.tag.viewnext),
281 awful.button({ }, 5, awful.tag.viewprev)
286 globalkeys = awful.util.table.join(
287 awful.key({ modkey, }, "Left", awful.tag.viewprev ),
288 awful.key({ modkey, }, "Right", awful.tag.viewnext ),
289 awful.key({ modkey, }, "Escape", awful.tag.history.restore),
291 awful.key({ modkey, }, "j",
293 awful.client.focus.byidx( 1)
294 if client.focus then client.focus:raise() end
296 awful.key({ modkey, }, "k",
298 awful.client.focus.byidx(-1)
299 if client.focus then client.focus:raise() end
301 awful.key({ modkey, }, "w", function () mymainmenu:show() end),
303 -- Layout manipulation
304 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
305 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
306 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
307 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
308 awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
309 awful.key({ modkey, }, "Tab",
311 awful.client.focus.history.previous()
318 awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
319 awful.key({ modkey, "Control" }, "r", awesome.restart),
320 awful.key({ modkey, "Shift" }, "q", awesome.quit),
322 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
323 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
324 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
325 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
326 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
327 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
328 awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
329 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
331 awful.key({ modkey, "Control" }, "n", awful.client.restore),
334 awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
336 awful.key({ modkey }, "x",
338 awful.prompt.run({ prompt = "Run Lua code: " },
339 mypromptbox[mouse.screen].widget,
340 awful.util.eval, nil,
341 awful.util.getdir("cache") .. "/history_eval")
344 awful.key({ modkey }, "p", function() menubar.show() end)
347 clientkeys = awful.util.table.join(
348 awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
349 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
350 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
351 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
352 awful.key({ modkey, }, "o", awful.client.movetoscreen ),
353 awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
354 awful.key({ modkey, }, "n",
356 -- The client currently has the input focus, so it cannot be
357 -- minimized, since minimized clients can't have the focus.
360 awful.key({ modkey, }, "m",
362 c.maximized_horizontal = not c.maximized_horizontal
363 c.maximized_vertical = not c.maximized_vertical
367 -- Bind all key numbers to tags.
368 -- Be careful: we use keycodes to make it works on any keyboard layout.
369 -- This should map on the top row of your keyboard, usually 1 to 9.
371 globalkeys = awful.util.table.join(globalkeys,
372 awful.key({ modkey }, "#" .. i + 9,
374 local screen = mouse.screen
375 local tag = awful.tag.gettags(screen)[i]
377 awful.tag.viewonly(tag)
380 awful.key({ modkey, "Control" }, "#" .. i + 9,
382 local screen = mouse.screen
383 local tag = awful.tag.gettags(screen)[i]
385 awful.tag.viewtoggle(tag)
388 awful.key({ modkey, "Shift" }, "#" .. i + 9,
390 local tag = awful.tag.gettags(client.focus.screen)[i]
391 if client.focus and tag then
392 awful.client.movetotag(tag)
395 awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
397 local tag = awful.tag.gettags(client.focus.screen)[i]
398 if client.focus and tag then
399 awful.client.toggletag(tag)
404 clientbuttons = awful.util.table.join(
405 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
406 awful.button({ modkey }, 1, awful.mouse.client.move),
407 awful.button({ modkey }, 3, awful.mouse.client.resize))
410 -- Add this line before root.keys(globalkeys).
411 musicwidget:append_global_keys()
413 root.keys(globalkeys)
417 awful.rules.rules = {
418 -- All clients will match this rule.
420 properties = { border_width = beautiful.border_width,
421 border_color = beautiful.border_normal,
422 focus = awful.client.focus.filter,
424 buttons = clientbuttons } },
425 { rule = { class = "MPlayer" },
426 properties = { floating = true } },
427 { rule = { class = "pinentry" },
428 properties = { floating = true } },
429 { rule = { class = "gimp" },
430 properties = { floating = true } },
431 -- Set Firefox to always map on tags number 2 of screen 1.
432 -- { rule = { class = "Firefox" },
433 -- properties = { tag = tags[1][2] } },
438 -- Signal function to execute when a new client appears.
439 client.connect_signal("manage", function (c, startup)
440 -- Enable sloppy focus
441 c:connect_signal("mouse::enter", function(c)
442 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
443 and awful.client.focus.filter(c) then
449 -- Set the windows at the slave,
450 -- i.e. put it at the end of others instead of setting it master.
451 -- awful.client.setslave(c)
453 -- Put windows in a smart way, only if they does not set an initial position.
454 if not c.size_hints.user_position and not c.size_hints.program_position then
455 awful.placement.no_overlap(c)
456 awful.placement.no_offscreen(c)
460 local titlebars_enabled = false
461 if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
462 -- buttons for the titlebar
463 local buttons = awful.util.table.join(
464 awful.button({ }, 1, function()
467 awful.mouse.client.move(c)
469 awful.button({ }, 3, function()
472 awful.mouse.client.resize(c)
476 -- Widgets that are aligned to the left
477 local left_layout = wibox.layout.fixed.horizontal()
478 left_layout:add(awful.titlebar.widget.iconwidget(c))
479 left_layout:buttons(buttons)
481 -- Widgets that are aligned to the right
482 local right_layout = wibox.layout.fixed.horizontal()
483 right_layout:add(awful.titlebar.widget.floatingbutton(c))
484 right_layout:add(awful.titlebar.widget.maximizedbutton(c))
485 right_layout:add(awful.titlebar.widget.stickybutton(c))
486 right_layout:add(awful.titlebar.widget.ontopbutton(c))
487 right_layout:add(awful.titlebar.widget.closebutton(c))
489 -- The title goes in the middle
490 local middle_layout = wibox.layout.flex.horizontal()
491 local title = awful.titlebar.widget.titlewidget(c)
492 title:set_align("center")
493 middle_layout:add(title)
494 middle_layout:buttons(buttons)
496 -- Now bring it all together
497 local layout = wibox.layout.align.horizontal()
498 layout:set_left(left_layout)
499 layout:set_right(right_layout)
500 layout:set_middle(middle_layout)
502 awful.titlebar(c):set_widget(layout)
506 client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
507 client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)