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