config/awesome/rc.lua

   1 gears = require('gears');
   2 awful = require('awful');
   3 wibox = require('wibox');
   4 
   5 require('awful.autofocus');
   6 
   7 Mod1 = {'Mod1'};
   8 Mod1Shift = {'Mod1', 'Shift'};
   9 
  10 Mod4 = {'Mod4'};
  11 Mod4Alt = {'Mod4', 'Mod1'};
  12 Mod4Ctrl = {'Mod4', 'Control'};
  13 Mod4Shift = {'Mod4', 'Shift'};
  14 Mod4CtrlShift = {'Mod4', 'Control', 'Shift'};
  15 
  16 awful.layout.layouts = {
  17     awful.layout.suit.tile,
  18     awful.layout.suit.tile.bottom,
  19 };
  20 
  21 -- Colors {{{
  22 
  23 beautiful = require('beautiful');
  24 beautiful.init(gears.filesystem.get_themes_dir()..'default/theme.lua');
  25 
  26 xresources = require('beautiful.xresources');
  27 xrdb = xresources.get_current_theme();
  28 
  29 beautiful.font = 'Terminus 8';
  30 
  31 beautiful.bg_normal = xrdb.background;
  32 beautiful.fg_normal = xrdb.foreground;
  33 beautiful.border_normal = beautiful.bg_normal;
  34 
  35 beautiful.bg_focus = xrdb.foreground;
  36 beautiful.fg_focus = xrdb.background;
  37 beautiful.border_focus  = beautiful.bg_focus;
  38 
  39 beautiful.useless_gap = 20;
  40 beautiful.border_width = 0;
  41 
  42 -- }}}
  43 
  44 root_m = gears.table.join(
  45     awful.button({}, 3, function() end)
  46 );
  47 
  48 root_k = gears.table.join(
  49     awful.key(Mod4CtrlShift, 'r', awesome.restart),
  50     awful.key(Mod4CtrlShift, 'q', awesome.quit),
  51 
  52     awful.key(Mod4, 'Tab', awful.tag.viewnext),
  53     awful.key(Mod4Shift, 'Tab', awful.tag.viewprev),
  54 
  55     awful.key(Mod4, 'Up', function() awful.client.focus.byidx(-1) end),
  56     awful.key(Mod4, 'Down', function() awful.client.focus.byidx(1) end),
  57     awful.key(Mod4, 'Left', function() awful.client.focus.byidx(-1) end),
  58     awful.key(Mod4, 'Right', function() awful.client.focus.byidx(1) end),
  59 
  60     awful.key(Mod1, 'Tab', function() awful.client.focus.byidx(1) end),
  61     awful.key(Mod1Shift, 'Tab', function() awful.client.focus.byidx(-1) end),
  62 
  63     awful.key(Mod4Shift, 'Up', function() awful.client.swap.byidx(-1) end),
  64     awful.key(Mod4Shift, 'Down', function() awful.client.swap.byidx(1) end),
  65     awful.key(Mod4Shift, 'Left', function() awful.client.swap.byidx(-1) end),
  66     awful.key(Mod4Shift, 'Right', function() awful.client.swap.byidx(1) end),
  67 
  68     awful.key(Mod4Ctrl, 'v', function() awful.layout.set(awful.layout.suit.tile) end),
  69     awful.key(Mod4Ctrl, 's', function() awful.layout.set(awful.layout.suit.tile.bottom) end),
  70 
  71     awful.key(Mod4Ctrl, 'g', function()
  72         if awful.tag.getgap() == 0 then
  73             beautiful.border_width = 0;
  74             awful.tag.setgap(20);
  75         else
  76             beautiful.border_width = 2;
  77             awful.tag.setgap(0);
  78         end
  79     end),
  80 
  81     awful.key(Mod4Ctrl, 'Up', function() awful.client.incwfact(-0.05) end),
  82     awful.key(Mod4Ctrl, 'Down', function() awful.client.incwfact(0.05) end),
  83     awful.key(Mod4Ctrl, 'Left', function() awful.tag.incmwfact(-0.01) end),
  84     awful.key(Mod4Ctrl, 'Right', function() awful.tag.incmwfact(0.01) end)
  85 );
  86 
  87 for i = 1, 9 do
  88     root_k = gears.table.join(root_k,
  89         awful.key(Mod4, '#'..(i + 9), function()
  90             local tag = awful.screen.focused().tags[i];
  91 
  92             if tag then
  93                 tag:view_only();
  94             end
  95         end),
  96 
  97         awful.key(Mod4Shift, '#'..(i + 9), function()
  98             if client.focus then
  99                 local tag = client.focus.screen.tags[i];
 100 
 101                 if tag then
 102                     client.focus:move_to_tag(tag);
 103                 end
 104             end
 105         end)
 106     );
 107 end
 108 
 109 window_m = gears.table.join(
 110     awful.button({}, 1, function(c) client.focus = c; c:raise() end),
 111     awful.button(Mod4, 1, awful.mouse.client.move),
 112     awful.button(Mod4, 3, awful.mouse.client.resize)
 113 );
 114 
 115 window_k = gears.table.join(
 116     awful.key(Mod4, 'q', function(c) c:kill() end),
 117     awful.key(Mod4, 'Return', function(c) c:swap(awful.client.getmaster()) end),
 118 
 119     awful.key(Mod4Ctrl, 'f', awful.client.floating.toggle),
 120     awful.key(Mod4Ctrl, 'z', function(c) c.fullscreen = not c.fullscreen; c:raise() end)
 121 );
 122 
 123 titlebar_m = gears.table.join(
 124     awful.button({}, 1, function() awful.mouse.client.move(client.focus) end),
 125     awful.button({}, 2, function() client.focus:kill() end),
 126     awful.button({}, 3, function() awful.mouse.client.resize(client.focus) end)
 127 );
 128 
 129 layout_m = gears.table.join(
 130     awful.button({}, 1, function() awful.layout.inc( 1) end),
 131     awful.button({}, 3, function() awful.layout.inc(-1) end),
 132     awful.button({}, 4, function() awful.layout.inc( 1) end),
 133     awful.button({}, 5, function() awful.layout.inc(-1) end)
 134 );
 135 
 136 taglist_m = gears.table.join(
 137     awful.button({}, 1, function(t) t:view_only() end),
 138     awful.button({}, 3, awful.tag.viewtoggle),
 139     awful.button({}, 4, function(t) awful.tag.viewprev(t.screen) end),
 140     awful.button({}, 5, function(t) awful.tag.viewnext(t.screen) end)
 141 );
 142 
 143 tasklist_m = gears.table.join(
 144     awful.button({}, 1, function(c) client.focus = c; c:raise(); c.first_tag:view_only() end),
 145     awful.button({}, 2, function(c) c:kill() end),
 146     awful.button({}, 4, function(c) c.byidx(1) end),
 147     awful.button({}, 5, function(c) c.byidx(-1) end)
 148 );
 149 
 150 -- Desktop {{{
 151 
 152 root.keys(root_k);
 153 root.buttons(root_m);
 154 
 155 awful.screen.connect_for_each_screen(function(s)
 156     awful.tag({' 1 ', ' 2 ', ' 3 ', ' 4 '}, s, awful.layout.layouts[1]);
 157 
 158     s.mylayoutbox = awful.widget.layoutbox(s);
 159     s.mylayoutbox:buttons(layout_m);
 160 
 161     s.mywibox = awful.wibar({position = 'top', screen = s, height = 28});
 162     s.mywibox:setup {
 163         layout = wibox.layout.align.horizontal,
 164 
 165         {
 166             layout = wibox.layout.fixed.horizontal,
 167             awful.widget.taglist(s, awful.widget.taglist.filter.all, taglist_m)
 168         },
 169 
 170         {
 171             layout = wibox.layout.fixed.horizontal,
 172             awful.widget.tasklist(s, awful.widget.tasklist.filter.alltags, tasklist_m, {
 173                 icon_size = 16,
 174             });
 175         },
 176 
 177         {
 178             layout = wibox.layout.fixed.horizontal,
 179             wibox.widget.systray(),
 180             awful.widget.keyboardlayout(),
 181             wibox.widget.textclock(),
 182             s.mylayoutbox,
 183         }
 184     };
 185 end);
 186 
 187 -- }}}
 188 -- Rules {{{
 189 
 190 awful.rules.rules = {
 191     {
 192         rule = {},
 193         properties = {
 194             border_width = beautiful.border_width,
 195             border_color = beautiful.border_normal,
 196             focus = awful.client.focus.filter,
 197             raise = true,
 198             keys = window_k,
 199             buttons = window_m,
 200             screen = awful.screen.preferred,
 201             placement = (awful.placement.no_overlap + awful.placement.no_offscreen)
 202         }
 203     },
 204 
 205     {
 206         rule_any = {
 207             instance = {'DTA', 'copyq'},
 208             class = {'Sxiv'},
 209             name = {'Event Tester'},
 210             role = {'pop-up', 'xfce4-terminal-dropdown'}
 211         },
 212 
 213         properties = {floating = true}
 214     },
 215 
 216     {
 217         rule_any = {type = { 'normal', 'dialog'}},
 218         properties = {titlebars_enabled = true}
 219     }
 220 }
 221 
 222 -- }}}
 223 -- Signals {{{
 224 
 225 awesome.connect_signal('exit', function(c)
 226     os.execute([[
 227         sleep 0.1 &&
 228         pkill -USR1 polybar &
 229         pkill -USR1 compron &
 230     ]]);
 231 end);
 232 
 233 client.connect_signal('manage', function(c)
 234     if not awesome.startup then
 235         awful.client.setslave(c);
 236     end
 237 end);
 238 
 239 client.connect_signal('request::titlebars', function(c)
 240     awful.titlebar(c, {size = 16}):setup({
 241         {
 242             awful.titlebar.widget.iconwidget(c),
 243             buttons = titlebar_m,
 244             layout  = wibox.layout.fixed.horizontal
 245         },
 246 
 247         {
 248             {align  = 'center', widget = awful.titlebar.widget.titlewidget(c)},
 249             buttons = titlebar_m,
 250             layout  = wibox.layout.flex.horizontal
 251         },
 252 
 253         {
 254             buttons = titlebar_m,
 255             layout  = wibox.layout.fixed.horizontal()
 256         },
 257 
 258         layout = wibox.layout.align.horizontal
 259     });
 260 end)
 261 
 262 client.connect_signal('mouse::enter', function(c)
 263     if
 264         awful.client.focus.filter(c) and
 265         awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
 266     then
 267         client.focus = c;
 268     end
 269 end);
 270 
 271 client.connect_signal('focus', function(c) c.border_color = beautiful.border_focus end);
 272 client.connect_signal('unfocus', function(c) c.border_color = beautiful.border_normal end);
 273 
 274 -- }}}