Advertisement
Guest User

Untitled

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