pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

pastebin - collaborative debugging tool View Help


Posted by Maki on Mon 20 Oct 22:06
report abuse | download | new post

  1. -- awesome 3 configuration file
  2.  
  3. -- Include awesome library, with lots of useful function!
  4. require("awful")
  5. require("tabulous")
  6. require("beautiful")
  7.  
  8. -- {{{ Variable definitions
  9. -- This is a file path to a theme file which will defines colors.
  10. theme_path = "/home/maki/.config/awesome/themes/default"
  11.  
  12. -- This is used later as the default terminal to run.
  13. terminal = "urxvt"
  14.  
  15. -- Default modkey.
  16. -- Usually, Mod4 is the key with a logo between Control and Alt.
  17. -- If you do not like this or do not have such a key,
  18. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  19. -- However, you can use another modifier like Mod1, but it may interact with others.
  20. modkey = "Mod4"
  21.  
  22. -- Table of layouts to cover with awful.layout.inc, order matters.
  23. layouts =
  24. {
  25.     "tile",
  26.     "tileleft",
  27.     "tilebottom",
  28.     "tiletop",
  29.     "fairh",
  30.     "fairv",
  31.     "magnifier",
  32.     "max",
  33.     "spiral",
  34.     "dwindle",
  35.     "floating"
  36. }
  37.  
  38. -- Table of clients that should be set floating. The index may be either
  39. -- the application class or instance. The instance is useful when running
  40. -- a console app in a terminal like (Music on Console)
  41. --    xterm -name mocp -e mocp
  42. floatapps =
  43. {
  44.     -- by class
  45.     ["MPlayer"] = true,
  46.     ["pinentry"] = true,
  47.     ["gimp"] = true,
  48.     -- by instance
  49.     ["mocp"] = true
  50. }
  51.  
  52. -- Applications to be moved to a pre-defined tag by class or instance.
  53. -- Use the screen and tags indices.
  54. apptags =
  55. {
  56.  ["Firefox"] = { screen = 1, tag = 2 },
  57.  
  58. }
  59.  
  60. -- Define if we want to use titlebar on all applications.
  61. use_titlebar = false
  62. -- }}}
  63.  
  64. -- {{{ Initialization
  65. -- Initialize theme (colors).
  66. beautiful.init(theme_path)
  67.  
  68. -- Register theme in awful.
  69. -- This allows to not pass plenty of arguments to each function
  70. -- to inform it about colors we want it to draw.
  71. awful.beautiful.register(beautiful)
  72.  
  73. -- Uncomment this to activate autotabbing
  74. -- tabulous.autotab_start()
  75. -- }}}
  76.  
  77. -- {{{ Tags
  78. -- Define tags table.
  79. tags = {9}
  80. for s = 1, screen.count() do
  81.     -- Each screen has its own tag table.
  82.     tags[s] = {9}
  83.     -- Create 9 tags per screen.
  84.     for tagnumber = 1, 9 do
  85.         tags[s][tagnumber] = tag({ name = tagnumber, layout = layouts[1] })
  86.         -- Add tags to screen one by one
  87.         tags[s][tagnumber].screen = s
  88.     end
  89.     -- I'm sure you want to see at least one tag.
  90.     tags[s][1].selected = true
  91. end
  92. -- }}}
  93.  
  94. -- {{{ Statusbar
  95. -- Create a taglist widget
  96. mytaglist = widget({ type = "taglist", name = "mytaglist" })
  97. mytaglist:mouse_add(mouse({}, 1, function (object, tag) awful.tag.viewonly(tag) end))
  98. mytaglist:mouse_add(mouse({ modkey }, 1, function (object, tag) awful.client.movetotag(tag) end))
  99. mytaglist:mouse_add(mouse({}, 3, function (object, tag) tag.selected = not tag.selected end))
  100. mytaglist:mouse_add(mouse({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end))
  101. mytaglist:mouse_add(mouse({ }, 4, awful.tag.viewnext))
  102. mytaglist:mouse_add(mouse({ }, 5, awful.tag.viewprev))
  103. mytaglist.label = awful.widget.taglist.label.all
  104.  
  105. -- Create a tasklist widget
  106. mytasklist = widget({ type = "tasklist", name = "mytasklist" })
  107. mytasklist:mouse_add(mouse({ }, 1, function (object, c) client.focus = c; c:raise() end))
  108. mytasklist:mouse_add(mouse({ }, 4, function () awful.client.focusbyidx(1) end))
  109. mytasklist:mouse_add(mouse({ }, 5, function () awful.client.focusbyidx(-1) end))
  110. mytasklist.label = awful.widget.tasklist.label.currenttags
  111.  
  112. -- Create a textbox widget
  113. mytextbox = widget({ type = "textbox", name = "mytextbox", align = "right" })
  114. -- Set the default text in textbox
  115. mytextbox.text = "<b><small> awesome " .. AWESOME_VERSION .. " </small></b>"
  116. mypromptbox = widget({ type = "textbox", name = "mypromptbox", align = "left" })
  117.  
  118. -- Create an iconbox widget
  119. myiconbox = widget({ type = "textbox", name = "myiconbox", align = "left" })
  120. myiconbox.text = "<bg image=\"/usr/share/awesome/icons/awesome16.png\" resize=\"true\"/>"
  121.  
  122. -- Create a systray
  123. mysystray = widget({ type = "systray", name = "mysystray", align = "right" })
  124.  
  125. -- Create an iconbox widget which will contains an icon indicating which layout we're using.
  126. -- We need one layoutbox per screen.
  127. mylayoutbox = {}
  128. for s = 1, screen.count() do
  129.    mylayoutbox[s] = widget({ type = "textbox", name = "mylayoutbox", align = "left" })
  130.     mylayoutbox[s]:mouse_add(mouse({ }, 1, function () awful.layout.inc(layouts, 1) end))
  131.     mylayoutbox[s]:mouse_add(mouse({ }, 3, function () awful.layout.inc(layouts, -1) end))
  132.     mylayoutbox[s]:mouse_add(mouse({ }, 4, function () awful.layout.inc(layouts, 1) end))
  133.     mylayoutbox[s]:mouse_add(mouse({ }, 5, function () awful.layout.inc(layouts, -1) end))
  134.     mylayoutbox[s].text = "<bg image=\"/usr/share/awesome/icons/layouts/tilew.png\" resize=\"true\"/>"
  135. end
  136.  
  137. -- Create a statusbar for each screen and add it
  138. mystatusbar = {}
  139. for s = 1, screen.count() do
  140.     mystatusbar[s] = statusbar({ position = "bottom", name = "mystatusbar" .. s,
  141.                                  fg = beautiful.fg_normal, bg = beautiful.bg_normal })
  142.     -- Add widgets to the statusbar - order matters
  143.     mystatusbar[s]:widgets({
  144.         myiconbox,
  145.         mytaglist,
  146.         mylayoutbox[s],
  147.         mytasklist,
  148.         mypromptbox,
  149.         mytextbox,
  150.         s == 1 and mysystray or nil
  151.     })
  152.     mystatusbar[s].screen = s
  153. end
  154. -- }}}
  155.  
  156. -- {{{ Mouse bindings
  157. awesome.mouse_add(mouse({ }, 3, function () awful.spawn(terminal) end))
  158. awesome.mouse_add(mouse({ }, 4, awful.tag.viewnext))
  159. awesome.mouse_add(mouse({ }, 5, awful.tag.viewprev))
  160. -- }}}
  161.  
  162. -- {{{ Key bindings
  163.  
  164. -- Bind keyboard digits
  165. -- Compute the maximum number of digit we need, limited to 9
  166. keynumber = 0
  167. for s = 1, screen.count() do
  168.    keynumber = math.min(9, math.max(#tags[s], keynumber));
  169. end
  170.  
  171. for i = 1, keynumber do
  172.     keybinding({ modkey }, i,
  173.                    function ()
  174.                        local screen = mouse.screen
  175.                        if tags[screen][i] then
  176.                            awful.tag.viewonly(tags[screen][i])
  177.                        end
  178.                    end):add()
  179.     keybinding({ modkey, "Control" }, i,
  180.                    function ()
  181.                        local screen = mouse.screen
  182.                        if tags[screen][i] then
  183.                            tags[screen][i].selected = not tags[screen][i].selected
  184.                        end
  185.                    end):add()
  186.     keybinding({ modkey, "Shift" }, i,
  187.                    function ()
  188.                        local sel = client.focus
  189.                        if sel then
  190.                            if tags[sel.screen][i] then
  191.                                awful.client.movetotag(tags[sel.screen][i])
  192.                            end
  193.                        end
  194.                    end):add()
  195.     keybinding({ modkey, "Control", "Shift" }, i,
  196.                    function ()
  197.                        local sel = client.focus
  198.                        if sel then
  199.                            if tags[sel.screen][i] then
  200.                                awful.client.toggletag(tags[sel.screen][i])
  201.                            end
  202.                        end
  203.                    end):add()
  204. end
  205.  
  206. keybinding({ modkey }, "Left", awful.tag.viewprev):add()
  207. keybinding({ modkey }, "Right", awful.tag.viewnext):add()
  208. keybinding({ modkey }, "Escape", awful.tag.history.restore):add()
  209.  
  210. -- Standard program
  211. keybinding({ modkey }, "Return", function () awful.spawn(terminal) end):add()
  212.  
  213. keybinding({ modkey, "Control" }, "r", awesome.restart):add()
  214. keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
  215.  
  216. -- Client manipulation
  217. keybinding({ modkey }, "m", awful.client.maximize):add()
  218. keybinding({ modkey,}, "F4" , function () client.focus:kill() end):add()
  219. keybinding({ modkey }, "j", function () awful.client.focusbyidx(1); client.focus:raise() end):add()
  220. keybinding({ modkey }, "k", function () awful.client.focusbyidx(-1);  client.focus:raise() end):add()
  221. keybinding({ modkey, "Shift" }, "j", function () awful.client.swap(1) end):add()
  222. keybinding({ modkey, "Shift" }, "k", function () awful.client.swap(-1) end):add()
  223. keybinding({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
  224. keybinding({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
  225. keybinding({ modkey, "Control" }, "space", awful.client.togglefloating):add()
  226. keybinding({ modkey, "Control" }, "Return", function () client.focus:swap(awful.client.master()) end):add()
  227. keybinding({ modkey }, "o", awful.client.movetoscreen):add()
  228. keybinding({ modkey }, "Tab", awful.client.focus.history.previous):add()
  229. keybinding({ modkey }, "u", awful.client.urgent.jumpto):add()
  230. keybinding({ modkey, "Shift" }, "r", function () client.focus:redraw() end):add()
  231.  
  232. -- Layout manipulation
  233. keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
  234. keybinding({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
  235. keybinding({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
  236. keybinding({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
  237. keybinding({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
  238. keybinding({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
  239. keybinding({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
  240. keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
  241.  
  242. -- Prompt
  243. keybinding({ modkey }, "F2", function ()
  244.                                  awful.prompt.run({ prompt = "Run: " }, mypromptbox, awful.spawn, awful.completion.bash,
  245. os.getenv("HOME") .. "/.cache/awesome/history") end):add()
  246. keybinding({ modkey }, "F3", function ()
  247.                                  awful.prompt.run({ prompt = "Run Lua code: " }, mypromptbox, awful.eval, awful.prompt.bash,
  248. os.getenv("HOME") .. "/.cache/awesome/history_eval") end):add()
  249. keybinding({ modkey, "Ctrl" }, "i", function ()
  250.                                         if mypromptbox.text then
  251.                                             mypromptbox.text = nil
  252.                                         else
  253.                                             mypromptbox.text = nil
  254.                                             if client.focus.class then
  255.                                                 mypromptbox.text = "Class: " .. client.focus.class .. " "
  256.                                             end
  257.                                             if client.focus.instance then
  258.                                                 mypromptbox.text = mypromptbox.text .. "Instance: ".. client.focus.instance .. " "
  259.                                             end
  260.                                             if client.focus.role then
  261.                                                 mypromptbox.text = mypromptbox.text .. "Role: ".. client.focus.role
  262.                                             end
  263.                                         end
  264.                                     end):add()
  265.  
  266. --- Tabulous, tab manipulation
  267. keybinding({ modkey, "Control" }, "y", function ()
  268.     local tabbedview = tabulous.tabindex_get()
  269.     local nextclient = awful.client.next(1)
  270.  
  271.     if not tabbedview then
  272.         tabbedview = tabulous.tabindex_get(nextclient)
  273.  
  274.         if not tabbedview then
  275.             tabbedview = tabulous.tab_create()
  276.             tabulous.tab(tabbedview, nextclient)
  277.         else
  278.             tabulous.tab(tabbedview, client.focus)
  279.         end
  280.     else
  281.         tabulous.tab(tabbedview, nextclient)
  282.     end
  283. end):add()
  284.  
  285. keybinding({ modkey, "Shift" }, "y", tabulous.untab):add()
  286.  
  287. keybinding({ modkey }, "y", function ()
  288.    local tabbedview = tabulous.tabindex_get()
  289.  
  290.    if tabbedview then
  291.        local n = tabulous.next(tabbedview)
  292.        tabulous.display(tabbedview, n)
  293.    end
  294. end):add()
  295.  
  296. -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
  297. keybinding({ modkey }, "t", awful.client.togglemarked):add()
  298. keybinding({ modkey, 'Shift' }, "t", function ()
  299.     local tabbedview = tabulous.tabindex_get()
  300.     local clients = awful.client.getmarked()
  301.  
  302.     if not tabbedview then
  303.         tabbedview = tabulous.tab_create(clients[1])
  304.         table.remove(clients, 1)
  305.     end
  306.  
  307.     for k,c in pairs(clients) do
  308.         tabulous.tab(tabbedview, c)
  309.     end
  310.  
  311. end):add()
  312.  
  313. for i = 1, keynumber do
  314.     keybinding({ modkey, "Shift" }, "F" .. i,
  315.                    function ()
  316.                        local screen = mouse.screen
  317.                        if tags[screen][i] then
  318.                            for k, c in pairs(awful.client.getmarked()) do
  319.                                awful.client.movetotag(tags[screen][i], c)
  320.                            end
  321.                        end
  322.                    end):add()
  323. end
  324. -- }}}
  325.  
  326. -- {{{ Hooks
  327. -- Hook function to execute when focusing a client.
  328. function hook_focus(c)
  329.     if not awful.client.ismarked(c) then
  330.         c.border_color = beautiful.border_focus
  331.     end
  332. end
  333.  
  334. -- Hook function to execute when unfocusing a client.
  335. function hook_unfocus(c)
  336.     if not awful.client.ismarked(c) then
  337.         c.border_color = beautiful.border_normal
  338.     end
  339. end
  340.  
  341. -- Hook function to execute when marking a client
  342. function hook_marked(c)
  343.     c.border_color = beautiful.border_marked
  344. end
  345.  
  346. -- Hook function to execute when unmarking a client
  347. function hook_unmarked(c)
  348.     c.border_color = beautiful.border_focus
  349. end
  350.  
  351. -- Hook function to execute when the mouse is over a client.
  352. function hook_mouseover(c)
  353.     -- Sloppy focus, but disabled for magnifier layout
  354.     if awful.layout.get(c.screen) ~= "magnifier" then
  355.         client.focus = c
  356.     end
  357. end
  358.  
  359. -- Hook function to execute when a new client appears.
  360. function hook_manage(c)
  361.     -- Set floating placement to be smart!
  362.     c.floating_placement = "smart"
  363.     if use_titlebar then
  364.         -- Add a titlebar
  365.         awful.titlebar.add(c, { modkey = modkey })
  366.     end
  367.     -- Add mouse bindings
  368.     c:mouse_add(mouse({ }, 1, function (c) client.focus = c; c:raise() end))
  369.     c:mouse_add(mouse({ modkey }, 1, function (c) c:mouse_move() end))
  370.     c:mouse_add(mouse({ modkey }, 3, function (c) c:mouse_resize() end))
  371.     -- New client may not receive focus
  372.     -- if they're not focusable, so set border anyway.
  373.     c.border_width = beautiful.border_width
  374.     c.border_color = beautiful.border_normal
  375.     client.focus = c
  376.  
  377.     -- Check if the application should be floating.
  378.     local cls = c.class
  379.     local inst = c.instance
  380.     if floatapps[cls] then
  381.         c.floating = floatapps[cls]
  382.     elseif floatapps[inst] then
  383.         c.floating = floatapps[inst]
  384.     end
  385.  
  386.     -- Check application->screen/tag mappings.
  387.     local target
  388.     if apptags[cls] then
  389.         target = apptags[cls]
  390.     elseif apptags[inst] then
  391.         target = apptags[inst]
  392.     end
  393.     if target then
  394.         c.screen = target.screen
  395.         awful.client.movetotag(tags[target.screen][target.tag], c)
  396.     end
  397.  
  398.     -- Set the windows at the slave,
  399.     -- i.e. put it at the end of others instead of setting it master.
  400.     -- awful.client.setslave(c)
  401.  
  402.     -- Honor size hints
  403.     c.honorsizehints = true
  404. end
  405.  
  406. -- Hook function to execute when arranging the screen
  407. -- (tag switch, new client, etc)
  408. function hook_arrange(screen)
  409.     local layout = awful.layout.get(screen)
  410.     if layout then
  411.         mylayoutbox[screen].text =
  412.             "<bg image=\"/usr/share/awesome/icons/layouts/" .. awful.layout.get(screen) .. "w.png\" resize=\"true\"/>"
  413.         else
  414.             mylayoutbox[screen].text = "No layout."
  415.     end
  416.  
  417.     -- If no window has focus, give focus to the latest in history
  418.     if not client.focus then
  419.         local c = awful.client.focus.history.get(screen, 0)
  420.         if c then client.focus = c end
  421.     end
  422.  
  423.     -- Uncomment if you want mouse warping
  424.     --[[
  425.     local sel = client.focus
  426.     if sel then
  427.         local c_c = sel:coords()
  428.         local m_c = mouse.coords()
  429.  
  430.         if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
  431.             m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
  432.             if table.maxn(m_c.buttons) == 0 then
  433.                 mouse.coords({ x = c_c.x + 5, y = c_c.y + 5})
  434.             end
  435.         end
  436.     end
  437.     ]]
  438. end
  439.  
  440. -- Hook called every second
  441. function hook_timer ()
  442.     -- For unix time_t lovers
  443.    -- mytextbox.text = " " .. os.time() .. " time_t "
  444.     -- Otherwise use:
  445.     mytextbox.text = " " .. os.date() .. " "
  446. end
  447.  
  448. -- Set up some hooks
  449. awful.hooks.focus.register(hook_focus)
  450. awful.hooks.unfocus.register(hook_unfocus)
  451. awful.hooks.marked.register(hook_marked)
  452. awful.hooks.unmarked.register(hook_unmarked)
  453. awful.hooks.manage.register(hook_manage)
  454. awful.hooks.mouseover.register(hook_mouseover)
  455. awful.hooks.arrange.register(hook_arrange)
  456. awful.hooks.timer.register(1, hook_timer)
  457. -- }}}-

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post