Advertisement
Guest User

rc.lua

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