Jedipottsy

Untitled

Mar 10th, 2011
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.76 KB | None | 0 0
  1. -- Standard awesome library
  2. require("awful")
  3. require("awful.autofocus")
  4. require("awful.rules")
  5. -- Widget and layout library
  6. require("wibox")
  7. require("wicked")
  8. require("vicious")
  9. -- Theme handling library
  10. require("beautiful")
  11. -- Notification library require("naughty")
  12.  
  13. -- {{{ Variable definitions
  14. -- Themes define colours, icons, and wallpapers
  15. beautiful.init("/home/jedipottsy/.config/awesome/themes/pastel/theme.lua")
  16.  
  17. -- This is used later as the default terminal and editor to run.
  18. terminal = "urxvtc"
  19. editor = os.getenv("EDITOR") or "nano"
  20. editor_cmd = terminal .. " -e " .. editor
  21.  
  22. -- Default modkey.
  23. -- Usually, Mod4 is the key with a logo between Control and Alt.
  24. -- If you do not like this or do not have such a key,
  25. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  26. -- However, you can use another modifier like Mod1, but it may interact with others.
  27. modkey = "Mod4"
  28.  
  29. -- Table of layouts to cover with awful.layout.inc, order matters.
  30. layouts =
  31. {
  32.     awful.layout.suit.tile,
  33.     awful.layout.suit.tile.left,
  34.     awful.layout.suit.tile.bottom,
  35.     awful.layout.suit.tile.top,
  36.     awful.layout.suit.fair,
  37.     awful.layout.suit.fair.horizontal,
  38.     awful.layout.suit.max,
  39. }
  40. -- }}}
  41.  
  42. -- {{{ Tags
  43. -- Define a tag table which hold all screen tags.
  44. tags = {
  45.     names = { "main", "web", "terminal", "social", "music" },
  46.     layout = { layouts[1], layouts[7], layouts[1], layouts[1], layouts[7] }
  47. }
  48. for s = 1, screen.count() do
  49.     -- Each screen has its own tag table.
  50.     tags[s] = awful.tag(tags.names, s, tags.layout)
  51. end
  52. -- }}}
  53.  
  54. -- {{{ Menu
  55. -- Create a laucher widget and a main menu
  56. myawesomemenu = {
  57.    { "manual", terminal .. " -e man awesome" },
  58.    { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
  59.    { "reload", awesome.restart },
  60.    { "lock", terminal .. " -e xscreensaver-command --lock" },
  61.    { "restart", terminal .. " -e sudo shutdown -r now" },
  62.    { "shutdown", terminal .. " -e sudo shutdown -h now" },
  63.    { "quit", awesome.quit }
  64. }
  65.  
  66. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
  67.                                     { "open terminal", terminal }
  68.                                   }
  69.                         })
  70.  
  71. mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
  72.                                      menu = mymainmenu })
  73. -- }}}
  74.  
  75. -- {{{ Wibox
  76. -- Create a textclock widget
  77. mytextclock = awful.widget.textclock()
  78.  
  79.  
  80. -- Create a netwidget
  81. dnicon = widget({ type = "imagebox" })
  82. upicon = widget({ type = "imagebox" })
  83. dnicon.image = image("/home/jfalco/.config/awesome/icons/down.png")
  84. upicon.image = image("/home/jfalco/.config/awesome/icons/up.png")
  85. -- Initilize widget
  86. netwidget = widget({ type = "textbox" })
  87. -- Register widget
  88. vicious.register(netwidget, vicious.widgets.net, "${wlan0 up_kb}kb/s / ${wlan0 down_kb}kb/s", 1)
  89.  
  90. -- Create a batwidget
  91. baticon = widget({ type = "imagebox" })
  92. baticon.image = image("/home/jfalco/.config/awesome/icons/bat.png")
  93. -- Initilize widget
  94. batwidget = widget({ type = "textbox" })
  95. -- Register widget
  96. vicious.register(batwidget, vicious.widgets.bat, "$1$2%", 31, "BAT0")
  97.  
  98. -- Create cpuwidget
  99. cpuicon = widget({ type = "imagebox" })
  100. cpuicon.image = image("/home/jfalco/.config/awesome/icons/cpu.png")
  101. -- Initilize widget
  102. cpuwidget = widget({ type = "textbox" })
  103. -- Register widget
  104. vicious.register(cpuwidget, vicious.widgets.cpu, "$1%", 2)
  105.  
  106. -- Create a wifiwidget
  107. wifiicon = widget({ type = "imagebox" })
  108. wifiicon.image = image("/home/jfalco/.config/awesome/icons/wifi.png")
  109. -- Initilize widget
  110. wifiwidget = widget({ type = "textbox" })
  111. -- Register widget
  112. vicious.register(wifiwidget, vicious.widgets.wifi, "${ssid} ${link}% ${rate} Mb/s", 5, "wlan0")
  113.  
  114. -- Create a volume widget
  115. volicon = widget({ type ="imagebox" })
  116. volicon.image = image("/home/jfalco/.config/awesome/icons/vol.png")
  117. -- Initilize widget
  118. volwidget = widget({ type = "textbox" })
  119. -- Register widget
  120. vicious.register(volwidget, vicious.widgets.volume, " $1% ", 2, "Master")
  121.  
  122.  
  123.  
  124.  
  125. -- Create a wibox for each screen and add it
  126. mywibox = {}
  127. mypromptbox = {}
  128. mylayoutbox = {}
  129. mytaglist = {}
  130. mytaglist.buttons = awful.util.table.join(
  131.                     awful.button({ }, 1, awful.tag.viewonly),
  132.                     awful.button({ modkey }, 1, awful.client.movetotag),
  133.                     awful.button({ }, 3, awful.tag.viewtoggle),
  134.                     awful.button({ modkey }, 3, awful.client.toggletag),
  135.                     awful.button({ }, 4, awful.tag.viewnext),
  136.                     awful.button({ }, 5, awful.tag.viewprev)
  137.                     )
  138. mytasklist = {}
  139. mytasklist.buttons = awful.util.table.join(
  140.                      awful.button({ }, 1, function (c)
  141.                                               if not c:isvisible() then
  142.                                                   awful.tag.viewonly(c:tags()[1])
  143.                                               end
  144.                                               client.focus = c
  145.                                               c:raise()
  146.                                           end),
  147.                      awful.button({ }, 3, function ()
  148.                                               if instance then
  149.                                                   instance:hide()
  150.                                                   instance = nil
  151.                                               else
  152.                                                   instance = awful.menu.clients({ width=250 })
  153.                                               end
  154.                                           end),
  155.                      awful.button({ }, 4, function ()
  156.                                               awful.client.focus.byidx(1)
  157.                                               if client.focus then client.focus:raise() end
  158.                                           end),
  159.                      awful.button({ }, 5, function ()
  160.                                               awful.client.focus.byidx(-1)
  161.                                               if client.focus then client.focus:raise() end
  162.                                           end))
  163.  
  164. for s = 1, screen.count() do
  165.     -- Create a promptbox for each screen
  166.     mypromptbox[s] = awful.widget.prompt()
  167.     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  168.     -- We need one layoutbox per screen.
  169.     mylayoutbox[s] = awful.widget.layoutbox(s)
  170.     mylayoutbox[s]:buttons(awful.util.table.join(
  171.                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  172.                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  173.                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  174.                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  175.     -- Create a taglist widget
  176.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
  177.  
  178.     -- Create a tasklist widget
  179.     mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
  180.  
  181.     -- Create the wibox
  182.     mywibox[s] = awful.wibox({ position = "top", screen = s })
  183.  
  184.     -- Widgets that are aligned to the left
  185.     local left_layout = wibox.layout.fixed.horizontal()
  186.     left_layout:add(mytaglist[s])
  187.     left_layout:add(mypromptbox[s])
  188.  
  189.     -- Widgets that are aligned to the right
  190.     local right_layout = wibox.layout.fixed.horizontal()
  191.     if s == 1 then right_layout:add(wibox.widget.systray()) end
  192.     right_layout:add(batwidget)
  193.     right_layout:add(mytextclock)
  194.     right_layout:add(mylayoutbox[s])
  195.  
  196.     -- Now bring it all together (with the tasklist in the middle)
  197.     local layout = wibox.layout.align.horizontal()
  198.     layout:set_left(left_layout)
  199.     layout:set_middle(mytasklist[s])
  200.     layout:set_right(right_layout)
  201.  
  202.     mywibox[s]:set_widget(layout)
  203. end
  204. -- }}}
  205.  
  206. -- {{{ Mouse bindings
  207. root.buttons(awful.util.table.join(
  208.     awful.button({ }, 3, function () mymainmenu:toggle() end),
  209.     awful.button({ }, 4, awful.tag.viewnext),
  210.     awful.button({ }, 5, awful.tag.viewprev)
  211. ))
  212. -- }}}
  213.  
  214. -- {{{ Key bindings
  215. globalkeys = awful.util.table.join(
  216.     awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
  217.     awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
  218.     awful.key({ modkey,           }, "Escape", awful.tag.history.restore),
  219.  
  220.     awful.key({ modkey,           }, "j",
  221.         function ()
  222.             awful.client.focus.byidx( 1)
  223.             if client.focus then client.focus:raise() end
  224.         end),
  225.     awful.key({ modkey,           }, "k",
  226.         function ()
  227.             awful.client.focus.byidx(-1)
  228.             if client.focus then client.focus:raise() end
  229.         end),
  230.     awful.key({ modkey,           }, "w", function () mymainmenu:show({keygrabber=true}) end),
  231.  
  232.     -- Layout manipulation
  233.     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
  234.     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
  235.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  236.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  237.     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
  238.     awful.key({ modkey,           }, "Tab",
  239.         function ()
  240.             awful.client.focus.history.previous()
  241.             if client.focus then
  242.                 client.focus:raise()
  243.             end
  244.         end),
  245.  
  246.     -- Standard program
  247.     awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
  248.     awful.key({ modkey, "Control" }, "r", awesome.restart),
  249.     awful.key({ modkey, "Shift"   }, "q", awesome.quit),
  250.  
  251.     -- Applications
  252.  
  253.     awful.key({ modkey,       }, "e", function ()
  254. awful.util.spawn("chromium-browser") end),
  255.  
  256.     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
  257.     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
  258.     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
  259.     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
  260.     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
  261.     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
  262.     awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
  263.     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
  264.  
  265.     awful.key({ modkey, "Control" }, "n", awful.client.restore),
  266.  
  267.     -- Prompt
  268.     awful.key({ modkey },            "r",     function () mypromptbox[mouse.screen]:run() end),
  269.  
  270.     awful.key({ modkey }, "x",
  271.               function ()
  272.                   awful.prompt.run({ prompt = "Run Lua code: " },
  273.                   mypromptbox[mouse.screen].widget,
  274.                   awful.util.eval, nil,
  275.                   awful.util.getdir("cache") .. "/history_eval")
  276.               end)
  277. )
  278.  
  279. clientkeys = awful.util.table.join(
  280.     awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
  281.     awful.key({ modkey, "Shift"   }, "c",      function (c) c:kill()                         end),
  282.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
  283.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  284.     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
  285.     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
  286.     awful.key({ modkey,           }, "n",      function (c) c.minimized = not c.minimized    end),
  287.     awful.key({ modkey,           }, "m",
  288.         function (c)
  289.             c.maximized_horizontal = not c.maximized_horizontal
  290.             c.maximized_vertical   = not c.maximized_vertical
  291.         end)
  292. )
  293.  
  294. -- Compute the maximum number of digit we need, limited to 9
  295. keynumber = 0
  296. for s = 1, screen.count() do
  297.    keynumber = math.min(9, math.max(#tags[s], keynumber));
  298. end
  299.  
  300. -- Bind all key numbers to tags.
  301. -- Be careful: we use keycodes to make it works on any keyboard layout.
  302. -- This should map on the top row of your keyboard, usually 1 to 9.
  303. for i = 1, keynumber do
  304.     globalkeys = awful.util.table.join(globalkeys,
  305.         awful.key({ modkey }, "#" .. i + 9,
  306.                   function ()
  307.                         local screen = mouse.screen
  308.                         if tags[screen][i] then
  309.                             awful.tag.viewonly(tags[screen][i])
  310.                         end
  311.                   end),
  312.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  313.                   function ()
  314.                       local screen = mouse.screen
  315.                       if tags[screen][i] then
  316.                           awful.tag.viewtoggle(tags[screen][i])
  317.                       end
  318.                   end),
  319.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  320.                   function ()
  321.                       if client.focus and tags[client.focus.screen][i] then
  322.                           awful.client.movetotag(tags[client.focus.screen][i])
  323.                       end
  324.                   end),
  325.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  326.                   function ()
  327.                       if client.focus and tags[client.focus.screen][i] then
  328.                           awful.client.toggletag(tags[client.focus.screen][i])
  329.                       end
  330.                   end))
  331. end
  332.  
  333. clientbuttons = awful.util.table.join(
  334.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  335.     awful.button({ modkey }, 1, awful.mouse.client.move),
  336.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  337.  
  338. -- Set keys
  339. root.keys(globalkeys)
  340. -- }}}
  341.  
  342. -- {{{ Rules
  343. awful.rules.rules = {
  344.     -- All clients will match this rule.
  345.    { rule = { },
  346.       properties = { border_width = beautiful.border_width,
  347.                      border_color = beautiful.border_normal,
  348.                      focus = true,
  349.                      keys = clientkeys,
  350.                      buttons = clientbuttons } },
  351.     { rule = { class = "MPlayer" },
  352.       properties = { floating = true } },
  353.     { rule = { class = "pinentry" },
  354.       properties = { floating = true } },
  355.     { rule = { class = "gimp" },
  356.       properties = { floating = true } },
  357.  
  358.    { rule = { class = "chrome" } ,
  359.       properties = { tag = tags[1][1] , switchtotag = true } }
  360.  
  361.     -- Set Firefox to always map on tags number 2 of screen 1.
  362.     -- { rule = { class = "Firefox" },
  363.     --   properties = { tag = tags[1][2] } },
  364. }
  365. -- }}}
  366.  
  367. -- {{{ Signals
  368. -- Signal function to execute when a new client appears.
  369. client.connect_signal("manage", function (c, startup)
  370.     -- Enable sloppy focus
  371.     c:connect_signal("mouse::enter", function(c)
  372.         if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  373.             and awful.client.focus.filter(c) then
  374.             client.focus = c
  375.         end
  376.     end)
  377.  
  378.     if not startup then
  379.         -- Set the windows at the slave,
  380.         -- i.e. put it at the end of others instead of setting it master.
  381.         -- awful.client.setslave(c)
  382.  
  383.         -- Put windows in a smart way, only if they does not set an initial position.
  384.         if not c.size_hints.user_position and not c.size_hints.program_position then
  385.             awful.placement.no_overlap(c)
  386.             awful.placement.no_offscreen(c)
  387.         end
  388.     end
  389. end)
  390.  
  391. client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  392. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  393. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment