Advertisement
Guest User

Divius

a guest
Oct 26th, 2010
681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.33 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. -- {{{ Variable definitions
  14. -- Themes define colours, icons, and wallpapers
  15. beautiful.init("/home/divius/.config/awesome/theme.lua")
  16.  
  17. -- This is used later as the default terminal and editor to run.
  18. terminal = "x-terminal-emulator"
  19. --editor = os.getenv("EDITOR") or "editor"
  20. editor_cmd = "/usr/bin/geany"
  21.  
  22. -- Default modkey.
  23. -- Usually, Mod4 is the key with a logo between Control and Alt.
  24. -- If you do not like this or do not have such a key,
  25. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  26. -- However, you can use another modifier like Mod1, but it may interact with others.
  27. modkey = "Mod4"
  28.  
  29. -- Table of layouts to cover with awful.layout.inc, order matters.
  30. layouts =
  31. {
  32.     awful.layout.suit.floating,
  33.     awful.layout.suit.tile,
  34.     awful.layout.suit.tile.left,
  35.     awful.layout.suit.tile.bottom,
  36.     awful.layout.suit.tile.top,
  37.     awful.layout.suit.fair,
  38.     awful.layout.suit.fair.horizontal,
  39.     awful.layout.suit.spiral,
  40.     awful.layout.suit.spiral.dwindle,
  41.     awful.layout.suit.max,
  42.     awful.layout.suit.max.fullscreen,
  43.     awful.layout.suit.magnifier
  44. }
  45. -- }}}
  46.  
  47. -- {{{ Tags
  48. -- Define a tag table which hold all screen tags.
  49. --tags = {}
  50. --for s = 1, screen.count() do
  51. --    -- Each screen has its own tag table.
  52. --    tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])
  53. --end
  54. tags = {
  55.    names  = { "main", "www", "work", "vbox", "gajim", "office" },
  56.    layout = {   awful.layout.suit.floating,
  57.                 awful.layout.suit.max,
  58.                 awful.layout.suit.tile.right,
  59.                 awful.layout.suit.magnifier,
  60.                 awful.layout.suit.tile.left,
  61.                 awful.layout.suit.max
  62. }}
  63. for s = 1, screen.count() do
  64.     tags[s] = awful.tag(tags.names, s, tags.layout)
  65. end
  66. -- }}}
  67.  
  68. -- {{{ Menu
  69. -- Create a laucher widget and a main menu
  70. myawesomemenu = {
  71.    { "manual", terminal .. " -e man awesome" },
  72.    { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
  73.    { "suspend", "gksudo pm-suspend" },
  74.    { "reboot", "gksudo reboot" },
  75.    { "restart", awesome.restart },
  76.    { "quit", awesome.quit }
  77. }
  78.  
  79. mymainmenu = awful.menu({ items = { { "Awesome", myawesomemenu, beautiful.awesome_icon },
  80.                                     { "Debian", debian.menu.Debian_menu.Debian },
  81.                                     { "Terminal", terminal },
  82.                                     { "Chromium", "chromium-browser" },
  83.                                     { "Geany", "geany" },
  84.                                     { "Audacious", "audacious" },
  85.                                     { "Gajim", "gajim" },
  86.                                     { "Transmission", "transmission"},
  87.                                     { "VirtualBox", "VirtualBox" }
  88.                                   }
  89.                         })
  90.  
  91. mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
  92.                                      menu = mymainmenu })
  93. -- }}}
  94.  
  95. -- {{{ Wibox
  96. -- Create a textclock widget
  97. require("obvious.volume_alsa") -- Load the module
  98. --mytextclock = awful.widget.textclock({ align = "right" })
  99.  
  100. -- Create a systray
  101. mysystray = widget({ type = "systray" })
  102.  
  103. -- Create a wibox for each screen and add it
  104. mywibox = {}
  105. mypromptbox = {}
  106. mylayoutbox = {}
  107. mytaglist = {}
  108. mytaglist.buttons = awful.util.table.join(
  109.                     awful.button({ }, 1, awful.tag.viewonly),
  110.                     awful.button({ modkey }, 1, awful.client.movetotag),
  111.                     awful.button({ }, 3, awful.tag.viewtoggle),
  112.                     awful.button({ modkey }, 3, awful.client.toggletag),
  113.                     awful.button({ }, 4, awful.tag.viewnext),
  114.                     awful.button({ }, 5, awful.tag.viewprev)
  115.                     )
  116. mytasklist = {}
  117. mytasklist.buttons = awful.util.table.join(
  118.                      awful.button({ }, 1, function (c)
  119.                                               if not c:isvisible() then
  120.                                                   awful.tag.viewonly(c:tags()[1])
  121.                                               end
  122.                                               client.focus = c
  123.                                               c:raise()
  124.                                           end),
  125.                      awful.button({ }, 3, function ()
  126.                                               if instance then
  127.                                                   instance:hide()
  128.                                                   instance = nil
  129.                                               else
  130.                                                   instance = awful.menu.clients({ width=250 })
  131.                                               end
  132.                                           end),
  133.                      awful.button({ }, 4, function ()
  134.                                               awful.client.focus.byidx(1)
  135.                                               if client.focus then client.focus:raise() end
  136.                                           end),
  137.                      awful.button({ }, 5, function ()
  138.                                               awful.client.focus.byidx(-1)
  139.                                               if client.focus then client.focus:raise() end
  140.                                           end))
  141.  
  142. for s = 1, screen.count() do
  143.     -- Create a promptbox for each screen
  144.     mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
  145.     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  146.     -- We need one layoutbox per screen.
  147.     mylayoutbox[s] = awful.widget.layoutbox(s)
  148.     mylayoutbox[s]:buttons(awful.util.table.join(
  149.                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  150.                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  151.                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  152.                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  153.     -- Create a taglist widget
  154.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
  155.  
  156.     -- Create a tasklist widget
  157.     mytasklist[s] = awful.widget.tasklist(function(c)
  158.                                               return awful.widget.tasklist.label.currenttags(c, s)
  159.                                           end, mytasklist.buttons)
  160.  
  161.     -- Create the wibox
  162.     mywibox[s] = awful.wibox({ position = "bottom", screen = s, height="24" })
  163.     -- Add widgets to the wibox - order matters
  164.     mywibox[s].widgets = {
  165.         {
  166.             --mylauncher,
  167.  
  168.             mytaglist[s],
  169.             mypromptbox[s],
  170.             layout = awful.widget.layout.horizontal.leftright
  171.         },
  172.         mylayoutbox[s],
  173.         obvious.volume_alsa(),
  174.         s == 1 and mysystray or nil,
  175.         mytasklist[s],
  176.         layout = awful.widget.layout.horizontal.rightleft
  177.     }
  178. end
  179. -- }}}
  180.  
  181. -- {{{ Mouse bindings
  182. root.buttons(awful.util.table.join(
  183.     awful.button({ }, 3, function () mymainmenu:toggle() end),
  184.     awful.button({ }, 4, awful.tag.viewnext),
  185.     awful.button({ }, 5, awful.tag.viewprev)
  186. ))
  187. -- }}}
  188.  
  189. -- {{{ Key bindings
  190. globalkeys = awful.util.table.join(
  191.     awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
  192.     awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
  193.     awful.key({ modkey,           }, "Escape", awful.tag.history.restore),
  194.  
  195.     awful.key({ modkey,           }, "j",
  196.         function ()
  197.             awful.client.focus.byidx( 1)
  198.             if client.focus then client.focus:raise() end
  199.         end),
  200.     awful.key({ modkey,           }, "k",
  201.         function ()
  202.             awful.client.focus.byidx(-1)
  203.             if client.focus then client.focus:raise() end
  204.         end),
  205.     awful.key({ modkey,           }, "w", function () mymainmenu:show(true)        end),
  206.  
  207.     -- Layout manipulation
  208.     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
  209.     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
  210.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  211.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  212.     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
  213.     awful.key({ modkey,           }, "Tab",
  214.         function ()
  215.             awful.client.focus.history.previous()
  216.             if client.focus then
  217.                 client.focus:raise()
  218.             end
  219.         end),
  220.  
  221.     -- Standard program
  222.     awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
  223.     awful.key({ modkey, "Control" }, "r", awesome.restart),
  224.     awful.key({ modkey, "Shift"   }, "q", awesome.quit),
  225.  
  226.     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
  227.     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
  228.     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
  229.     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
  230.     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
  231.     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
  232.     awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
  233.     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
  234.  
  235.     -- Prompt
  236.     awful.key({ modkey },            "r",     function () mypromptbox[mouse.screen]:run() end),
  237.  
  238.     awful.key({ modkey }, "x",
  239.               function ()
  240.                   awful.prompt.run({ prompt = "Run Lua code: " },
  241.                   mypromptbox[mouse.screen].widget,
  242.                   awful.util.eval, nil,
  243.                   awful.util.getdir("cache") .. "/history_eval")
  244.               end)
  245. )
  246.  
  247. clientkeys = awful.util.table.join(
  248.     awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
  249.     awful.key({ modkey, "Shift"   }, "c",      function (c) c:kill()                         end),
  250.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
  251.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  252.     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
  253.     awful.key({ modkey, "Shift"   }, "r",      function (c) c:redraw()                       end),
  254.     awful.key({ modkey,           }, "n",      function (c) c.minimized = not c.minimized    end),
  255.     awful.key({ modkey,           }, "m",
  256.         function (c)
  257.             c.maximized_horizontal = not c.maximized_horizontal
  258.             c.maximized_vertical   = not c.maximized_vertical
  259.         end)
  260. )
  261.  
  262. -- Compute the maximum number of digit we need, limited to 9
  263. keynumber = 0
  264. for s = 1, screen.count() do
  265.    keynumber = math.min(9, math.max(#tags[s], keynumber));
  266. end
  267.  
  268. -- Bind all key numbers to tags.
  269. -- Be careful: we use keycodes to make it works on any keyboard layout.
  270. -- This should map on the top row of your keyboard, usually 1 to 9.
  271. for i = 1, keynumber do
  272.     globalkeys = awful.util.table.join(globalkeys,
  273.         awful.key({ modkey }, "#" .. i + 9,
  274.                   function ()
  275.                         local screen = mouse.screen
  276.                         if tags[screen][i] then
  277.                             awful.tag.viewonly(tags[screen][i])
  278.                         end
  279.                   end),
  280.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  281.                   function ()
  282.                       local screen = mouse.screen
  283.                       if tags[screen][i] then
  284.                           awful.tag.viewtoggle(tags[screen][i])
  285.                       end
  286.                   end),
  287.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  288.                   function ()
  289.                       if client.focus and tags[client.focus.screen][i] then
  290.                           awful.client.movetotag(tags[client.focus.screen][i])
  291.                       end
  292.                   end),
  293.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  294.                   function ()
  295.                       if client.focus and tags[client.focus.screen][i] then
  296.                           awful.client.toggletag(tags[client.focus.screen][i])
  297.                       end
  298.                   end))
  299. end
  300.  
  301. clientbuttons = awful.util.table.join(
  302.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  303.     awful.button({ modkey }, 1, awful.mouse.client.move),
  304.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  305.  
  306. -- Set keys
  307. root.keys(globalkeys)
  308. -- }}}
  309.  
  310. -- {{{ Rules
  311. awful.rules.rules = {
  312.     -- All clients will match this rule.
  313.     { rule = { },
  314.       properties = { border_width = beautiful.border_width,
  315.                      border_color = beautiful.border_normal,
  316.                      focus = true,
  317.                      keys = clientkeys,
  318.                      buttons = clientbuttons,
  319.                      --tag = tags[1][1]
  320.                      } },
  321.     { rule = { class = "MPlayer" },
  322.       properties = { floating = true } },
  323.     { rule = { class = "pinentry" },
  324.       properties = { floating = true } },
  325.     { rule = { class = "gimp" },
  326.       properties = { floating = true } },
  327.  
  328.     { rule = { instance = "geany" },
  329.       properties = { tag = tags[1][3], floating = false, slave = false } },
  330.     { rule = { instance = "chromium-browser" },
  331.       properties = { tag = tags[1][2], floating = false } },
  332.     { rule = { instance = "gajim" },
  333.       properties = { tag = tags[1][5], floating = false } },
  334.     { rule = { instance = "VirtualBox" },
  335.       properties = { tag = tags[1][4], floating = false } },
  336.  
  337.     { rule = { modal = true} ,
  338.       properties = { floating = true },
  339.       callback = awful.placement.centered },
  340. }
  341. -- }}}
  342.  
  343. -- {{{ Signals
  344. -- Signal function to execute when a new client appears.
  345. client.add_signal("manage", function (c, startup)
  346.     -- Add a titlebar
  347.     awful.titlebar.add(c, { modkey = modkey })
  348.     --- Delete icon from titlebar
  349.     c.titlebar.widgets[3].appicon = {}
  350.  
  351.     -- Enable sloppy focus
  352.     c:add_signal("mouse::enter", function(c)
  353.         if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  354.             and awful.client.focus.filter(c) then
  355.             client.focus = c
  356.         end
  357.     end)
  358.  
  359.     if not startup then
  360.         -- Set the windows at the slave,
  361.         -- i.e. put it at the end of others instead of setting it master.
  362.         awful.client.setslave(c)
  363.  
  364.         -- Put windows in a smart way, only if they does not set an initial position.
  365.         if not c.size_hints.user_position and not c.size_hints.program_position then
  366.             awful.placement.no_overlap(c)
  367.             awful.placement.no_offscreen(c)
  368.         end
  369.     end
  370. end)
  371.  
  372. client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  373. client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  374. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement