[download]

config/awesome/rc.lua

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