Advertisement
Guest User

Untitled

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