Guest User

Untitled

a guest
Nov 8th, 2011
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.58 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. require("vicious")
  10.  
  11. os.setlocale(os.getenv("LANG"))
  12.  
  13. -- {{{ Variable definitions
  14. -- Themes define colours, icons, and wallpapers
  15. --beautiful.init("/usr/share/awesome/themes/default/theme.lua")
  16. beautiful.init("/home/serega/.config/awesome/themes/lunar/theme.lua")
  17.  
  18. -- This is used later as the default terminal and editor to run.
  19. terminal = "xterm"
  20. editor = os.getenv("EDITOR") or "vim"
  21. editor_cmd = terminal .. " -e " .. editor
  22.  
  23. -- Default modkey.
  24. -- Usually, Mod4 is the key with a logo between Control and Alt.
  25. -- If you do not like this or do not have such a key,
  26. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  27. -- However, you can use another modifier like Mod1, but it may interact with others.
  28. modkey = "Mod4"
  29.  
  30. -- Table of layouts to cover with awful.layout.inc, order matters.
  31. layouts =
  32. {
  33.     awful.layout.suit.floating,
  34.     awful.layout.suit.tile,
  35.     awful.layout.suit.tile.left,
  36.     awful.layout.suit.tile.bottom,
  37.     awful.layout.suit.tile.top,
  38.     awful.layout.suit.fair,
  39.     awful.layout.suit.fair.horizontal,
  40.     awful.layout.suit.spiral,
  41.     awful.layout.suit.spiral.dwindle,
  42.     awful.layout.suit.max,
  43.     awful.layout.suit.max.fullscreen,
  44.     awful.layout.suit.magnifier
  45. }
  46. -- }}}
  47.  
  48. -- {{{ Tags
  49. -- Define a tag table which hold all screen tags.
  50. tags = {
  51.    names  = { "файлы", "терм", "веб", "док", "ауд", "6", "7", "8", "9" },
  52.    layout = { layouts[1], layouts[4], layouts[1], layouts[4], layouts[4],
  53.               layouts[1], layouts[1], layouts[1], layouts[1]
  54.  }}
  55. for s = 1, screen.count() do
  56.     -- Each screen has its own tag table.
  57.     tags[s] = awful.tag(tags.names, s, tags.layout)
  58. end
  59. -- }}}
  60.  
  61. -- {{{ Menu
  62. -- Create a laucher widget and a main menu
  63. --myawesomemenu = {
  64. --   { "manual", terminal .. " -e man awesome" },
  65. --   { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
  66. --   { "restart", awesome.restart },
  67. --   { "quit", awesome.quit }
  68. --}
  69. gamesmenu = {
  70.    { "nexuiz", "startx /opt/nexuiz/nexuiz-sdl-svn -basedir /opt/nexuiz -- :1" },
  71.    { "trine", "startx /home/serega/games/trine/trine-bin64 -- :1" },
  72. }
  73.  
  74. mymainmenu = awful.menu({ items = {-- { "awesome" , myawesomemenu, beautiful.awesome_icon },
  75.                     { "терминал", terminal },
  76.                     { "файлы", "thunar" },
  77.                     { "интернет", "chromium" },
  78.                     { "почта", "thunderbird" },
  79.                     { "audacious", "audacious2" },
  80.                     { "qbittorrent", "qbittorrent" },
  81.                     { "libreoffice writer", "libreoffice --writer" },
  82.                     { "libreoffice calc", "libreoffice --calc" },
  83.                     { "калькулятор", "gcalctool" },
  84.                     { "stamina", "wine '/home/serega/.wine/drive_c/Program\ Files/Stamina/Stamina.exe'" },
  85.                     { "игры", gamesmenu },
  86.                     { "перезагрузка", "sudo reboot" },
  87.                     { "выключить", "sudo shutdown -h now" },
  88.                    
  89.                                   }
  90.                         })
  91.  
  92. mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
  93.                                      menu = mymainmenu })
  94. -- }}}
  95.  
  96. -- {{{ Wibox
  97.  --  Network usage widget
  98.  -- Initialize widget
  99. netwidget = widget({ type = "textbox" })
  100.  -- Register widget
  101. vicious.register(netwidget, vicious.widgets.net, '<span color="#CC9393">${eth0 down_kb}</span> <span color="#7F9F7F">${eth0 up_kb}</span>', 3)
  102. --separator
  103. separator = widget({ type = "textbox" })
  104. separator.text  = " "
  105. -- Initialize widget
  106. datewidget = widget({ type = "textbox" })
  107. -- Register widget
  108. vicious.register(datewidget, vicious.widgets.date, " : %A %d %B : %R ", 60)
  109. --
  110. -- Create a textclock widget
  111. --mytextclock = awful.widget.textclock({ align = "right" })
  112.  
  113. -- Create a systray
  114. mysystray = widget({ type = "systray" })
  115.  
  116. -- Create a wibox for each screen and add it
  117. mywibox = {}
  118. mypromptbox = {}
  119. mylayoutbox = {}
  120. mytaglist = {}
  121. mytaglist.buttons = awful.util.table.join(
  122.                     awful.button({ }, 1, awful.tag.viewonly),
  123.                     awful.button({ modkey }, 1, awful.client.movetotag),
  124.                     awful.button({ }, 3, awful.tag.viewtoggle),
  125.                     awful.button({ modkey }, 3, awful.client.toggletag),
  126.                     awful.button({ }, 4, awful.tag.viewnext),
  127.                     awful.button({ }, 5, awful.tag.viewprev)
  128.                     )
  129. mytasklist = {}
  130. mytasklist.buttons = awful.util.table.join(
  131.                      awful.button({ }, 1, function (c)
  132.                                               if c == client.focus then
  133.                                                   c.minimized = true
  134.                                               else
  135.                                                   if not c:isvisible() then
  136.                                                       awful.tag.viewonly(c:tags()[1])
  137.                                                   end
  138.                                                   -- This will also un-minimize
  139.                                                   -- the client, if needed
  140.                                                   client.focus = c
  141.                                                   c:raise()
  142.                                               end
  143.                                           end),
  144.                      awful.button({ }, 3, function ()
  145.                                               if instance then
  146.                                                   instance:hide()
  147.                                                   instance = nil
  148.                                               else
  149.                                                   instance = awful.menu.clients({ width=250 })
  150.                                               end
  151.                                           end),
  152.                      awful.button({ }, 4, function ()
  153.                                               awful.client.focus.byidx(1)
  154.                                               if client.focus then client.focus:raise() end
  155.                                           end),
  156.                      awful.button({ }, 5, function ()
  157.                                               awful.client.focus.byidx(-1)
  158.                                               if client.focus then client.focus:raise() end
  159.                                           end))
  160.  
  161. for s = 1, screen.count() do
  162.     -- Create a promptbox for each screen
  163.     mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
  164.     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  165.     -- We need one layoutbox per screen.
  166.     mylayoutbox[s] = awful.widget.layoutbox(s)
  167.     mylayoutbox[s]:buttons(awful.util.table.join(
  168.                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  169.                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  170.                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  171.                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  172.     -- Create a taglist widget
  173.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
  174.  
  175.     -- Create a tasklist widget
  176.     mytasklist[s] = awful.widget.tasklist(function(c)
  177.                                               return awful.widget.tasklist.label.currenttags(c, s)
  178.                                           end, mytasklist.buttons)
  179.  
  180.     -- Create the wibox
  181.     mywibox[s] = awful.wibox({ position = "top", screen = s })
  182.     -- Add widgets to the wibox - order matters
  183.     mywibox[s].widgets = {
  184.         {
  185.         mylauncher,          
  186.         separator,     
  187.         mytaglist[s],
  188.         separator,
  189.         mylayoutbox[s],
  190.         separator,
  191.             mypromptbox[s],
  192.             layout = awful.widget.layout.horizontal.leftright
  193.         },
  194. --        mylayoutbox[s],
  195.     datewidget,
  196.         s == 1 and mysystray or nil,
  197.     separator,
  198.     netwidget,
  199.         mytasklist[s],
  200.         layout = awful.widget.layout.horizontal.rightleft
  201.     }
  202. end
  203. -- }}}
  204.  
  205. -- {{{ Mouse bindings
  206. root.buttons(awful.util.table.join(
  207.     awful.button({ }, 3, function () mymainmenu:toggle() end),
  208.     awful.button({ }, 4, awful.tag.viewnext),
  209.     awful.button({ }, 5, awful.tag.viewprev)
  210. ))
  211. -- }}}
  212.  
  213. -- {{{ Key bindings
  214. globalkeys = awful.util.table.join(
  215.     awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
  216.     awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
  217.     awful.key({ modkey,           }, "Escape", awful.tag.history.restore),
  218.  
  219.     awful.key({ modkey,           }, "j",
  220.         function ()
  221.             awful.client.focus.byidx( 1)
  222.             if client.focus then client.focus:raise() end
  223.         end),
  224.     awful.key({ modkey,           }, "k",
  225.         function ()
  226.             awful.client.focus.byidx(-1)
  227.             if client.focus then client.focus:raise() end
  228.         end),
  229.     awful.key({ modkey,           }, "w", function () mymainmenu:show({keygrabber=true}) end),
  230.  
  231.     -- Layout manipulation
  232.     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
  233.     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
  234.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  235.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  236.     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
  237.     awful.key({ modkey,           }, "Tab",
  238.         function ()
  239.             awful.client.focus.history.previous()
  240.             if client.focus then
  241.                 client.focus:raise()
  242.             end
  243.         end),
  244.  
  245.     -- Standard program
  246.     awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
  247.     awful.key({ modkey, "Control" }, "r", awesome.restart),
  248.     awful.key({ modkey, "Shift"   }, "q", awesome.quit),
  249.  
  250.     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
  251.     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
  252.     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
  253.    
  254. awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
  255.     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
  256.     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
  257.     awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
  258.     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
  259.  
  260.     awful.key({ modkey, "Control" }, "n", awful.client.restore),
  261.  
  262.     -- Prompt
  263.     awful.key({ modkey },            "r",     function () mypromptbox[mouse.screen]:run() end),
  264.  
  265.     awful.key({ modkey }, "x",
  266.               function ()
  267.                   awful.prompt.run({ prompt = "Run Lua code: " },
  268.                   mypromptbox[mouse.screen].widget,
  269.                   awful.util.eval, nil,
  270.                   awful.util.getdir("cache") .. "/history_eval")
  271.               end)
  272. )
  273.  
  274. clientkeys = awful.util.table.join(
  275.     awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
  276.     awful.key({ modkey, "Shift"   }, "c",      function (c) c:kill()                         end),
  277.     awful.key({ modkey,           }, "q",      function (c) c:kill()                         end),
  278.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
  279.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  280.     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
  281.     awful.key({ modkey, "Shift"   }, "r",      function (c) c:redraw()                       end),
  282.     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
  283.     awful.key({ modkey,           }, "n",
  284.         function (c)
  285.             -- The client currently has the input focus, so it cannot be
  286.             -- minimized, since minimized clients can't have the focus.
  287.             c.minimized = true
  288.         end),
  289.     awful.key({ modkey,           }, "m",
  290.         function (c)
  291.             c.maximized_horizontal = not c.maximized_horizontal
  292.             c.maximized_vertical   = not c.maximized_vertical
  293.         end)
  294. )
  295.  
  296. -- Compute the maximum number of digit we need, limited to 9
  297. keynumber = 0
  298. for s = 1, screen.count() do
  299.    keynumber = math.min(9, math.max(#tags[s], keynumber));
  300. end
  301.  
  302. -- Bind all key numbers to tags.
  303. -- Be careful: we use keycodes to make it works on any keyboard layout.
  304. -- This should map on the top row of your keyboard, usually 1 to 9.
  305. for i = 1, keynumber do
  306.     globalkeys = awful.util.table.join(globalkeys,
  307.         awful.key({ modkey }, "#" .. i + 9,
  308.                   function ()
  309.                         local screen = mouse.screen
  310.                         if tags[screen][i] then
  311.                             awful.tag.viewonly(tags[screen][i])
  312.                         end
  313.                   end),
  314.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  315.                   function ()
  316.                       local screen = mouse.screen
  317.                       if tags[screen][i] then
  318.                           awful.tag.viewtoggle(tags[screen][i])
  319.                       end
  320.                   end),
  321.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  322.                   function ()
  323.                       if client.focus and tags[client.focus.screen][i] then
  324.                           awful.client.movetotag(tags[client.focus.screen][i])
  325.                       end
  326.                   end),
  327.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  328.                   function ()
  329.                       if client.focus and tags[client.focus.screen][i] then
  330.                           awful.client.toggletag(tags[client.focus.screen][i])
  331.                       end
  332.                   end))
  333. end
  334.  
  335. clientbuttons = awful.util.table.join(
  336.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  337.     awful.button({ modkey }, 1, awful.mouse.client.move),
  338.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  339.  
  340. -- Set keys
  341. root.keys(globalkeys)
  342. -- }}}
  343.  
  344.  
  345. -- {{{ Rules
  346. awful.rules.rules = {
  347.     -- All clients will match this rule.
  348.     { rule = { },
  349.       properties = { border_width = beautiful.border_width,
  350.                      border_color = beautiful.border_normal,
  351.                      focus = true,
  352.                      keys = clientkeys,
  353.                      maximized_vertical   = false,
  354.                      maximized_horizontal = false,
  355.                      buttons = clientbuttons,
  356.              size_hints_honor = false } },
  357. -- {{{ Floating clients
  358.     { rule = { class = "Gcalctool" },
  359.       properties = { floating = true } },
  360.     { rule = { class = "Qbittorrent" },
  361.       properties = { floating = true } },
  362. -- }}}
  363.  
  364. -- {{{ Clients placement
  365.     { rule = { class = "Conky" },
  366.       properties = { tag = tags[1][1] } },
  367.  
  368.     { rule = { class = "Thunar" },
  369.       properties = { tag = tags[1][1] } },
  370.  
  371.     { rule = { class = "Chromium" },
  372.       properties = { tag = tags[1][3] } },
  373.  
  374.     { rule = { class = "Thunderbird" },
  375.       properties = { tag = tags[1][3] } },
  376.  
  377.     { rule = { class = "libreoffice-writer" },
  378.       properties = { tag = tags[1][4] } },
  379.  
  380.     { rule = { class = "libreoffice-calc" },
  381.       properties = { tag = tags[1][4] } },
  382.  
  383.     { rule = { class = "Evince" },
  384.       properties = { tag = tags[1][4] } },
  385.  
  386.     { rule = { class = "Audacious" },
  387.       properties = { tag = tags[1][5] } },
  388.     { rule = { class = "Ossxmix" },
  389.       properties = { tag = tags[1][5] } },
  390.  
  391.     { rule = { class = "Gimp" },
  392.       properties = { tag = tags[1][6] } },
  393.  
  394.     { rule = { class = "Inkscape" },
  395.       properties = { tag = tags[1][7] } },
  396. }
  397. -- }}}
  398. -- }}}
  399.  
  400. -- {{{ Signals
  401. -- Signal function to execute when a new client appears.
  402. client.add_signal("manage", function (c, startup)
  403.     -- Add a titlebar
  404.     -- awful.titlebar.add(c, { modkey = modkey })
  405.  
  406.     -- Enable sloppy focus
  407. --    c:add_signal("mouse::enter", function(c)
  408. --        if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  409. --            and awful.client.focus.filter(c) then
  410. --            client.focus = c
  411. --        end
  412. --    end)
  413.  
  414.     if not startup then
  415.         -- Set the windows at the slave,
  416.         -- i.e. put it at the end of others instead of setting it master.
  417.         -- awful.client.setslave(c)
  418.  
  419.         -- Put windows in a smart way, only if they does not set an initial position.
  420.         if not c.size_hints.user_position and not c.size_hints.program_position then
  421.             awful.placement.no_overlap(c)
  422.             awful.placement.no_offscreen(c)
  423.         end
  424.     end
  425. end)
  426.  
  427. client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  428. client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  429. -- }}}
  430.  
  431. --notifications
  432. naughty.config.default_preset.position = "bottom_right"
  433. naughty.config.default_preset.font = "Ubuntu 12"
  434.  
  435. -- autorun programs
  436. awful.util.spawn_with_shell("nvidia-settings -l")
  437. awful.util.spawn_with_shell("~/scripts/xxkb_run")
  438. awful.util.spawn_with_shell("~/scripts/run_once volumeicon")
  439. awful.util.spawn_with_shell("~/scripts/run_once chromium")
  440. awful.util.spawn_with_shell("~/scripts/run_once thunar")
  441. awful.util.spawn_with_shell("~/scripts/run_once conky")
  442.  
  443.  
Advertisement
Add Comment
Please, Sign In to add comment