Advertisement
Guest User

hurleyef

a guest
Oct 2nd, 2010
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 16.89 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. function run_once(prg)
  11.     if not prg then
  12.         do return nil end
  13.     end
  14.     awful.util.spawn_with_shell("pgrep -u $USER -x " .. prg .. " || (" .. prg .. ")")
  15. end
  16. -- AUTORUN APPS!
  17. run_once("xcompmgr -c -f -D 5")
  18. --run_once("xscreensaver -nosplash")
  19. --run_once("gnome-power-manager")
  20. run_once("nm-applet --disable")
  21. run_once("pyvolwheel")
  22. run_once("mpd")
  23. run_once("mpc volume 38")
  24.  
  25. -- Autorun programs
  26. autorun = true
  27. autorunApps =
  28. {
  29.      "xscreensaver -nosplash"
  30. --   "xcompmgr",
  31. --   "gnome-screensaver",
  32. --   "gnome-power-manager",
  33. --   "nm-applet --disable",
  34. --   "pyvolwheel",
  35. }
  36. if autorun then
  37.    for app = 1, #autorunApps do
  38.        awful.util.spawn(autorunApps[app])
  39.    end
  40. end
  41.  
  42. -- {{{ Variable definitions
  43. -- Themes define colours, icons, and wallpapers
  44. beautiful.init("/home/ted/.config/awesome/theme.lua")
  45.  
  46. -- This is used later as the default terminal and editor to run.
  47. -- terminal = "xterm"
  48. terminal = "urxvt"
  49. filebrowser = "pcmanfm"
  50. editor = os.getenv("EDITOR") or "gedit"
  51. -- editor_cmd = terminal .. " -e " .. editor
  52. editor_cmd = editor
  53.  
  54. -- Default modkey.
  55. -- Usually, Mod4 is the key with a logo between Control and Alt.
  56. -- If you do not like this or do not have such a key,
  57. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  58. -- However, you can use another modifier like Mod1, but it may interact with others.
  59. modkey = "Mod4"
  60.  
  61. -- Table of layouts to cover with awful.layout.inc, order matters.
  62. layouts =
  63. {
  64.     awful.layout.suit.floating,
  65.     awful.layout.suit.tile,
  66.     -- awful.layout.suit.tile.left,
  67.     awful.layout.suit.tile.bottom,
  68.     -- awful.layout.suit.tile.top,
  69.     awful.layout.suit.fair,
  70.     awful.layout.suit.fair.horizontal,
  71.     -- awful.layout.suit.spiral,
  72.     -- awful.layout.suit.spiral.dwindle,
  73.     -- awful.layout.suit.max,
  74.     -- awful.layout.suit.max.fullscreen,
  75.     awful.layout.suit.magnifier
  76. }
  77. -- }}}
  78.  
  79. -- {{{ Tags
  80.  -- Define a tag table which will hold all screen tags.
  81.  tags = {
  82.    names  = { "one", "two", "three", "four", "five", "video", "audio", "www", },
  83.    layout = { layouts[2], layouts[2], layouts[2], layouts[2], layouts[2],
  84.               layouts[2], layouts[2], layouts[2], layouts[2]
  85.  }}
  86.  for s = 1, screen.count() do
  87.      -- Each screen has its own tag table.
  88.      tags[s] = awful.tag(tags.names, s, tags.layout)
  89.  end
  90.  -- }}}
  91.  
  92. -- {{{ Menu
  93. -- Create a laucher widget and a main menu
  94. myawesomemenu = {
  95.    { "manual", terminal .. " -e man awesome" },
  96.    { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
  97.    { "restart", awesome.restart },
  98.    { "quit", awesome.quit }
  99. }
  100. applicationsmenu = {
  101.    { "rhythmbox", 'rhythmbox' },
  102.    { "calculator", 'gcalctool' },
  103.    { "chromium", 'chromium' },
  104.    { "pidgin", 'pidgin' },
  105.    { "transmission", 'transmission' },
  106.    { "openoffic.org", 'soffice' },
  107.    { "brasero", 'brasero' }
  108. }
  109. programmingmenu = {
  110.    { "geany", 'geany' },
  111.    { "eclipse", 'eclipse' },
  112.    { "glade", 'glade-3' }
  113.  
  114. }
  115.  
  116. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
  117.                                     { "applications", applicationsmenu },
  118.                                     { "coding", programmingmenu },
  119.                                     { "open terminal", terminal },
  120.                                     { "file browser", filebrowser }
  121.                                   }
  122.                         })
  123.  
  124. mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
  125.                                      menu = mymainmenu })
  126. -- }}}
  127.  
  128. -- {{{ Wibox
  129. -- Create a textclock widget
  130. mytextclock = awful.widget.textclock({ align = "right" })
  131.  
  132. -- Create a systray
  133. mysystray = widget({ type = "systray" })
  134.  
  135. -- Create a wibox for each screen and add it
  136. mywibox = {}
  137. mypromptbox = {}
  138. mylayoutbox = {}
  139. mytaglist = {}
  140. mytaglist.buttons = awful.util.table.join(
  141.                     awful.button({ }, 1, awful.tag.viewonly),
  142.                     awful.button({ modkey }, 1, awful.client.movetotag),
  143.                     awful.button({ }, 3, awful.tag.viewtoggle),
  144.                     awful.button({ modkey }, 3, awful.client.toggletag),
  145.                     awful.button({ }, 4, awful.tag.viewnext),
  146.                     awful.button({ }, 5, awful.tag.viewprev)
  147.                     )
  148. mytasklist = {}
  149. mytasklist.buttons = awful.util.table.join(
  150.                      awful.button({ }, 1, function (c)
  151.                                               if not c:isvisible() then
  152.                                                   awful.tag.viewonly(c:tags()[1])
  153.                                               end
  154.                                               client.focus = c
  155.                                               c:raise()
  156.                                           end),
  157.                      awful.button({ }, 3, function ()
  158.                                               if instance then
  159.                                                   instance:hide()
  160.                                                   instance = nil
  161.                                               else
  162.                                                   instance = awful.menu.clients({ width=250 })
  163.                                               end
  164.                                           end),
  165.                      awful.button({ }, 4, function ()
  166.                                               awful.client.focus.byidx(1)
  167.                                               if client.focus then client.focus:raise() end
  168.                                           end),
  169.                      awful.button({ }, 5, function ()
  170.                                               awful.client.focus.byidx(-1)
  171.                                               if client.focus then client.focus:raise() end
  172.                                           end))
  173.  
  174. for s = 1, screen.count() do
  175.     -- Create a promptbox for each screen
  176.     mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
  177.     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  178.     -- We need one layoutbox per screen.
  179.     mylayoutbox[s] = awful.widget.layoutbox(s)
  180.     mylayoutbox[s]:buttons(awful.util.table.join(
  181.                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  182.                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  183.                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  184.                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  185.     -- Create a taglist widget
  186.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
  187.  
  188.     -- Create a tasklist widget
  189.     mytasklist[s] = awful.widget.tasklist(function(c)
  190.                                               return awful.widget.tasklist.label.currenttags(c, s)
  191.                                           end, mytasklist.buttons)
  192.  
  193.     -- Create the wibox
  194.     mywibox[s] = awful.wibox({ position = "top", screen = s })
  195.     -- Add widgets to the wibox - order matters
  196.     mywibox[s].widgets = {
  197.         {
  198.             mylauncher,
  199.             mytaglist[s],
  200.             mypromptbox[s],
  201.             layout = awful.widget.layout.horizontal.leftright
  202.         },
  203.         mylayoutbox[s],
  204.         mytextclock,
  205.         s == 1 and mysystray or nil,
  206.         mytasklist[s],
  207.         layout = awful.widget.layout.horizontal.rightleft
  208.     }
  209. end
  210. -- }}}
  211.  
  212. -- {{{ Mouse bindings
  213. root.buttons(awful.util.table.join(
  214.     awful.button({ }, 3, function () mymainmenu:toggle() end),
  215.     awful.button({ }, 4, awful.tag.viewnext),
  216.     awful.button({ }, 5, awful.tag.viewprev)
  217. ))
  218. -- }}}
  219.  
  220. -- {{{ Key bindings
  221. globalkeys = awful.util.table.join(
  222.  
  223.     -- lock screen
  224.     awful.key({ "Mod1", "Control"          }, "l", function () awful.util.spawn_with_shell("xscreensaver-command --lock") end),
  225.     -- window switcher
  226.     awful.key({ "Mod1" }, "Escape", function ()
  227.      -- If you want to always position the menu on the same place set coordinates
  228.      awful.menu.menu_keys.down = { "Down", "Alt_L" }
  229.      local cmenu = awful.menu.clients({width=245}, { keygrabber=true, coords={x=0, y=20} })
  230.  
  231.  end),
  232.    
  233.     awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
  234.     awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
  235.     awful.key({ modkey,           }, "Escape", awful.tag.history.restore),
  236.  
  237.     awful.key({ modkey,           }, "j",
  238.         function ()
  239.             awful.client.focus.byidx( 1)
  240.             if client.focus then client.focus:raise() end
  241.         end),
  242.     awful.key({ modkey,           }, "k",
  243.         function ()
  244.             awful.client.focus.byidx(-1)
  245.             if client.focus then client.focus:raise() end
  246.         end),
  247.     awful.key({ modkey,           }, "w", function () mymainmenu:show({keygrabber=true}) end),
  248.  
  249.     -- Layout manipulation
  250.     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
  251.     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
  252.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  253.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  254.     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
  255.     awful.key({ modkey,           }, "Tab",
  256.         function ()
  257.             awful.client.focus.history.previous()
  258.             if client.focus then
  259.                 client.focus:raise()
  260.             end
  261.         end),
  262.  
  263.     -- Standard program
  264.     awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
  265.     awful.key({ modkey, "Control" }, "r", awesome.restart),
  266.     awful.key({ modkey, "Shift"   }, "q", awesome.quit),
  267.  
  268.     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
  269.     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
  270.     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
  271.     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
  272.     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
  273.     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
  274.     awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
  275.     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
  276.  
  277.     -- Prompt
  278.    
  279.    
  280.     --dmenu
  281.     awful.key({ modkey, },            "r",     function ()
  282.     awful.util.spawn("dmenu_run -i -b -p 'Run command:' -nb '" ..
  283.         beautiful.bg_normal .. "' -nf '" .. beautiful.fg_normal ..
  284.         "' -sb '" .. beautiful.bg_focus ..
  285.         "' -sf '" .. beautiful.fg_focus .. "'")
  286.     end),
  287.    
  288.    
  289.     -- awful.key({ modkey },            "r",     function () mypromptbox[mouse.screen]:run() end),
  290.  
  291.     awful.key({ modkey }, "x",
  292.               function ()
  293.                   awful.prompt.run({ prompt = "Run Lua code: " },
  294.                   mypromptbox[mouse.screen].widget,
  295.                   awful.util.eval, nil,
  296.                   awful.util.getdir("cache") .. "/history_eval")
  297.               end)
  298. )
  299.  
  300. clientkeys = awful.util.table.join(
  301.     awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
  302.     awful.key({ modkey, "Shift"   }, "c",      function (c) c:kill()                         end),
  303.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
  304.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  305.     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
  306.     awful.key({ modkey, "Shift"   }, "r",      function (c) c:redraw()                       end),
  307.     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
  308.     awful.key({ modkey,           }, "n",      function (c) c.minimized = not c.minimized    end),
  309.     awful.key({ modkey,           }, "m",
  310.         function (c)
  311.             c.maximized_horizontal = not c.maximized_horizontal
  312.             c.maximized_vertical   = not c.maximized_vertical
  313.         end)
  314. )
  315.  
  316. -- Compute the maximum number of digit we need, limited to 9
  317. keynumber = 0
  318. for s = 1, screen.count() do
  319.    keynumber = math.min(9, math.max(#tags[s], keynumber));
  320. end
  321.  
  322. -- Bind all key numbers to tags.
  323. -- Be careful: we use keycodes to make it works on any keyboard layout.
  324. -- This should map on the top row of your keyboard, usually 1 to 9.
  325. for i = 1, keynumber do
  326.     globalkeys = awful.util.table.join(globalkeys,
  327.         awful.key({ modkey }, "#" .. i + 9,
  328.                   function ()
  329.                         local screen = mouse.screen
  330.                         if tags[screen][i] then
  331.                             awful.tag.viewonly(tags[screen][i])
  332.                         end
  333.                   end),
  334.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  335.                   function ()
  336.                       local screen = mouse.screen
  337.                       if tags[screen][i] then
  338.                           awful.tag.viewtoggle(tags[screen][i])
  339.                       end
  340.                   end),
  341.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  342.                   function ()
  343.                       if client.focus and tags[client.focus.screen][i] then
  344.                           awful.client.movetotag(tags[client.focus.screen][i])
  345.                       end
  346.                   end),
  347.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  348.                   function ()
  349.                       if client.focus and tags[client.focus.screen][i] then
  350.                           awful.client.toggletag(tags[client.focus.screen][i])
  351.                       end
  352.                   end))
  353. end
  354.  
  355. clientbuttons = awful.util.table.join(
  356.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  357.     awful.button({ modkey }, 1, awful.mouse.client.move),
  358.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  359.  
  360. -- Set keys
  361. root.keys(globalkeys)
  362. -- }}}
  363.  
  364. -- {{{ Rules
  365. awful.rules.rules = {
  366.     -- All clients will match this rule.
  367.     { rule = { },
  368.       properties = { border_width = beautiful.border_width,
  369.                      border_color = beautiful.border_normal,
  370.                      focus = true,
  371.                      keys = clientkeys,
  372.                      buttons = clientbuttons,
  373.                      size_hints_honor = false } },
  374.     { rule = { class = "MPlayer" },
  375.       properties = { floating = true } },
  376.     { rule = { class = "pinentry" },
  377.       properties = { floating = true } },
  378.     { rule = { class = "gimp" },
  379.       properties = { floating = true } },
  380.     { rule = { class = "Pyvolwheel" },
  381.       properties = { floating = true } },
  382.     { rule = { class = "Volumeicon" },
  383.       properties = { floating = true } },
  384.     { rule = { class = "Gnome-volume-control" },
  385.       properties = { floating = true } },
  386.     { rule = { class = "Transmission" },
  387.       properties = { floating = true } },
  388.     { rule = { class = "Pidgin" },
  389.       properties = { floating = true } },
  390.     { rule = { class = "Rhythmbox" },
  391.       properties = { tag = tags[1][7] } },
  392.     { rule = { class = "Chromium" },
  393.       properties = { tag = tags[1][8] } },
  394.     { rule = { class = "Vlc" },
  395.       properties = { tag = tags[1][6] } },
  396.     -- Set Firefox to always map on tags number 2 of screen 1.
  397.     -- { rule = { class = "Firefox" },
  398.     --   properties = { tag = tags[1][2] } },
  399. }
  400. -- }}}
  401.  
  402. -- {{{ Signals
  403. -- Signal function to execute when a new client appears.
  404. client.add_signal("manage", function (c, startup)
  405.     -- Add a titlebar
  406.     -- awful.titlebar.add(c, { modkey = modkey })
  407.  
  408.     -- Enable sloppy focus
  409.     c:add_signal("mouse::enter", function(c)
  410.         if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  411.             and awful.client.focus.filter(c) then
  412.             client.focus = c
  413.         end
  414.     end)
  415.  
  416.     if not startup then
  417.         -- Set the windows at the slave,
  418.         -- i.e. put it at the end of others instead of setting it master.
  419.         -- awful.client.setslave(c)
  420.  
  421.         -- Put windows in a smart way, only if they does not set an initial position.
  422.         if not c.size_hints.user_position and not c.size_hints.program_position then
  423.             awful.placement.no_overlap(c)
  424.             awful.placement.no_offscreen(c)
  425.         end
  426.     end
  427. end)
  428.  
  429. mymainmenu:add_signal("mouse::leave", function (c) c:hide() end)
  430.  
  431.  
  432. client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  433. client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  434. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement