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