Advertisement
Guest User

Untitled

a guest
May 8th, 2015
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.09 KB | None | 0 0
  1. -- Standard awesome library
  2. require("awful")
  3. require("awful.autofocus")
  4. require("awful.rules")
  5. -- Theme handling library
  6. -- require("beautiful")
  7. -- Notification library
  8. require("naughty")
  9.  
  10. -- Load Debian menu entries
  11. require("debian.menu")
  12.  
  13. -- {{{ Error handling
  14. -- Check if awesome encountered an error during startup and fell back to
  15. -- another config (This code will only ever execute for the fallback config)
  16. if awesome.startup_errors then
  17.     naughty.notify({ preset = naughty.config.presets.critical,
  18.                      title = "Oops, there were errors during startup!",
  19.                      text = awesome.startup_errors })
  20. end
  21.  
  22. -- Handle runtime errors after startup
  23. do
  24.     local in_error = false
  25.     awesome.add_signal("debug::error", function (err)
  26.         -- Make sure we don't go into an endless error loop
  27.         if in_error then return end
  28.         in_error = true
  29.  
  30.         naughty.notify({ preset = naughty.config.presets.critical,
  31.                          title = "Oops, an error happened!",
  32.                          text = err })
  33.         in_error = false
  34.     end)
  35. end
  36. -- }}}
  37.  
  38. -- {{{ Variable definitions
  39. -- Themes define colours, icons, and wallpapers
  40. -- beautiful.init("/usr/share/awesome/themes/default/theme.lua")
  41.  
  42. -- This is used later as the default terminal and editor to run.
  43. terminal = "konsole"
  44. editor = os.getenv("EDITOR") or "gvim"
  45. editor_cmd = editor
  46.  
  47. -- Default modkey.
  48. -- Usually, Mod4 is the key with a logo between Control and Alt.
  49. -- If you do not like this or do not have such a key,
  50. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  51. -- However, you can use another modifier like Mod1, but it may interact with others.
  52. modkey = "Mod4"
  53.  
  54. -- Table of layouts to cover with awful.layout.inc, order matters.
  55. layouts =
  56. {
  57.     awful.layout.suit.tile,
  58.     awful.layout.suit.tile.left,
  59.     awful.layout.suit.tile.bottom,
  60.     awful.layout.suit.tile.top,
  61.     awful.layout.suit.fair,
  62.     awful.layout.suit.fair.horizontal,
  63.     awful.layout.suit.spiral,
  64.     awful.layout.suit.spiral.dwindle,
  65.     awful.layout.suit.max,
  66.     awful.layout.suit.max.fullscreen,
  67.     awful.layout.suit.magnifier,
  68.     awful.layout.suit.floating
  69. }
  70. -- }}}
  71.  
  72. -- {{{ Tags
  73. -- Define a tag table which hold all screen tags.
  74. tags = {}
  75. for s = 1, screen.count() do
  76.     -- Each screen has its own tag table.
  77.     tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])
  78. end
  79. -- }}}
  80.  
  81. function wrapped_kill(client)
  82.     if client.class ~= 'Plasma' then
  83.         client:kill()
  84.     end
  85. end
  86.  
  87. -- {{{ Mouse bindings
  88. -- root.buttons(awful.util.table.join(
  89. --     awful.button({ }, 3, function () mymainmenu:toggle() end),
  90. --     awful.button({ }, 4, awful.tag.viewnext),
  91. --     awful.button({ }, 5, awful.tag.viewprev)
  92. -- ))
  93. -- }}}
  94.  
  95. -- {{{ Key bindings
  96. globalkeys = awful.util.table.join(
  97.     awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
  98.     awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
  99.     awful.key({ modkey,           }, "Escape", awful.tag.history.restore),
  100.  
  101.     awful.key({ modkey,           }, "j",
  102.         function ()
  103.             awful.client.focus.byidx( 1)
  104.             if client.focus then client.focus:raise() end
  105.         end),
  106.     awful.key({ modkey,           }, "k",
  107.         function ()
  108.             awful.client.focus.byidx(-1)
  109.             if client.focus then client.focus:raise() end
  110.         end),
  111.     awful.key({ modkey,           }, "w", function () mymainmenu:show({keygrabber=true}) end),
  112.  
  113.     -- Layout manipulation
  114.     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
  115.     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
  116.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  117.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  118.     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
  119.     awful.key({ modkey,           }, "Tab",
  120.         function ()
  121.             awful.client.focus.history.previous()
  122.             if client.focus then
  123.                 client.focus:raise()
  124.             end
  125.         end),
  126.  
  127.     -- Standard program
  128.     awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
  129.     awful.key({ modkey, "Control" }, "r", awesome.restart),
  130.     awful.key({ modkey, "Shift"   }, "q", awesome.quit),
  131.  
  132.     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
  133.     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
  134.     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
  135.     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
  136.     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
  137.     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
  138.     awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
  139.     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
  140.  
  141.     awful.key({ modkey, "Control" }, "n", awful.client.restore),
  142.  
  143.     -- Prompt
  144.     awful.key({ modkey },            "r",     function () awful.util.spawn_with_shell("krunner") end),
  145.  
  146.     awful.key({ "Control", "Alt" },            "Escape", function () awful.util.spawn_with_shell("xkill") end)
  147.  
  148.     -- awful.key({ modkey }, "x",
  149.     --           function ()
  150.     --               awful.prompt.run({ prompt = "Run Lua code: " },
  151.     --               mypromptbox[mouse.screen].widget,
  152.     --               awful.util.eval, nil,
  153.     --               awful.util.getdir("cache") .. "/history_eval")
  154.     --           end)
  155. )
  156.  
  157. clientkeys = awful.util.table.join(
  158.     awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
  159.     awful.key({ modkey, "Shift"   }, "c",      function (c) wrapped_kill(c)                         end),
  160.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
  161.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  162.     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
  163.     awful.key({ modkey, "Shift"   }, "r",      function (c) c:redraw()                       end),
  164.     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
  165.     awful.key({ modkey,           }, "n",
  166.         function (c)
  167.             -- The client currently has the input focus, so it cannot be
  168.             -- minimized, since minimized clients can't have the focus.
  169.             c.minimized = true
  170.         end),
  171.     awful.key({ modkey,           }, "m",
  172.         function (c)
  173.             c.maximized_horizontal = not c.maximized_horizontal
  174.             c.maximized_vertical   = not c.maximized_vertical
  175.         end)
  176. )
  177.  
  178. -- Compute the maximum number of digit we need, limited to 9
  179. keynumber = 0
  180. for s = 1, screen.count() do
  181.    keynumber = math.min(9, math.max(#tags[s], keynumber));
  182. end
  183.  
  184. -- Bind all key numbers to tags.
  185. -- Be careful: we use keycodes to make it works on any keyboard layout.
  186. -- This should map on the top row of your keyboard, usually 1 to 9.
  187. for i = 1, keynumber do
  188.     globalkeys = awful.util.table.join(globalkeys,
  189.         awful.key({ modkey }, "#" .. i + 9,
  190.                   function ()
  191.                         local screen = mouse.screen
  192.                         if tags[screen][i] then
  193.                             awful.tag.viewonly(tags[screen][i])
  194.                         end
  195.                   end),
  196.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  197.                   function ()
  198.                       local screen = mouse.screen
  199.                       if tags[screen][i] then
  200.                           awful.tag.viewtoggle(tags[screen][i])
  201.                       end
  202.                   end),
  203.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  204.                   function ()
  205.                       if client.focus and tags[client.focus.screen][i] then
  206.                           awful.client.movetotag(tags[client.focus.screen][i])
  207.                       end
  208.                   end),
  209.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  210.                   function ()
  211.                       if client.focus and tags[client.focus.screen][i] then
  212.                           awful.client.toggletag(tags[client.focus.screen][i])
  213.                       end
  214.                   end))
  215. end
  216.  
  217. clientbuttons = awful.util.table.join(
  218.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  219.     awful.button({ modkey }, 1, awful.mouse.client.move),
  220.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  221.  
  222. -- Set keys
  223. root.keys(globalkeys)
  224. -- }}}
  225.  
  226. -- {{{ Rules
  227. awful.rules.rules = {
  228.     -- All clients will match this rule.
  229.     { rule = { },
  230.       properties = { -- border_width = beautiful.border_width,
  231.                      -- border_color = beautiful.border_normal,
  232.                      focus = true,
  233.                      keys = clientkeys,
  234.                      buttons = clientbuttons } },
  235.     { rule = { class = "MPlayer" },
  236.       properties = { floating = true } },
  237.     { rule = { class = "pinentry" }, properties = { floating = true } },
  238.     { rule = { class = ".lasma-desktop" }, properties = { floating = true } },
  239.     { rule = { class = "Pidgin" }, properties = { floating = true } },
  240.     { rule = { class = "[Aa]marok" }, properties = { floating = true } },
  241.     { rule = { class = "[Pp]lugin-container" }, properties = { floating = true } },
  242.     { rule = { class = "[Kk]calc" }, properties = { floating = true } },
  243.     { rule = { class = "[Kk]lipper" }, properties = { floating = true } }
  244.     -- Set Firefox to always map on tags number 2 of screen 1.
  245.     -- { rule = { class = "Firefox" },
  246.     --   properties = { tag = tags[1][2] } },
  247. }
  248. -- }}}
  249.  
  250. -- {{{ Signals
  251. -- Signal function to execute when a new client appears.
  252. client.add_signal("manage", function (c, startup)
  253.     -- Add a titlebar
  254.     -- awful.titlebar.add(c, { modkey = modkey })
  255.  
  256.     -- Enable sloppy focus
  257.     c:add_signal("mouse::enter", function(c)
  258.         if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  259.             and awful.client.focus.filter(c) then
  260.             client.focus = c
  261.         end
  262.     end)
  263.  
  264.     if not startup then
  265.         -- Set the windows at the slave,
  266.         -- i.e. put it at the end of others instead of setting it master.
  267.         -- awful.client.setslave(c)
  268.  
  269.         -- Put windows in a smart way, only if they does not set an initial position.
  270.         if not c.size_hints.user_position and not c.size_hints.program_position then
  271.             awful.placement.no_overlap(c)
  272.             awful.placement.no_offscreen(c)
  273.         end
  274.     end
  275. end)
  276.  
  277. -- client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  278. -- client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  279. -- -- }}}
  280.  
  281. awful.util.spawn_with_shell("compton") -- composite manager
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement