| 1 |
|
| 2 |
require("awful") |
| 3 |
require("awful.autofocus") |
| 4 |
require("awful.rules") |
| 5 |
|
| 6 |
require("beautiful") |
| 7 |
|
| 8 |
require("naughty") |
| 9 |
|
| 10 |
require("flaw") |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
beautiful.init("/usr/share/awesome/themes/default/theme.lua") |
| 15 |
|
| 16 |
|
| 17 |
local gadgets = {} |
| 18 |
|
| 19 |
|
| 20 |
gadgets.calendar = flaw.gadget.text.calendar( |
| 21 |
'', { clock_format = ' | %a %d %B - <span color="' .. beautiful.fg_focus .. '">%H:%M</span>' }) |
| 22 |
|
| 23 |
|
| 24 |
gadgets.title = flaw.gadget.text.title( |
| 25 |
'', { pattern = ' | <b><small>$title</small></b>' }) |
| 26 |
|
| 27 |
|
| 28 |
gadgets.gmail = flaw.gadget.text.gmail( |
| 29 |
'', { pattern = ' | GMail: <span color="' .. beautiful.fg_focus .. '">$count</span> ' }) |
| 30 |
gadgets.gmail:set_tooltip('Unread messages at $timestamp:\n$mails') |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
gadgets.alsa = flaw.gadget.text.alsa('0', { pattern = ' | Vol.:$s_volume% ' }) |
| 37 |
gadgets.alsa_bar = flaw.gadget.bar.alsa('0') |
| 38 |
gadgets.alsa_bar.hull:set_vertical(true) |
| 39 |
gadgets.alsa_bar.hull:set_height(18) |
| 40 |
gadgets.alsa_bar.hull:set_width(12) |
| 41 |
|
| 42 |
|
| 43 |
gadgets.alsa_bar.hull:set_background_color(beautiful.bg_normal) |
| 44 |
gadgets.alsa_bar.hull:set_gradient_colors( |
| 45 |
{ beautiful.fg_normal, beautiful.fg_focus, beautiful.fg_urgent}) |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
gadgets.cpu_graph = flaw.gadget.graph.cpu( |
| 52 |
'cpu', {}, { width = 60, height = 18 }) |
| 53 |
gadgets.cpu_graph.hull:set_color(beautiful.fg_normal) |
| 54 |
gadgets.cpu_graph.hull:set_border_color(beautiful.fg_normal) |
| 55 |
gadgets.cpu_graph.hull:set_background_color(beautiful.bg_normal) |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
gadgets.net_graph = flaw.gadget.graph.network( |
| 62 |
'eth0', {}, { width = 60, height = 18 }) |
| 63 |
gadgets.net_graph.hull:set_color(beautiful.fg_normal) |
| 64 |
gadgets.net_graph.hull:set_border_color(beautiful.fg_normal) |
| 65 |
gadgets.net_graph.hull:set_background_color(beautiful.bg_normal) |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
if flaw.battery ~= nil then |
| 71 |
gadgets.battery_icon = flaw.gadget.icon.battery( |
| 72 |
'BAT0', |
| 73 |
{ |
| 74 |
my_icons = { |
| 75 |
image(beautiful.icon_battery_low), |
| 76 |
image(beautiful.icon_battery_mid), |
| 77 |
image(beautiful.icon_battery_full) |
| 78 |
}, |
| 79 |
my_load_icon = image(beautiful.icon_battery_plugged), |
| 80 |
my_update = function(self) |
| 81 |
if self.provider.data.st_symbol == flaw.battery.STATUS_CHARGING then |
| 82 |
self.widget.image = self.my_load_icon |
| 83 |
else |
| 84 |
self.widget.image = self.my_icons[math.floor(self.provider.data.load / 30) + 1] |
| 85 |
end |
| 86 |
end |
| 87 |
}, |
| 88 |
{ |
| 89 |
image = image(beautiful.icon_battery_full) |
| 90 |
} |
| 91 |
) |
| 92 |
gadgets.battery_icon:add_event( |
| 93 |
flaw.event.EdgeTrigger:new{ condition = function(d) return d.load < 60 end }, |
| 94 |
function (g) g:my_update() end |
| 95 |
) |
| 96 |
gadgets.battery_icon:add_event( |
| 97 |
flaw.event.EdgeTrigger:new{ condition = function(d) return d.load < 30 end }, |
| 98 |
function (g) g:my_update() end |
| 99 |
) |
| 100 |
gadgets.battery_icon:add_event( |
| 101 |
flaw.event.EdgeTrigger:new{ |
| 102 |
condition = function(d) return d.st_symbol == flaw.battery.STATUS_CHARGING end }, |
| 103 |
function (g) g:my_update() end |
| 104 |
) |
| 105 |
gadgets.battery_icon:add_event( |
| 106 |
flaw.event.LatchTrigger:new{condition = function(d) return d.load < 10 end }, |
| 107 |
function(g) naughty.notify{ |
| 108 |
title = "Battery Warning", |
| 109 |
text = "Battery low! " .. g.provider.data.load .. "% left!", |
| 110 |
timeout = 10, |
| 111 |
position = "top_right", |
| 112 |
fg = beautiful.fg_focus, |
| 113 |
bg = beautiful.bg_focus} end |
| 114 |
) |
| 115 |
|
| 116 |
gadgets.battery_box = flaw.gadget.text.battery( |
| 117 |
'BAT0', |
| 118 |
{ pattern = '<span color="#99aa99">$load</span>% $time' } ) |
| 119 |
gadgets.battery_box:add_event( |
| 120 |
flaw.event.LatchTrigger:new{condition = function(d) return d.load < 60 end }, |
| 121 |
function(g) g.pattern = '<span color="#ffffff">$load</span>%' end |
| 122 |
) |
| 123 |
gadgets.battery_box:add_event( |
| 124 |
flaw.event.LatchTrigger:new{condition = function(d) return d.load < 30 end }, |
| 125 |
function(g) g.pattern = '<span color="#ff6565">$load</span>%' end |
| 126 |
) |
| 127 |
end |
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
terminal = "x-terminal-emulator" |
| 138 |
editor = os.getenv("EDITOR") or "editor" |
| 139 |
editor_cmd = terminal .. " -e " .. editor |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
modkey = "Mod4" |
| 147 |
|
| 148 |
|
| 149 |
layouts = |
| 150 |
{ |
| 151 |
awful.layout.suit.floating, |
| 152 |
awful.layout.suit.tile, |
| 153 |
awful.layout.suit.tile.left, |
| 154 |
awful.layout.suit.tile.bottom, |
| 155 |
awful.layout.suit.tile.top, |
| 156 |
awful.layout.suit.fair, |
| 157 |
awful.layout.suit.fair.horizontal, |
| 158 |
awful.layout.suit.spiral, |
| 159 |
awful.layout.suit.spiral.dwindle, |
| 160 |
awful.layout.suit.max, |
| 161 |
awful.layout.suit.max.fullscreen, |
| 162 |
awful.layout.suit.magnifier |
| 163 |
} |
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
tags = {} |
| 169 |
for s = 1, screen.count() do |
| 170 |
|
| 171 |
tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1]) |
| 172 |
end |
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
myawesomemenu = { |
| 178 |
{ "manual", terminal .. " -e man awesome" }, |
| 179 |
{ "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" }, |
| 180 |
{ "restart", awesome.restart }, |
| 181 |
{ "quit", awesome.quit } |
| 182 |
} |
| 183 |
|
| 184 |
mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon }, |
| 185 |
{ "open terminal", terminal } |
| 186 |
} |
| 187 |
}) |
| 188 |
|
| 189 |
mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon), |
| 190 |
menu = mymainmenu }) |
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
mywibox = {} |
| 197 |
mylayoutbox = {} |
| 198 |
mytaglist = {} |
| 199 |
mytaglist.buttons = awful.util.table.join( |
| 200 |
awful.button({ }, 1, awful.tag.viewonly), |
| 201 |
awful.button({ modkey }, 1, awful.client.movetotag), |
| 202 |
awful.button({ }, 3, awful.tag.viewtoggle), |
| 203 |
awful.button({ modkey }, 3, awful.client.toggletag), |
| 204 |
awful.button({ }, 4, awful.tag.viewnext), |
| 205 |
awful.button({ }, 5, awful.tag.viewprev) |
| 206 |
) |
| 207 |
|
| 208 |
for s = 1, screen.count() do |
| 209 |
|
| 210 |
|
| 211 |
mylayoutbox[s] = awful.widget.layoutbox(s) |
| 212 |
mylayoutbox[s]:buttons(awful.util.table.join( |
| 213 |
awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end), |
| 214 |
awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end), |
| 215 |
awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end), |
| 216 |
awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end))) |
| 217 |
|
| 218 |
mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons) |
| 219 |
|
| 220 |
|
| 221 |
mywibox[s] = awful.wibox({ position = "top", screen = s }) |
| 222 |
|
| 223 |
mywibox[s].widgets = { |
| 224 |
{ |
| 225 |
mylauncher, |
| 226 |
mytaglist[s], |
| 227 |
|
| 228 |
gadgets.calendar.widget, |
| 229 |
gadgets.gmail.widget, |
| 230 |
gadgets.alsa.widget, |
| 231 |
gadgets.alsa_bar.widget, |
| 232 |
|
| 233 |
gadgets.cpu_graph.widget or nil, |
| 234 |
|
| 235 |
gadgets.net_graph.widget or nil, |
| 236 |
gadgets.battery_box and gadgets.battery_box.widget or nil, |
| 237 |
gadgets.battery_icon and gadgets.battery_icon.widget or nil, |
| 238 |
gadgets.title.widget, |
| 239 |
|
| 240 |
layout = awful.widget.layout.horizontal.leftright |
| 241 |
}, |
| 242 |
mylayoutbox[s], |
| 243 |
layout = awful.widget.layout.horizontal.rightleft |
| 244 |
} |
| 245 |
end |
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
root.buttons(awful.util.table.join( |
| 250 |
awful.button({ }, 3, function () mymainmenu:toggle() end), |
| 251 |
awful.button({ }, 4, awful.tag.viewnext), |
| 252 |
awful.button({ }, 5, awful.tag.viewprev) |
| 253 |
)) |
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
globalkeys = awful.util.table.join( |
| 258 |
awful.key({ modkey, }, "Left", awful.tag.viewprev ), |
| 259 |
awful.key({ modkey, }, "Right", awful.tag.viewnext ), |
| 260 |
awful.key({ modkey, }, "Escape", awful.tag.history.restore), |
| 261 |
|
| 262 |
awful.key({ modkey, }, "j", |
| 263 |
function () |
| 264 |
awful.client.focus.byidx( 1) |
| 265 |
if client.focus then client.focus:raise() end |
| 266 |
end), |
| 267 |
awful.key({ modkey, }, "k", |
| 268 |
function () |
| 269 |
awful.client.focus.byidx(-1) |
| 270 |
if client.focus then client.focus:raise() end |
| 271 |
end), |
| 272 |
awful.key({ modkey, }, "w", function () mymainmenu:show(true) end), |
| 273 |
|
| 274 |
|
| 275 |
awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end), |
| 276 |
awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end), |
| 277 |
awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end), |
| 278 |
awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end), |
| 279 |
awful.key({ modkey, }, "u", awful.client.urgent.jumpto), |
| 280 |
awful.key({ modkey, }, "Tab", |
| 281 |
function () |
| 282 |
awful.client.focus.history.previous() |
| 283 |
if client.focus then |
| 284 |
client.focus:raise() |
| 285 |
end |
| 286 |
end), |
| 287 |
|
| 288 |
|
| 289 |
awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end), |
| 290 |
awful.key({ modkey, "Control" }, "r", awesome.restart), |
| 291 |
awful.key({ modkey, "Shift" }, "q", awesome.quit), |
| 292 |
|
| 293 |
awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end), |
| 294 |
awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end), |
| 295 |
awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end), |
| 296 |
awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end), |
| 297 |
awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end), |
| 298 |
awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end), |
| 299 |
awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end), |
| 300 |
awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end) |
| 301 |
) |
| 302 |
|
| 303 |
clientkeys = awful.util.table.join( |
| 304 |
awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end), |
| 305 |
awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end), |
| 306 |
awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ), |
| 307 |
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end), |
| 308 |
awful.key({ modkey, }, "o", awful.client.movetoscreen ), |
| 309 |
awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end), |
| 310 |
awful.key({ modkey, }, "n", function (c) c.minimized = not c.minimized end), |
| 311 |
awful.key({ modkey, }, "m", |
| 312 |
function (c) |
| 313 |
c.maximized_horizontal = not c.maximized_horizontal |
| 314 |
c.maximized_vertical = not c.maximized_vertical |
| 315 |
end) |
| 316 |
) |
| 317 |
|
| 318 |
|
| 319 |
keynumber = 0 |
| 320 |
for s = 1, screen.count() do |
| 321 |
keynumber = math.min(9, math.max(#tags[s], keynumber)); |
| 322 |
end |
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
for i = 1, keynumber do |
| 328 |
globalkeys = awful.util.table.join(globalkeys, |
| 329 |
awful.key({ modkey }, "#" .. i + 9, |
| 330 |
function () |
| 331 |
local screen = mouse.screen |
| 332 |
if tags[screen][i] then |
| 333 |
awful.tag.viewonly(tags[screen][i]) |
| 334 |
end |
| 335 |
end), |
| 336 |
awful.key({ modkey, "Control" }, "#" .. i + 9, |
| 337 |
function () |
| 338 |
local screen = mouse.screen |
| 339 |
if tags[screen][i] then |
| 340 |
awful.tag.viewtoggle(tags[screen][i]) |
| 341 |
end |
| 342 |
end), |
| 343 |
awful.key({ modkey, "Shift" }, "#" .. i + 9, |
| 344 |
function () |
| 345 |
if client.focus and tags[client.focus.screen][i] then |
| 346 |
awful.client.movetotag(tags[client.focus.screen][i]) |
| 347 |
end |
| 348 |
end), |
| 349 |
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, |
| 350 |
function () |
| 351 |
if client.focus and tags[client.focus.screen][i] then |
| 352 |
awful.client.toggletag(tags[client.focus.screen][i]) |
| 353 |
end |
| 354 |
end)) |
| 355 |
end |
| 356 |
|
| 357 |
clientbuttons = awful.util.table.join( |
| 358 |
awful.button({ }, 1, function (c) client.focus = c; c:raise() end), |
| 359 |
awful.button({ modkey }, 1, awful.mouse.client.move), |
| 360 |
awful.button({ modkey }, 3, awful.mouse.client.resize)) |
| 361 |
|
| 362 |
|
| 363 |
root.keys(globalkeys) |
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
awful.rules.rules = { |
| 368 |
|
| 369 |
{ rule = { }, |
| 370 |
properties = { border_width = beautiful.border_width, |
| 371 |
border_color = beautiful.border_normal, |
| 372 |
focus = true, |
| 373 |
keys = clientkeys, |
| 374 |
buttons = clientbuttons } }, |
| 375 |
{ rule = { class = "MPlayer" }, |
| 376 |
properties = { floating = true } }, |
| 377 |
{ rule = { class = "pinentry" }, |
| 378 |
properties = { floating = true } }, |
| 379 |
{ rule = { class = "gimp" }, |
| 380 |
properties = { floating = true } }, |
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
} |
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
client.add_signal("manage", function (c, startup) |
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
c:add_signal("mouse::enter", function(c) |
| 395 |
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier |
| 396 |
and awful.client.focus.filter(c) then |
| 397 |
client.focus = c |
| 398 |
end |
| 399 |
end) |
| 400 |
|
| 401 |
if not startup then |
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
if not c.size_hints.user_position and not c.size_hints.program_position then |
| 408 |
awful.placement.no_overlap(c) |
| 409 |
awful.placement.no_offscreen(c) |
| 410 |
end |
| 411 |
end |
| 412 |
end) |
| 413 |
|
| 414 |
client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end) |
| 415 |
client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end) |
| 416 |
|
| 417 |
|
| 418 |
flaw.check_modules() |