[download]

config/awesome/rc.lua

   1 local gears = require("gears")
   2 local awful = require("awful")
   3 local wibox = require("wibox")
   4 local beautiful = require("beautiful")
   5 
   6 beautiful.font = "Terminus 9"
   7 beautiful.master_width_factor = 0.55
   8 
   9 beautiful.wibar_width  = 0.75
  10 beautiful.wibar_height = 18
  11 
  12 beautiful.tasklist_spacing = 5
  13 awesome.set_preferred_icon_size(48)
  14 
  15 beautiful.border_width = 2
  16 beautiful.titlebar_height = 16
  17 
  18 beautiful.padding = 300
  19 beautiful.gaps_outer  = 15
  20 beautiful.gaps_inner  = 15
  21 
  22 awful.rules.rules = {}
  23 awful.layout.layouts = {
  24     awful.layout.suit.tile,
  25     awful.layout.suit.floating,
  26     awful.layout.suit.max
  27 }
  28 
  29 Mod1  = { "Mod1" }
  30 Mod1s = { "Mod1", "Shift" }
  31 
  32 Mod4  = { "Mod4" }
  33 Mod4a = { "Mod4", "Mod1"    }
  34 Mod4s = { "Mod4", "Shift"   }
  35 Mod4c = { "Mod4", "Control" }
  36 
  37 -- Colors {{{
  38 
  39 local bg = awesome.xrdb_get_value("", "Awesome.background")
  40 local ba = awesome.xrdb_get_value("", "Awesome.background_rgba")
  41 local fg = awesome.xrdb_get_value("", "Awesome.foreground")
  42 local ug = awesome.xrdb_get_value("", "Awesome.yellow1")
  43 
  44 beautiful.bg_normal = ba
  45 beautiful.fg_normal = fg
  46 beautiful.border_normal = ba
  47 
  48 beautiful.bg_focus = fg
  49 beautiful.fg_focus = bg
  50 beautiful.border_focus  = fg
  51 
  52 beautiful.bg_urgent = ug
  53 beautiful.fg_urgent = bg
  54 beautiful.border_urgent = ug
  55 
  56 theme_assets = require("beautiful.theme_assets")
  57 beautiful.taglist_squares_sel   = theme_assets.taglist_squares_sel(4, fg)
  58 beautiful.taglist_squares_unsel = theme_assets.taglist_squares_unsel(4, fg)
  59 
  60 beautiful.tasklist_bg_normal = "#0000"
  61 
  62 -- }}}
  63 -- Wibar {{{
  64 
  65 awful.screen.connect_for_each_screen(function(s)
  66     awful.tag({ "www", "dev", "alt", "doc", "srv", "vid" }, s, awful.layout.layouts[1])
  67 
  68     awful.widget.layoutbox(s):buttons(gears.table.join(
  69         awful.button({}, 1, function() awful.layout.set(awful.layout.layouts[1]) end),
  70         awful.button({}, 2, function() awful.layout.set(awful.layout.layouts[2]) end),
  71         awful.button({}, 3, function() awful.layout.set(awful.layout.layouts[3]) end)
  72     ))
  73 
  74     s.bar = awful.wibar({ type = "dock" })
  75     s.bar:setup({ layout = wibox.layout.fixed.horizontal, {
  76         layout = wibox.layout.align.horizontal,
  77         forced_width = (s.geometry.width * beautiful.wibar_width),
  78 
  79         {
  80             layout = wibox.layout.fixed.horizontal,
  81             awful.widget.taglist(s, awful.widget.taglist.filter.all, gears.table.join(
  82                 awful.button({}, 1, function(t) t:view_only() end),
  83                 awful.button({}, 3, awful.tag.viewtoggle),
  84 
  85                 awful.button(Mod4, 1, function(t) client.focus:move_to_tag(t) end),
  86                 awful.button(Mod4, 3, function(t) client.focus:toggle_tag(t) end)
  87             )),
  88             wibox.widget.textbox(" ["),
  89             awful.widget.layoutbox(s),
  90             wibox.widget.textbox("] ")
  91         },
  92 
  93         {
  94             layout = wibox.layout.fixed.horizontal,
  95             awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, gears.table.join(
  96                 awful.button({}, 1, function(c) client.focus = c; c:raise() end),
  97                 awful.button({}, 2, function(c) c:kill() end),
  98                 awful.button({}, 3, function(c) c:swap(awful.client.getmaster()) end),
  99                 awful.button({}, 4, function() awful.client.focus.byidx(-1) end),
 100                 awful.button({}, 5, function() awful.client.focus.byidx( 1) end)
 101             ))
 102         },
 103 
 104         {
 105             layout = wibox.layout.fixed.horizontal,
 106             wibox.widget.textbox(" "),
 107             wibox.widget.systray()
 108         }
 109     }})
 110 end)
 111 
 112 -- }}}
 113 -- Keys {{{
 114 
 115 table.insert(awful.rules.rules, { rule = {}, properties = {
 116     raise  = true,
 117     screen = awful.screen.preferred,
 118     focus  = awful.client.focus.filter,
 119 
 120     buttons = gears.table.join(
 121         awful.button({},   1, function(c) c:raise() end),
 122         awful.button(Mod4, 1, function(c) c.floating = true; awful.mouse.client.move(c); c:raise() end),
 123         awful.button(Mod4, 3, function(c) c.floating = true; awful.mouse.client.resize(c); c:raise() end)
 124     ),
 125 
 126     keys = gears.table.join(
 127         awful.key(Mod4,  "q",     function(c) c:kill() end),
 128         awful.key(Mod4,  "z",     function(c) c:swap(awful.client.getmaster()) end),
 129         awful.key(Mod4s, "z",     function(c) c.fullscreen = not c.fullscreen end),
 130         awful.key(Mod4s, "space", function(c) c.floating   = not c.floating end)
 131     )
 132 }})
 133 
 134 root.keys(gears.table.join(root.keys(),
 135     awful.key(Mod1,  "Tab", function() awful.client.focus.byidx( 1) end),
 136     awful.key(Mod1s, "Tab", function() awful.client.focus.byidx(-1) end),
 137 
 138     awful.key(Mod4, "Up",    function() awful.client.focus.byidx(-1) end),
 139     awful.key(Mod4, "Down",  function() awful.client.focus.byidx( 1) end),
 140     awful.key(Mod4, "Left",  function() awful.client.focus.byidx(-1) end),
 141     awful.key(Mod4, "Right", function() awful.client.focus.byidx( 1) end),
 142 
 143     awful.key(Mod4s, "Up",    function() awful.client.swap.byidx(-1) end),
 144     awful.key(Mod4s, "Down",  function() awful.client.swap.byidx( 1) end),
 145     awful.key(Mod4s, "Left",  function() awful.client.swap.byidx(-1) end),
 146     awful.key(Mod4s, "Right", function() awful.client.swap.byidx( 1) end),
 147 
 148     awful.key(Mod4c, "Left",  function() awful.tag.incmwfact(-0.01) end),
 149     awful.key(Mod4c, "Right", function() awful.tag.incmwfact( 0.01) end),
 150 
 151     awful.key(Mod4c, "i", function() awful.tag.incnmaster( 1) end),
 152     awful.key(Mod4c, "o", function() awful.tag.incnmaster(-1) end),
 153 
 154     awful.key(Mod4c, "t", function() awful.layout.set(awful.layout.suit.tile) end),
 155     awful.key(Mod4c, "f", function() awful.layout.set(awful.layout.suit.floating) end),
 156     awful.key(Mod4c, "z", function() awful.layout.set(awful.layout.suit.max) end),
 157     awful.key(Mod4c, "g", function() awful.layout.set(awful.layout.suit.fair) end),
 158     awful.key(Mod4c, "c", function() awful.layout.set(awful.layout.suit.magnifier) end),
 159     awful.key(Mod4c, "v", function()
 160         local t = awful.screen.focused().selected_tag
 161         t.gap = t.gap == 0 and beautiful.gaps_inner or 0
 162     end)
 163 ))
 164 
 165 for i = 1, 9 do
 166     local t = awful.screen.focused().tags[i]
 167     root.keys(gears.table.join(root.keys(),
 168         awful.key(Mod4,  "Tab",        awful.tag.history.restore),
 169         awful.key(Mod4,  "#"..(i + 9), function() t:view_only() end),
 170         awful.key(Mod4s, "#"..(i + 9), function() client.focus:move_to_tag(t) end),
 171         awful.key(Mod4c, "#"..(i + 9), function() awful.tag.viewtoggle(t) end),
 172         awful.key(Mod4a, "#"..(i + 9), function() client.focus:toggle_tag(t) end)
 173     ))
 174 end
 175 
 176 -- }}}
 177 -- Titlebar {{{
 178 
 179 client.connect_signal("request::titlebars", function(c)
 180     c.has_titlebar = true
 181     awful.titlebar(c, { size = beautiful.titlebar_height }):setup({
 182         layout = wibox.layout.align.horizontal,
 183 
 184         {
 185             wibox.widget.textbox(" "),
 186             awful.titlebar.widget.iconwidget(c),
 187             layout = wibox.layout.fixed.horizontal
 188         },
 189 
 190         {
 191             {
 192                 align  = "center",
 193                 widget = awful.titlebar.widget.titlewidget(c)
 194             },
 195             layout  = wibox.layout.flex.horizontal,
 196             buttons = gears.table.join(
 197                 awful.button({}, 1, function() awful.mouse.client.move() end),
 198                 awful.button({}, 2, function() client.focus:kill() end),
 199                 awful.button({}, 3, function() awful.mouse.client.resize() end)
 200             )
 201         }
 202     })
 203 end)
 204 
 205 -- }}}
 206 -- Rules {{{
 207 
 208 table.insert(awful.rules.rules, {
 209     rule = { type = "dock" },
 210     properties = { focusable = false }
 211 })
 212 
 213 table.insert(awful.rules.rules, {
 214     rule_any = { type = { "normal", "dialog" } },
 215     properties = { titlebars_enabled = true }
 216 })
 217 
 218 table.insert(awful.rules.rules, {
 219     rule_any = {
 220         role  = { "pop-up" },
 221         class = {
 222             "explorer.exe",
 223             "Xfce4-settings-manager",
 224         }
 225     },
 226     properties = { floating  = true }
 227 })
 228 
 229 table.insert(awful.rules.rules, {
 230     rule = { x = 0 },
 231     properties = { placement = awful.placement.centered }
 232 })
 233 
 234 table.insert(awful.rules.rules, {
 235     rule = { class = "Audacious" },
 236     properties = { titlebars_enabled = false }
 237 })
 238 
 239 -- }}}
 240 -- Signals {{{
 241 
 242 require("awful.autofocus")
 243 
 244 screen.connect_signal("arrange", function(s) -- {{{
 245     if s.selected_tag.gap == 0 or s.selected_tag.layout == awful.layout.suit.max then
 246         if s.padding.left ~= 0 then s.padding = {} end
 247         return
 248     end
 249 
 250     if #s.tiled_clients == 1 then
 251         local padding = {
 252             top    = beautiful.gaps_outer - beautiful.gaps_inner,
 253             bottom = beautiful.gaps_outer - beautiful.gaps_inner,
 254             left   = beautiful.padding    - beautiful.gaps_inner,
 255             right  = beautiful.padding    - beautiful.gaps_inner
 256         }
 257 
 258         if s.padding.left ~= padding.left then s.padding = padding end
 259     elseif #s.tiled_clients > 1 then
 260         local padding = {
 261             top    = beautiful.gaps_outer - beautiful.gaps_inner,
 262             bottom = beautiful.gaps_outer - beautiful.gaps_inner,
 263             left   = beautiful.gaps_outer - beautiful.gaps_inner,
 264             right  = beautiful.gaps_outer - beautiful.gaps_inner
 265         }
 266 
 267         if s.padding.left ~= padding.left then s.padding = padding end
 268     end
 269 end) -- }}}
 270 screen.connect_signal("arrange", function(s) -- {{{
 271     for _, c in pairs(s.clients) do
 272         c.border_width = s.selected_tag.gap == 0 and
 273         not c.floating and beautiful.border_width or 0
 274 
 275         if c.has_titlebar then
 276             awful.titlebar[c.border_width == 0 and "show" or "hide"](c)
 277         end
 278     end
 279 end) -- }}}
 280 screen.connect_signal("arrange", function(s) -- {{{
 281     local fullscreen = false
 282 
 283     for _, c in pairs(s.clients) do fullscreen = fullscreen or c.fullscreen end
 284     for _, c in pairs(s.clients) do c.ontop = c.floating and not fullscreen end
 285 end) -- }}}
 286 
 287 client.connect_signal("mouse::enter", function(c) client.focus = c end)
 288 client.connect_signal("property::maximized", function(c) c.maximized = false end)
 289 
 290 client.connect_signal("focus",   function(c) c.border_color = beautiful.border_focus end)
 291 client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
 292 
 293 awesome.register_xproperty("_COMPTON_SHADOW", "boolean")
 294 client.connect_signal("property::floating", function(c)
 295     c:set_xproperty("_COMPTON_SHADOW", c.floating or nil)
 296 end)
 297 
 298 -- }}}