Guest User

Awesome 3.4 - rc.lua

a guest
Mar 30th, 2012
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 16.17 KB | None | 0 0
  1. -- Standard awesome library
  2. require("awful")
  3. require("awful.autofocus")
  4. require("awful.rules")
  5. -- Widget and layout library
  6. require("wibox")
  7. -- Theme handling library
  8. require("beautiful")
  9. -- Notification library
  10. require("naughty")
  11. require("menubar")
  12. --User added
  13. require("vicious")
  14.  
  15. -- {{{ Error handling
  16. -- Check if awesome encountered an error during startup and fell back to
  17. -- another config (This code will only ever execute for the fallback config)
  18. if awesome.startup_errors then
  19.     naughty.notify({ preset = naughty.config.presets.critical,
  20.                      title = "Oops, there were errors during startup!",
  21.                      text = awesome.startup_errors })
  22. end
  23.  
  24. -- Handle runtime errors after startup
  25. do
  26.     local in_error = false
  27.     awesome.connect_signal("debug::error", function (err)
  28.         -- Make sure we don't go into an endless error loop
  29.         if in_error then return end
  30.         in_error = true
  31.  
  32.         naughty.notify({ preset = naughty.config.presets.critical,
  33.                          title = "Oops, an error happened!",
  34.                          text = err })
  35.         in_error = false
  36.     end)
  37. end
  38. -- }}}
  39.  
  40. -- {{{ Variable definitions
  41. -- Themes define colours, icons, and wallpapers
  42. --beautiful.init("/home/joel/.config/awesome/themes/current_theme/theme.lua")
  43. beautiful.init(awful.util.getdir("config") .. "/themes/current_theme/theme.lua")
  44.  
  45. -- This is used later as the default terminal and editor to run.
  46. terminal = "urxvt"
  47. editor = "subl"
  48. --editor_cmd = terminal .. " -e " .. editor
  49. editor_cmd = terminal .. editor
  50.  
  51. -- Default modkey.
  52. -- Usually, Mod4 is the key with a logo between Control and Alt.
  53. -- If you do not like this or do not have such a key,
  54. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  55. -- However, you can use another modifier like Mod1, but it may interact with others.
  56. modkey = "Mod4"
  57.  
  58. -- Table of layouts to cover with awful.layout.inc, order matters.
  59. layouts =
  60. {
  61.     awful.layout.suit.floating, -- 1
  62.     awful.layout.suit.tile, -- 2
  63.     awful.layout.suit.tile.left, -- 3
  64. --    awful.layout.suit.tile.bottom, -- 4
  65. --    awful.layout.suit.tile.top, -- 5
  66. --    awful.layout.suit.fair, -- 6
  67. --    awful.layout.suit.fair.horizontal, -- 7
  68. --    awful.layout.suit.spiral, -- 8
  69. --    awful.layout.suit.spiral.dwindle, -- 9
  70.     awful.layout.suit.max, -- 10
  71. --    awful.layout.suit.max.fullscreen, -- 11
  72. --    awful.layout.suit.magnifier -- 12
  73. }
  74. -- }}}
  75.  
  76.  -- {{{ Tags
  77.  -- Define a tag table which will hold all screen tags.
  78.  tags = {
  79.    names  = { "[1]desktop", "[2]terms", "[3]www", "[4]media", "[5]dev", "[6]gimp", "[7]etc"},
  80.    layout = { layouts[1], layouts[2], layouts[2], layouts[4], layouts[2],
  81.               layouts[1], layouts[1],
  82.  }}
  83.  for s = 1, screen.count() do
  84.      -- Each screen has its own tag table.
  85.      tags[s] = awful.tag(tags.names, s, tags.layout)
  86.  end
  87.  -- }}}
  88.  
  89. -- Generate your table at startup or restart
  90.  
  91. -- {{{ Menu
  92. -- Create a laucher widget and a main menu
  93. myawesomemenu = {
  94.    { "manual", terminal .. " -e man awesome" },
  95.    { "edit config", editor_cmd .. " " .. awesome.conffile },
  96.    { "restart", awesome.restart },
  97.    { "quit", awesome.quit }
  98. }
  99.  
  100. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
  101.                                     { "urxvt", terminal },
  102.                                     { "Chromium", chromium}
  103.                                   }
  104.                         })
  105.  
  106. mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
  107.                                      menu = mymainmenu })
  108.  
  109. -- Menubar configuration
  110. menubar.utils.terminal = terminal -- Set the terminal for applications that require it
  111. -- }}}
  112.  
  113. -- {{{ Wibox
  114.  
  115. -- Create a textclock widget
  116. mytextclock = awful.widget.textclock()
  117.  
  118.  
  119. -- Create a wibox for each screen and add it
  120. mywibox = {}
  121. mypromptbox = {}
  122. mylayoutbox = {}
  123. mytaglist = {}
  124. mytaglist.buttons = awful.util.table.join(
  125.                     awful.button({ }, 1, awful.tag.viewonly),
  126.                     awful.button({ modkey }, 1, awful.client.movetotag),
  127.                     awful.button({ }, 3, awful.tag.viewtoggle),
  128.                     awful.button({ modkey }, 3, awful.client.toggletag),
  129.                     awful.button({ }, 4, awful.tag.viewnext),
  130.                     awful.button({ }, 5, awful.tag.viewprev)
  131.                     )
  132. mytasklist = {}
  133. mytasklist.buttons = awful.util.table.join(
  134.                      awful.button({ }, 1, function (c)
  135.                                               if c == client.focus then
  136.                                                   c.minimized = true
  137.                                               else
  138.                                                   if not c:isvisible() then
  139.                                                       awful.tag.viewonly(c:tags()[1])
  140.                                                   end
  141.                                                   -- This will also un-minimize
  142.                                                   -- the client, if needed
  143.                                                   client.focus = c
  144.                                                   c:raise()
  145.                                               end
  146.                                           end),
  147.                      awful.button({ }, 3, function ()
  148.                                               if instance then
  149.                                                   instance:hide()
  150.                                                   instance = nil
  151.                                               else
  152.                                                   instance = awful.menu.clients({ width=250 })
  153.                                               end
  154.                                           end),
  155.                      awful.button({ }, 4, function ()
  156.                                               awful.client.focus.byidx(1)
  157.                                               if client.focus then client.focus:raise() end
  158.                                           end),
  159.                      awful.button({ }, 5, function ()
  160.                                               awful.client.focus.byidx(-1)
  161.                                               if client.focus then client.focus:raise() end
  162.                                           end))
  163.  
  164. for s = 1, screen.count() do
  165.     -- Create a promptbox for each screen
  166.     mypromptbox[s] = awful.widget.prompt()
  167.     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  168.     -- We need one layoutbox per screen.
  169.     mylayoutbox[s] = awful.widget.layoutbox(s)
  170.     mylayoutbox[s]:buttons(awful.util.table.join(
  171.                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  172.                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  173.                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  174.                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  175.     -- Create a taglist widget
  176.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
  177.  
  178.     -- Create a tasklist widget
  179.     mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
  180.  
  181.     -- Create the wibox --zzz "top"
  182.     mywibox[s] = awful.wibox({ position = "top", screen = s })
  183.     --mywibox[s] = awful.wibox({ position = "bottom", screen = s })
  184.     -- Widgets that are aligned to the left
  185.     local left_layout = wibox.layout.fixed.horizontal()
  186.     left_layout:add(mylauncher)
  187.     left_layout:add(mytaglist[s])
  188.     left_layout:add(mypromptbox[s])
  189.  
  190.     -- Widgets that are aligned to the right
  191.     local right_layout = wibox.layout.fixed.horizontal()
  192.     if s == 1 then right_layout:add(wibox.widget.systray()) end
  193.     right_layout:add(mytextclock)
  194.     right_layout:add(mylayoutbox[s])
  195.  
  196.     -- Now bring it all together (with the tasklist in the middle)
  197.     local layout = wibox.layout.align.horizontal()
  198.     layout:set_left(left_layout)
  199.     layout:set_middle(mytasklist[s])
  200.     layout:set_right(right_layout)
  201.  
  202.     mywibox[s]:set_widget(layout)
  203. end
  204. -- }}}
  205.  
  206.  
  207.  
  208. -- {{{ Mouse bindings
  209. root.buttons(awful.util.table.join(
  210.     awful.button({ }, 3, function () mymainmenu:toggle() end),
  211.     awful.button({ }, 4, awful.tag.viewnext),
  212.     awful.button({ }, 5, awful.tag.viewprev)
  213. ))
  214. -- }}}
  215.  
  216. -- {{{ Key bindings
  217. globalkeys = awful.util.table.join(
  218.     awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
  219.     awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
  220.     awful.key({ modkey,           }, "Escape", awful.tag.history.restore),
  221.  
  222.     awful.key({ modkey,           }, "j",
  223.         function ()
  224.             awful.client.focus.byidx( 1)
  225.             if client.focus then client.focus:raise() end
  226.         end),
  227.     awful.key({ modkey,           }, "k",
  228.         function ()
  229.             awful.client.focus.byidx(-1)
  230.             if client.focus then client.focus:raise() end
  231.         end),
  232.     awful.key({ modkey,           }, "w", function () mymainmenu:show() end),
  233.  
  234.     -- Layout manipulation
  235.     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
  236.     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
  237.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  238.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  239.     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
  240.     awful.key({ modkey,           }, "Tab",
  241.         function ()
  242.             awful.client.focus.history.previous()
  243.             if client.focus then
  244.                 client.focus:raise()
  245.             end
  246.         end),
  247.  
  248.     -- Standard program
  249.     awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
  250.     awful.key({ modkey, "Control" }, "r", awesome.restart),
  251.     awful.key({ modkey, "Shift"   }, "q", awesome.quit),
  252.  
  253.     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
  254.     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
  255.     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
  256.     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
  257.     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
  258.     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
  259.     awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
  260.     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
  261.  
  262.     awful.key({ modkey, "Control" }, "n", awful.client.restore),
  263.  
  264.     -- Prompt
  265.     awful.key({ modkey },            "r",     function () mypromptbox[mouse.screen]:run() end),
  266.  
  267.     awful.key({ modkey }, "x",
  268.               function ()
  269.                   awful.prompt.run({ prompt = "Run Lua code: " },
  270.                   mypromptbox[mouse.screen].widget,
  271.                   awful.util.eval, nil,
  272.                   awful.util.getdir("cache") .. "/history_eval")
  273.               end),
  274.     -- Menubar
  275.     awful.key({ modkey }, "p", function() menubar.show() end)
  276. )
  277.  
  278. clientkeys = awful.util.table.join(
  279.     awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
  280.     awful.key({ modkey, "Shift"   }, "c",      function (c) c:kill()                         end),
  281.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
  282.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  283.     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
  284.     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
  285.     awful.key({ modkey,           }, "n",
  286.         function (c)
  287.             -- The client currently has the input focus, so it cannot be
  288.             -- minimized, since minimized clients can't have the focus.
  289.             c.minimized = true
  290.         end),
  291.     awful.key({ modkey,           }, "m",
  292.         function (c)
  293.             c.maximized_horizontal = not c.maximized_horizontal
  294.             c.maximized_vertical   = not c.maximized_vertical
  295.         end)
  296. )
  297.  
  298. -- Compute the maximum number of digit we need, limited to 9
  299. keynumber = 0
  300. for s = 1, screen.count() do
  301.    keynumber = math.min(9, math.max(#tags[s], keynumber));
  302. end
  303.  
  304. -- Bind all key numbers to tags.
  305. -- Be careful: we use keycodes to make it works on any keyboard layout.
  306. -- This should map on the top row of your keyboard, usually 1 to 9.
  307. for i = 1, keynumber do
  308.     globalkeys = awful.util.table.join(globalkeys,
  309.         awful.key({ modkey }, "#" .. i + 9,
  310.                   function ()
  311.                         local screen = mouse.screen
  312.                         if tags[screen][i] then
  313.                             awful.tag.viewonly(tags[screen][i])
  314.                         end
  315.                   end),
  316.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  317.                   function ()
  318.                       local screen = mouse.screen
  319.                       if tags[screen][i] then
  320.                           awful.tag.viewtoggle(tags[screen][i])
  321.                       end
  322.                   end),
  323.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  324.                   function ()
  325.                       if client.focus and tags[client.focus.screen][i] then
  326.                           awful.client.movetotag(tags[client.focus.screen][i])
  327.                       end
  328.                   end),
  329.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  330.                   function ()
  331.                       if client.focus and tags[client.focus.screen][i] then
  332.                           awful.client.toggletag(tags[client.focus.screen][i])
  333.                       end
  334.                   end))
  335. end
  336.  
  337. clientbuttons = awful.util.table.join(
  338.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  339.     awful.button({ modkey }, 1, awful.mouse.client.move),
  340.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  341.  
  342. -- Set keys
  343. root.keys(globalkeys)
  344. -- }}}
  345.  
  346. -- {{{ Rules
  347. awful.rules.rules = {
  348.     -- All clients will match this rule.
  349.     { rule = { },
  350.       properties = { border_width = beautiful.border_width,
  351.                      border_color = beautiful.border_normal,
  352.                      focus = true,
  353.                      keys = clientkeys,
  354.                      buttons = clientbuttons } },
  355.     { rule = { class = "MPlayer" },
  356.       properties = { floating = true } },
  357.     { rule = { class = "pinentry" },
  358.       properties = { floating = true } },
  359.     { rule = { class = "gimp" },
  360.       properties = { floating = true } },
  361.     { rule = { class = "URxvt" },
  362.       properties = { opacity = 0.65 } },
  363. --    { rule = { class = "Banshee" },
  364. --      properties = { tag = tags[media][1] } }
  365.     -- Set Firefox to always map on tags number 2 of screen 1.
  366.     -- { rule = { class = "Firefox" },
  367.     --   properties = { tag = tags[1][2] } },
  368. }
  369. -- }}}
  370.  
  371. -- {{{ Signals
  372. -- Signal function to execute when a new client appears.
  373. client.connect_signal("manage", function (c, startup)
  374.     -- Enable sloppy focus
  375.     c:connect_signal("mouse::enter", function(c)
  376.         if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  377.             and awful.client.focus.filter(c) then
  378.             client.focus = c
  379.         end
  380.     end)
  381.  
  382.     if not startup then
  383.         -- Set the windows at the slave,
  384.         -- i.e. put it at the end of others instead of setting it master.
  385.         -- awful.client.setslave(c)
  386.  
  387.         -- Put windows in a smart way, only if they does not set an initial position.
  388.         if not c.size_hints.user_position and not c.size_hints.program_position then
  389.             awful.placement.no_overlap(c)
  390.             awful.placement.no_offscreen(c)
  391.         end
  392.     end
  393. end)
  394.  
  395. client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  396. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  397. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment