1 -- Standard awesome library
3 require("awful.autofocus")
5 -- Theme handling library
7 -- Notification library
10 -- require("obvious.volume_alsa")
11 require("obvious.battery")
12 require("obvious.temp_info")
14 -- Load Debian menu entries
15 require("debian.menu")
17 -- from https://github.com/tony/awesome-config/blob/master/helpers.lua
19 function file_exists(file)
20 s = awful.util.pread("/bin/dash -c 'if [ -e " .. file .. " ]; then echo true; fi;'"):gsub("\n","")
21 if s == 'true' then return true else return nil end
24 -- {{{ Variable definitions
25 -- Themes define colours, icons, and wallpapers
26 beautiful.init("/usr/share/awesome/themes/default/theme.lua")
28 -- This is used later as the default terminal and editor to run.
29 terminal = "x-terminal-emulator"
30 editor = os.getenv("EDITOR") or "editor"
31 editor_cmd = terminal .. " -e " .. editor
32 home = os.getenv("HOME")
34 hostname = awful.util.pread("hostname -f"):gsub("\n", "")
37 -- Usually, Mod4 is the key with a logo between Control and Alt.
38 -- If you do not like this or do not have such a key,
39 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
40 -- However, you can use another modifier like Mod1, but it may interact with others.
43 -- Table of layouts to cover with awful.layout.inc, order matters.
46 awful.layout.suit.tile,
47 awful.layout.suit.tile.left,
48 awful.layout.suit.tile.bottom,
49 awful.layout.suit.tile.top,
50 awful.layout.suit.fair,
51 awful.layout.suit.fair.horizontal,
52 awful.layout.suit.spiral,
53 awful.layout.suit.spiral.dwindle,
54 awful.layout.suit.max,
55 awful.layout.suit.max.fullscreen,
56 awful.layout.suit.magnifier,
57 awful.layout.suit.floating
62 -- Define a tag table which hold all screen tags.
63 tags = {names={"mail","emacs","www","remotes",5,6,7,8,9}
65 for s = 1, screen.count() do
66 -- Each screen has its own tag table.
67 defaultlayout=layouts[9]
68 tags[s] = awful.tag(tags.names, s, defaultlayout)
73 -- Create a laucher widget and a main menu
75 { "manual", terminal .. " -e man awesome" },
76 { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
77 { "restart", awesome.restart },
78 { "quit", awesome.quit }
81 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
82 { "Debian", debian.menu.Debian_menu.Debian },
83 { "open terminal", terminal }
87 mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
92 -- Create a textclock widget
93 mytextclock = awful.widget.textclock({ align = "right" }, " %c ", 1)
95 -- myvolumealsa = obvious.volume_alsa()
96 mybattery = obvious.battery()
98 mytemp = obvious.temp_info()
101 mysystray = widget({ type = "systray" })
103 -- Create a wibox for each screen and add it
108 mytaglist.buttons = awful.util.table.join(
109 awful.button({ }, 1, awful.tag.viewonly),
110 awful.button({ modkey }, 1, awful.client.movetotag),
111 awful.button({ }, 3, awful.tag.viewtoggle),
112 awful.button({ modkey }, 3, awful.client.toggletag),
113 awful.button({ }, 4, awful.tag.viewnext),
114 awful.button({ }, 5, awful.tag.viewprev)
117 mytasklist.buttons = awful.util.table.join(
118 awful.button({ }, 1, function (c)
119 if not c:isvisible() then
120 awful.tag.viewonly(c:tags()[1])
125 awful.button({ }, 3, function ()
130 instance = awful.menu.clients({ width=250 })
133 awful.button({ }, 4, function ()
134 awful.client.focus.byidx(1)
135 if client.focus then client.focus:raise() end
137 awful.button({ }, 5, function ()
138 awful.client.focus.byidx(-1)
139 if client.focus then client.focus:raise() end
142 for s = 1, screen.count() do
143 -- Create a promptbox for each screen
144 mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
145 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
146 -- We need one layoutbox per screen.
147 mylayoutbox[s] = awful.widget.layoutbox(s)
148 mylayoutbox[s]:buttons(awful.util.table.join(
149 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
150 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
151 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
152 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
153 -- Create a taglist widget
154 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
156 -- Create a tasklist widget
157 mytasklist[s] = awful.widget.tasklist(function(c)
158 return awful.widget.tasklist.label.currenttags(c, s)
159 end, mytasklist.buttons)
162 mywibox[s] = awful.wibox({ position = "top", screen = s })
163 -- Add widgets to the wibox - order matters
164 mywibox[s].widgets = {
169 layout = awful.widget.layout.horizontal.leftright
176 s == 1 and mysystray or nil,
178 layout = awful.widget.layout.horizontal.rightleft
183 -- {{{ Mouse bindings
184 root.buttons(awful.util.table.join(
185 awful.button({ }, 3, function () mymainmenu:toggle() end),
186 awful.button({ }, 4, awful.tag.viewnext),
187 awful.button({ }, 5, awful.tag.viewprev)
192 globalkeys = awful.util.table.join(
193 -- awful.key({ modkey, }, "Left", awful.tag.viewprev ),
194 -- awful.key({ modkey, }, "Right", awful.tag.viewnext ),
195 awful.key({},"XF86AudioRaiseVolume",function () obvious.volume_alsa.raise(0, "Master", 2) end),
196 awful.key({},"XF86AudioLowerVolume",function () obvious.volume_alsa.lower(0, "Master", 2) end),
197 awful.key({},"XF86RotateWindows", function () awful.util.spawn("rotate_monitor") end),
198 awful.key({ modkey, }, "Escape", awful.tag.history.restore),
200 awful.key({ modkey, }, "j",
202 awful.client.focus.byidx( 1)
203 if client.focus then client.focus:raise() end
206 awful.key({ modkey, }, "k",
208 awful.client.focus.byidx(-1)
209 if client.focus then client.focus:raise() end
212 awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
214 -- Layout manipulation
215 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
216 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
217 awful.key({ modkey, }, "Left", function () awful.screen.focus_relative( 1) end),
218 awful.key({ modkey, }, "Right", function () awful.screen.focus_relative(-1) end),
219 awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
220 awful.key({ modkey, }, "Tab",
222 -- awful.client.focus.history.previous()
223 awful.client.focus.byidx(-1)
229 awful.key({ modkey, "Shift" }, "Tab",
231 -- awful.client.focus.history.previous()
232 awful.client.focus.byidx(1)
238 awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
239 awful.key({ modkey, "Control", "Shift" }, "r", awesome.restart),
240 awful.key({ modkey, "Control", "Shift" }, "q", awesome.quit),
242 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
243 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
244 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
245 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
246 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
247 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
248 awful.key({ modkey, }, "n", function () awful.layout.inc(layouts, 1) end),
249 awful.key({ modkey, "Shift" }, "n", function () awful.layout.inc(layouts, -1) end),
252 awful.key({ modkey, "Control" }, "Down", function () awful.client.moveresize(0, 20, 0, 0) end),
253 awful.key({ modkey, "Control" }, "Up", function () awful.client.moveresize(0, -20, 0, 0) end),
254 awful.key({ modkey, "Control" }, "Left", function () awful.client.moveresize(-20, 0, 0, 0) end),
255 awful.key({ modkey, "Control" }, "Right", function () awful.client.moveresize(20, 0, 0, 0) end),
256 awful.key({ modkey, "Control" , "Shift" }, "Down", function () awful.client.moveresize(0, 0, 0, -20) end),
257 awful.key({ modkey, "Control" , "Shift" }, "Up", function () awful.client.moveresize(0, 0, 0, 20) end),
258 awful.key({ modkey, "Control" , "Shift" }, "Left", function () awful.client.moveresize(0, 0, -20, 0) end),
259 awful.key({ modkey, "Control" , "Shift" }, "Right", function () awful.client.moveresize(0, 0, 20, 0) end),
261 awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
263 awful.key({ modkey }, "x",
265 awful.prompt.run({ prompt = "Run Lua code: " },
266 mypromptbox[mouse.screen].widget,
267 awful.util.eval, nil,
268 awful.util.getdir("cache") .. "/history_eval")
272 clientkeys = awful.util.table.join(
273 awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
274 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
275 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
276 awful.key({ modkey, }, "space", function (c) c:swap(awful.client.getmaster()) end),
277 awful.key({ modkey, }, "o", awful.client.movetoscreen ),
278 awful.key({ modkey, "Shift" }, "Right", function(c) awful.client.movetoscreen(c,c.screen-1 % screen.count()) end),
279 awful.key({ modkey, "Shift" }, "Left", function(c) awful.client.movetoscreen(c,c.screen+1 % screen.count()) end),
280 awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
281 awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
282 awful.key({ modkey, "Shift" }, "m", function (c) c.minimized = not c.minimized end),
283 awful.key({ modkey, }, "m",
285 c.maximized_horizontal = not c.maximized_horizontal
286 c.maximized_vertical = not c.maximized_vertical
290 -- Compute the maximum number of digit we need, limited to 9
292 for s = 1, screen.count() do
293 keynumber = math.min(9, math.max(#tags[s], keynumber));
296 -- Bind all key numbers to tags.
297 -- Be careful: we use keycodes to make it works on any keyboard layout.
298 -- This should map on the top row of your keyboard, usually 1 to 9.
299 for i = 1, keynumber do
300 globalkeys = awful.util.table.join(globalkeys,
301 awful.key({ modkey }, "#" .. i + 9,
303 local screen = mouse.screen
304 if tags[screen][i] then
305 awful.tag.viewonly(tags[screen][i])
308 awful.key({ modkey, "Control" }, "#" .. i + 9,
310 local screen = mouse.screen
311 if tags[screen][i] then
312 awful.tag.viewtoggle(tags[screen][i])
315 awful.key({ modkey, "Shift" }, "#" .. i + 9,
317 if client.focus and tags[client.focus.screen][i] then
318 awful.client.movetotag(tags[client.focus.screen][i])
321 awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
323 if client.focus and tags[client.focus.screen][i] then
324 awful.client.toggletag(tags[client.focus.screen][i])
329 clientbuttons = awful.util.table.join(
330 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
331 awful.button({ modkey }, 1, awful.mouse.client.move),
332 awful.button({ modkey }, 3, awful.mouse.client.resize))
335 root.keys(globalkeys)
339 awful.rules.rules = {
340 -- All clients will match this rule.
342 properties = { border_width = beautiful.border_width,
343 border_color = beautiful.border_normal,
346 buttons = clientbuttons } },
347 { rule = { class = "MPlayer" },
348 properties = { floating = true , ontop=true } },
349 { rule = { class = "pinentry" },
350 properties = { floating = true , ontop=true } },
351 { rule = { class = "gimp" },
352 properties = { floating = true } },
353 -- Set Firefox to always map on tags number 2 of screen 1.
354 -- { rule = { class = "Firefox" },
355 -- properties = { tag = tags[1][2] } },
360 -- Signal function to execute when a new client appears.
361 client.add_signal("manage", function (c, startup)
363 -- awful.titlebar.add(c, { modkey = modkey })
365 -- Enable sloppy focus
366 c:add_signal("mouse::enter", function(c)
367 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
368 and awful.client.focus.filter(c) then
374 -- Set the windows at the slave,
375 -- i.e. put it at the end of others instead of setting it master.
376 -- awful.client.setslave(c)
378 -- Put windows in a smart way, only if they does not set an initial position.
379 if not c.size_hints.user_position and not c.size_hints.program_position then
380 awful.placement.no_overlap(c)
381 awful.placement.no_offscreen(c)
386 function warp_mouse()
389 local g = c:geometry()
390 mouse.coords({ x = g.x + 1, y = g.y + 1}, true)
394 -- for s = 1, screen.count() do
395 -- screen[s]:add_signal("arrange", function (screen)
396 -- warp_mouse(screen)
401 client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
402 client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
406 wallpaper_dir = home .. "/media/background"
407 if (not file_exists(wallpaper_dir)) then
408 wallpaper_dir = "/usr/share/awesome/themes/default/background.png"
411 wallpaper_cmd = "find " .. wallpaper_dir ..
412 " -xtype f \\( -iname '*.jpg' -o -iname '*.png' \\) " ..
413 " -not -name '.*' -print0 | shuf -n" .. screen.count() .. " -z | xargs -0 feh --draw-exif -d --bg-max"
415 -- set up the wallpaper timer
416 wallpaper_timer = timer({ timeout = 0 })
417 wallpaper_timer:add_signal("timeout",
419 -- tell awsetbg to randomly choose a wallpaper from your wallpaper directory
420 os.execute(wallpaper_cmd)
421 -- stop the timer (we don't need multiple instances running at the same time)
422 wallpaper_timer:stop()
424 -- define the interval in which the next wallpaper change should occur in seconds
425 -- (in this case anytime between 10 and 20 minutes)
427 wallpaper_timer.timeout = math.random(600,1200)
428 wallpaper_timer:start()
431 wallpaper_timer:start();