*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.7;
  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.currenttags, 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         b.hidden  = not b.visible;
 142         awful.spawn('polybar-msg cmd toggle', false);
 143     end),
 144 
 145     awful.key(Mod4Ctrl, 'g', function()
 146         local t = awful.screen.focused().selected_tag;
 147         t.gap = t.gap == 0 and beautiful.useless_gap or 0;
 148     end)
 149 );
 150 
 151 for k, v in pairs({'Up', 'Down', 'Left', 'Right'}) do
 152     keys = gears.table.join(keys,
 153         awful.key(Mod4,     v, function() awful.client.focus.bydirection(v:lower()) end),
 154         awful.key(Mod4Shft, v, function()  awful.client.swap.bydirection(v:lower()) end)
 155     );
 156 end
 157 
 158 for i = 1, 9 do
 159     local tag = awful.screen.focused().tags[i];
 160     keys = gears.table.join(keys,
 161         awful.key(Mod4,     'Tab',        awful.tag.history.restore),
 162         awful.key(Mod4,     '#'..(i + 9), function() tag:view_only() end),
 163         awful.key(Mod4Shft, '#'..(i + 9), function() client.focus:move_to_tag(tag) end),
 164         awful.key(Mod4Ctrl, '#'..(i + 9), function() awful.tag.viewtoggle(tag) end)
 165     );
 166 end
 167 
 168 root.keys(keys);
 169 
 170 -- }}}
 171 -- Client {{{
 172 
 173 table.insert(awful.rules.rules, { rule = {}, properties = {
 174     raise  = true,
 175     screen = awful.screen.preferred,
 176     focus  = awful.client.focus.filter,
 177 
 178     buttons = gears.table.join(
 179         awful.button({},   1, function(c) client.focus = c; c:raise() end),
 180         awful.button(Mod4, 1, awful.mouse.client.move),
 181         awful.button(Mod4, 3, awful.mouse.client.resize)
 182     ),
 183 
 184     keys = gears.table.join(
 185         awful.key(Mod4, 'q',      function(c) c:kill() end),
 186         awful.key(Mod4, 'Return', function(c) c:swap(awful.client.getmaster()) end),
 187 
 188         awful.key(Mod4,     'z', function(c) c.fullscreen = not c.fullscreen end),
 189         awful.key(Mod4Shft, 'z', function(c) c.floating   = not c.floating   end)
 190     )
 191 }});
 192 
 193 -- }}}
 194 -- Titlebar {{{
 195 
 196 client.connect_signal('request::titlebars', function(c)
 197     awful.titlebar(c, { size = beautiful.titlebar_height }):setup({
 198         layout = wibox.layout.align.horizontal,
 199 
 200         {
 201             awful.titlebar.widget.iconwidget(c),
 202             layout = wibox.layout.fixed.horizontal
 203         },
 204 
 205         {
 206             {
 207                 align  = 'center',
 208                 widget = awful.titlebar.widget.titlewidget(c)
 209             },
 210             layout  = wibox.layout.flex.horizontal,
 211             buttons = gears.table.join(
 212                 awful.button({}, 1, function() awful.mouse.client.move(); client.focus:raise() end),
 213                 awful.button({}, 2, function() client.focus:kill() end),
 214                 awful.button({}, 3, function() awful.mouse.client.resize() end)
 215             )
 216         }
 217     });
 218 end)
 219 
 220 -- }}}
 221 -- Rules {{{
 222 
 223 table.insert(awful.rules.rules, {
 224     rule = { type = 'dock' },
 225     properties = { focusable = false }
 226 });
 227 
 228 table.insert(awful.rules.rules, {
 229     rule_any = { type = { 'normal', 'dialog' } },
 230     properties = { titlebars_enabled = true }
 231 });
 232 
 233 table.insert(awful.rules.rules, {
 234     rule_any = { role  = { 'pop-up' }, class = { 'Wine' } },
 235     properties = { floating  = true }
 236 });
 237 
 238 table.insert(awful.rules.rules, {
 239     rule = { x = 0 },
 240     properties = { placement = awful.placement.centered }
 241 });
 242 
 243 table.insert(awful.rules.rules, {
 244     rule = { class = 'Audacious' },
 245     properties = { titlebars_enabled = false }
 246 });
 247 
 248 -- }}}
 249 -- Signals {{{
 250 
 251 require('awful.autofocus');
 252 
 253 screen.connect_signal('arrange', function(s)
 254     if
 255         s.geometry.width < 1650 or s.selected_tag.gap == 0 or
 256         #s.tiled_clients > 1 or awful.layout.get() == awful.layout.suit.max
 257     then
 258         if s.padding.left ~= 0 then
 259             s.padding = {};
 260         end
 261     else
 262         if s.padding.left == 0 then
 263             s.padding = {
 264                 left  = beautiful.padding,
 265                 right = beautiful.padding
 266             };
 267         end
 268     end
 269 
 270     local fullscreen = false;
 271     local nogaps = #s.tiled_clients > 1 and s.selected_tag.gap == 0;
 272 
 273     for _, c in pairs(s.clients) do
 274         fullscreen = fullscreen or c.fullscreen;
 275     end
 276 
 277     for _, c in pairs(s.clients) do
 278         c.ontop = c.floating and not fullscreen;
 279         c.border_width = not c.floating and nogaps and beautiful.border_width or 0;
 280     end
 281 
 282     local bar = awful.screen:focused().bar;
 283 
 284     if fullscreen then
 285         bar.visible = false;
 286         awful.spawn('polybar-msg cmd hide', false);
 287     elseif not bar.hidden then
 288         bar.visible = true;
 289         awful.spawn('polybar-msg cmd show', false);
 290     end
 291 end);
 292 
 293 client.connect_signal('mouse::enter', function(c) client.focus = c end);
 294 client.connect_signal('property::maximized', function(c) c.maximized = false end);
 295 
 296 client.connect_signal('focus',   function(c) c.border_color = beautiful.border_focus end);
 297 client.connect_signal('unfocus', function(c) c.border_color = beautiful.border_normal end);
 298 
 299 -- }}}