]> git.rmz.io Git - dotfiles.git/blob - awesome/rc.lua
ead665c613e800790b4c85dc70a9aec417f6c112
[dotfiles.git] / awesome / rc.lua
1 -- Standard awesome library
2 gears = require("gears")
3 awful = require("awful")
4 awful.rules = require("awful.rules")
5 require("awful.autofocus")
6 -- Widget and layout library
7 wibox = require("wibox")
8 -- Theme handling library
9 beautiful = require("beautiful")
10 -- Notification library
11 naughty = require("naughty")
12 menubar = require("menubar")
13 -- Pulseaudio widget
14 --local APW = require("apw/widget")
15
16 -- {{{ Error handling
17 -- Check if awesome encountered an error during startup and fell back to
18 -- another config (This code will only ever execute for the fallback config)
19 if awesome.startup_errors then
20 naughty.notify({ preset = naughty.config.presets.critical,
21 title = "Oops, there were errors during startup!",
22 text = awesome.startup_errors })
23 end
24
25 -- Handle runtime errors after startup
26 do
27 local in_error = false
28 awesome.connect_signal("debug::error", function (err)
29 -- Make sure we don't go into an endless error loop
30 if in_error then return end
31 in_error = true
32
33 naughty.notify({ preset = naughty.config.presets.critical,
34 title = "Oops, an error happened!",
35 text = err })
36 in_error = false
37 end)
38 end
39 -- }}}
40
41 -- {{{ Variable definitions
42 -- Themes define colours, icons, and wallpapers
43 beautiful.init("/usr/share/awesome/themes/default/theme.lua")
44
45 -- This is used later as the default terminal and editor to run.
46 terminal = "konsole"
47 editor = os.getenv("EDITOR") or "vim"
48 editor_cmd = terminal .. " -e " .. editor
49
50 -- Default modkey.
51 -- Usually, Mod4 is the key with a logo between Control and Alt.
52 -- If you do not like this or do not have such a key,
53 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
54 -- However, you can use another modifier like Mod1, but it may interact with others.
55 modkey = "Mod4"
56
57 -- Tags
58 require("tags")
59 -- }}}
60
61 -- {{{ Wallpaper
62 if beautiful.wallpaper then
63 for s = 1, screen.count() do
64 gears.wallpaper.maximized(beautiful.wallpaper, s, true)
65 end
66 end
67 -- }}}
68
69 --Menu
70 require("menu")
71
72 -- {{{ Wibox
73 -- Create a textclock widget
74 mytextclock = awful.widget.textclock()
75
76 -- Create a wibox for each screen and add it
77 mywibox = {}
78 mypromptbox = {}
79 mylayoutbox = {}
80 mytaglist = {}
81 mytaglist.buttons = awful.util.table.join(
82 awful.button({ }, 1, awful.tag.viewonly),
83 awful.button({ modkey }, 1, awful.client.movetotag),
84 awful.button({ }, 3, awful.tag.viewtoggle),
85 awful.button({ modkey }, 3, awful.client.toggletag),
86 awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
87 awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
88 )
89 mytasklist = {}
90 mytasklist.buttons = awful.util.table.join(
91 awful.button({ }, 1, function (c)
92 if c == client.focus then
93 c.minimized = true
94 else
95 -- Without this, the following
96 -- :isvisible() makes no sense
97 c.minimized = false
98 if not c:isvisible() then
99 awful.tag.viewonly(c:tags()[1])
100 end
101 -- This will also un-minimize
102 -- the client, if needed
103 client.focus = c
104 c:raise()
105 end
106 end),
107 awful.button({ }, 2, function (c) c:kill() end),
108 awful.button({ }, 3, function ()
109 if instance then
110 instance:hide()
111 instance = nil
112 else
113 instance = awful.menu.clients({ width=250 })
114 end
115 end),
116 awful.button({ }, 4, function ()
117 awful.client.focus.byidx(1)
118 if client.focus then client.focus:raise() end
119 end),
120 awful.button({ }, 5, function ()
121 awful.client.focus.byidx(-1)
122 if client.focus then client.focus:raise() end
123 end))
124
125 for s = 1, screen.count() do
126 -- Create a promptbox for each screen
127 mypromptbox[s] = awful.widget.prompt()
128 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
129 -- We need one layoutbox per screen.
130 mylayoutbox[s] = awful.widget.layoutbox(s)
131 mylayoutbox[s]:buttons(awful.util.table.join(
132 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
133 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
134 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
135 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
136 -- Create a taglist widget
137 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
138
139 -- Create a tasklist widget
140 mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
141
142 -- Create the wibox
143 mywibox[s] = awful.wibox({ position = "top", screen = s })
144
145 -- Widgets that are aligned to the left
146 local left_layout = wibox.layout.fixed.horizontal()
147 left_layout:add(mylauncher)
148 left_layout:add(mytaglist[s])
149 left_layout:add(mypromptbox[s])
150
151 -- Widgets that are aligned to the right
152 local right_layout = wibox.layout.fixed.horizontal()
153 if s == 1 then right_layout:add(wibox.widget.systray()) end
154 --right_layout:add(APW)
155 right_layout:add(mytextclock)
156 right_layout:add(mylayoutbox[s])
157
158 -- Now bring it all together (with the tasklist in the middle)
159 local layout = wibox.layout.align.horizontal()
160 layout:set_left(left_layout)
161 layout:set_middle(mytasklist[s])
162 layout:set_right(right_layout)
163
164 mywibox[s]:set_widget(layout)
165 end
166 -- }}}
167
168 -- Mouse/Key Bindings
169 require("bindings")
170
171 -- Rules
172 require("rules")
173
174 -- {{{ Signals
175 -- Signal function to execute when a new client appears.
176 client.connect_signal("manage", function (c, startup)
177 -- Enable sloppy focus
178 c:connect_signal("mouse::enter", function(c)
179 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
180 and awful.client.focus.filter(c) then
181 client.focus = c
182 end
183 end)
184
185 if not startup then
186 -- Set the windows at the slave,
187 -- i.e. put it at the end of others instead of setting it master.
188 -- awful.client.setslave(c)
189
190 -- Put windows in a smart way, only if they does not set an initial position.
191 if not c.size_hints.user_position and not c.size_hints.program_position then
192 awful.placement.no_overlap(c)
193 awful.placement.no_offscreen(c)
194 end
195 end
196 end)
197
198 client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
199 client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
200 -- }}}
201
202 -- {{{ Autostart applications
203 require("autostart")
204 -- }}}