*nohtml*

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