Advertisement
Guest User

Untitled

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