Advertisement
Guest User

Untitled

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