Advertisement
mightyroot

My AWESOME config

Feb 18th, 2013
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 19.79 KB | None | 0 0
  1. linux-ruwb:~ # cat .config/awesome/rc.lua
  2. -- Standard awesome library
  3. require("awful")
  4. require("awful.autofocus")
  5. require("awful.rules")
  6. -- Theme handling library
  7. require("beautiful")
  8. -- Notification library
  9. require("naughty")
  10.  
  11. --Widgets
  12. vicious = require("vicious")
  13.  
  14. -- {{{ Variable definitions
  15. -- Themes define colours, icons, and wallpapers
  16. beautiful.init("/usr/share/awesome/themes/default/theme.lua")
  17.  
  18. -- This is used later as the default terminal and editor to run.
  19. terminal = "xterm -fn 7x14"
  20. xterminal = "urxvt -fn 7x14"                                                                                                                                                                                  
  21.                                                                                                                                                                                                                
  22. --terminal = "xterm -fn 7x14 -T xterm -e /usr/sbin/pre-exec /usr/sbin/fader 0.7 &"                                                                                                                            
  23. editor = os.getenv("EDITOR") or "vi"                                                                                                                                                                          
  24. editor_cmd = terminal .. " -e " .. editor                                                                                                                                                                      
  25.                                                                                                                                                                                                                
  26. -- Default modkey.                                                                                                                                                                                            
  27. -- Usually, Mod4 is the key with a logo between Control and Alt.                                                                                                                                              
  28. -- If you do not like this or do not have such a key,                                                                                                                                                          
  29. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.                                                                                                                                    
  30. -- However, you can use another modifier like Mod1, but it may interact with others.                                                                                                                          
  31. modkey = "Mod4"                                                                                                                                                                                                
  32.                                                                                                                                                                                                                
  33. -- Table of layouts to cover with awful.layout.inc, order matters.                                                                                                                                            
  34. layouts =                                                                                                                                                                                                      
  35. {                                                                                                                                                                                                              
  36.     awful.layout.suit.floating,                                                                                                                                                                                
  37.     awful.layout.suit.tile,
  38.     awful.layout.suit.tile.left,
  39.     awful.layout.suit.tile.bottom,
  40.     awful.layout.suit.tile.top,
  41.     awful.layout.suit.fair,
  42.     awful.layout.suit.fair.horizontal,
  43.     awful.layout.suit.spiral,
  44.     awful.layout.suit.spiral.dwindle,
  45.     awful.layout.suit.max,
  46.     awful.layout.suit.max.fullscreen,
  47.     awful.layout.suit.magnifier
  48. }
  49. -- }}}
  50.  
  51.  
  52. -- {{{ Tags DEFAULT
  53. -- Define a tag table which hold all screen tags.
  54. -- tags = {}
  55. -- for s = 1, screen.count() do
  56.     -- Each screen has its own tag table.
  57. --     tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])
  58. -- end
  59. -- }}}
  60.  
  61. -- {{{ Tags
  62.   -- Define a tag table which will hold all screen tags.
  63. tags = {
  64.     names  = { 1, 2, 3, 4, 5, 6, 7, 8, "-" },
  65.     layout = { layouts[8], layouts[1], layouts[1], layouts[1], layouts[7], layouts[12], layouts[1], layouts[1], layouts[1] }
  66.     }
  67.  
  68. for s = 1, screen.count() do
  69.  -- Each screen has its own tag table.
  70.     tags[s] = awful.tag(tags.names, s, tags.layout)
  71. end
  72.  -- }}}
  73.  
  74.  
  75. -- {{{ Menu
  76. -- Create a laucher widget and a main menu
  77. myawesomemenu = {
  78.     { "Suspend", "powersave -u"},
  79.     { "Hibernate", "powersave -U"},
  80.    { "manual", terminal .. " -e man awesome" },
  81.    { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
  82.    { "restart", awesome.restart },
  83.    { "quit", awesome.quit }
  84. }
  85.  
  86.  
  87. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
  88.                                     { "Console", terminal },
  89.                                     { "Transparent", "urxvt -fn 7x14"},
  90.                                     { "Firefox", "firefox"},
  91.                                     { "Krusader", "krusader"},
  92.                                     { "Kppp", "kppp"}
  93.                                   }
  94.                         })
  95.  
  96. mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
  97.                                      menu = mymainmenu })
  98. -- }}}
  99.  
  100. -- {{{ Wibox
  101. -- Create a textclock widget
  102. --mytextclock = awful.widget.textclock({ align = "right" })
  103. --mybattery = awful.widget.battery({ align = "right" })
  104. datewidget  = widget({ type = "textbox" })
  105.  vicious.register(datewidget, vicious.widgets.date, "| %a  %d |  %R ", 60)
  106.  
  107.  
  108. -- CPU temperature
  109. thermalwidget  = widget({ type = "textbox" })
  110.  vicious.register(thermalwidget, vicious.widgets.thermal, "  $1°C", 20, { "thermal_zone0", "sys"} )
  111.  
  112. termwidget = awful.widget.progressbar()
  113.   termwidget:set_width(20)
  114.   termwidget:set_height(20)
  115.   termwidget:set_vertical(true)
  116.   termwidget:set_background_color("#000000")
  117.   termwidget:set_border_color("#494B4F")
  118.   termwidget:set_color("#AECF96")
  119.   termwidget:set_gradient_colors({ "#FF5656", "#88A175", "#AECF96" })
  120.  
  121. -- vicious.register(thermwidget, vicious.widgets.thermal, "$1", 20, { "thermal_zone0", "sys"} )
  122.  
  123.  
  124. -- Battery Wiget
  125. baterywidget  = widget({ type = "textbox" })
  126.   vicious.register(baterywidget, vicious.widgets.bat, " | $1 $2 ", 120, "BAT0")
  127.  
  128. batwidget = awful.widget.progressbar()
  129.   batwidget:set_width(20)
  130.   batwidget:set_height(24)
  131.   batwidget:set_vertical(true)
  132.   batwidget:set_background_color("#000000")
  133.   batwidget:set_border_color("#494B4F")
  134.   batwidget:set_color("#AECF96")
  135.   batwidget:set_gradient_colors({ "#FF5656", "#88A175", "#AECF96" })
  136.     vicious.register(batwidget, vicious.widgets.bat, "$2", 120, "BAT0")
  137.  
  138. cpuwidget = awful.widget.graph()
  139.   cpuwidget:set_width(50)
  140.   cpuwidget:set_height(24)
  141.   cpuwidget:set_background_color("#494B4F")
  142.   cpuwidget:set_color("#FF5656")
  143.   cpuwidget:set_gradient_colors({ "#AECF96", "#88A175", "#FF5656" })
  144.  vicious.register(cpuwidget, vicious.widgets.cpu, "$1")
  145.  
  146.  
  147. -- Create a systray
  148. mysystray = widget({ type = "systray" })
  149.  
  150. -- Create a wibox for each screen and add it
  151. mywibox = {}
  152. mypromptbox = {}
  153. mylayoutbox = {}
  154. mytaglist = {}
  155. mytaglist.buttons = awful.util.table.join(
  156.                     awful.button({ }, 1, awful.tag.viewonly),
  157.                     awful.button({ modkey }, 1, awful.client.movetotag),
  158.                     awful.button({ }, 3, awful.tag.viewtoggle),
  159.                     awful.button({ modkey }, 3, awful.client.toggletag),
  160.                     awful.button({ }, 4, awful.tag.viewnext),
  161.                     awful.button({ }, 5, awful.tag.viewprev)
  162.                     )
  163. mytasklist = {}
  164. mytasklist.buttons = awful.util.table.join(
  165.                      awful.button({ }, 1, function (c)
  166.                                               if not c:isvisible() then
  167.                                                   awful.tag.viewonly(c:tags()[1])
  168.                                               end
  169.                                               client.focus = c
  170.                                               c:raise()
  171.                                           end),
  172.                      awful.button({ }, 3, function ()
  173.                                               if instance then
  174.                                                   instance:hide()
  175.                                                   instance = nil
  176.                                               else
  177.                                                   instance = awful.menu.clients({ width=250 })
  178.                                               end
  179.                                           end),
  180.                      awful.button({ }, 4, function ()
  181.                                               awful.client.focus.byidx(1)
  182.                                               if client.focus then client.focus:raise() end
  183.                                           end),
  184.                      awful.button({ }, 5, function ()
  185.                                               awful.client.focus.byidx(-1)
  186.                                               if client.focus then client.focus:raise() end
  187.                                           end))
  188.  
  189. for s = 1, screen.count() do
  190.     -- Create a promptbox for each screen
  191.     mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
  192.     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  193.     -- We need one layoutbox per screen.
  194.     mylayoutbox[s] = awful.widget.layoutbox(s)
  195.     mylayoutbox[s]:buttons(awful.util.table.join(
  196.                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  197.                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  198.                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  199.                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  200.     -- Create a taglist widget
  201.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
  202.  
  203.     -- Create a tasklist widget
  204.     mytasklist[s] = awful.widget.tasklist(function(c)
  205.                                               return awful.widget.tasklist.label.currenttags(c, s)
  206.                                           end, mytasklist.buttons)
  207.  
  208.     -- Create the wibox
  209.     mywibox[s] = awful.wibox({ position = "bottom", screen = s })
  210.     -- Add widgets to the wibox - order matters
  211.     mywibox[s].widgets = {
  212.         {
  213.             mylauncher,
  214.             mytaglist[s],
  215.             mypromptbox[s],
  216.             layout = awful.widget.layout.horizontal.leftright
  217.         },
  218.         mylayoutbox[s],
  219.         mytextclock,
  220.         datewidget,
  221. --      termwidget,
  222.         baterywidget,
  223.         batwidget,
  224.         cpuwidget,
  225.         thermalwidget,
  226.         s == 1 and mysystray or nil,
  227.         mytasklist[s],
  228.         layout = awful.widget.layout.horizontal.rightleft
  229.     }
  230. end
  231. -- }}}
  232.  
  233. -- {{{ Mouse bindings
  234. root.buttons(awful.util.table.join(
  235.     awful.button({ }, 3, function () mymainmenu:toggle() end),
  236.     awful.button({ }, 4, awful.tag.viewnext),
  237.     awful.button({ }, 5, awful.tag.viewprev)
  238. ))
  239. -- }}}
  240.  
  241. -- {{{ Key bindings
  242. globalkeys = awful.util.table.join(
  243.     awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
  244.     awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
  245.     awful.key({ modkey,           }, "h", awful.tag.history.restore),
  246.  
  247.     awful.key({ modkey,           }, "j",
  248.         function ()
  249.             awful.client.focus.byidx( 1)
  250.             if client.focus then client.focus:raise() end
  251.         end),
  252.     awful.key({ modkey,           }, "Tab",
  253.         function ()
  254.             awful.client.focus.byidx(-1)
  255.             if client.focus then client.focus:raise() end
  256.         end),
  257.     awful.key({ modkey,           }, "Esc", function () mymainmenu:show(true)        end),
  258.  
  259.     -- Layout manipulation
  260.     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
  261.     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
  262.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  263.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  264.     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
  265.     awful.key({ modkey,           }, "q",
  266.         function ()
  267.             awful.client.focus.history.previous()
  268.             if client.focus then
  269.                 client.focus:raise()
  270.             end
  271.         end),
  272.  
  273.     -- Standard program
  274.     awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
  275.     awful.key({ modkey,           }, "w", function () awful.util.spawn(xterminal) end),
  276.     awful.key({ modkey, "Control" }, "r", awesome.restart),
  277.     awful.key({ modkey, "Shift"   }, "q", awesome.quit),
  278.  
  279.     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
  280.     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
  281.     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
  282.     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
  283.     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
  284.     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
  285.     awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
  286.     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
  287.  
  288.     -- Prompt
  289.     awful.key({ modkey },            "r",     function () mypromptbox[mouse.screen]:run() end),
  290.  
  291.     awful.key({ modkey }, "x",
  292.               function ()
  293.                   awful.prompt.run({ prompt = "Run Lua code: " },
  294.                   mypromptbox[mouse.screen].widget,
  295.                   awful.util.eval, nil,
  296.                   awful.util.getdir("cache") .. "/history_eval")
  297.               end)
  298. )
  299.  
  300. clientkeys = awful.util.table.join(
  301.     awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
  302.     awful.key({ modkey,           }, "F4",      function (c) c:kill()                         end),
  303.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
  304.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  305.     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
  306.     awful.key({ modkey, "Shift"   }, "r",      function (c) c:redraw()                       end),
  307.     awful.key({ modkey,           }, "n",      function (c) c.minimized = not c.minimized    end),
  308.     awful.key({ modkey,           }, "m",
  309.         function (c)
  310.             c.maximized_horizontal = not c.maximized_horizontal
  311.             c.maximized_vertical   = not c.maximized_vertical
  312.         end)
  313. )
  314.  
  315. -- Compute the maximum number of digit we need, limited to 9
  316. keynumber = 0
  317. for s = 1, screen.count() do
  318.    keynumber = math.min(9, math.max(#tags[s], keynumber));
  319. end
  320.  
  321. -- Bind all key numbers to tags.
  322. -- Be careful: we use keycodes to make it works on any keyboard layout.
  323. -- This should map on the top row of your keyboard, usually 1 to 9.
  324. for i = 1, keynumber do
  325.     globalkeys = awful.util.table.join(globalkeys,
  326.         awful.key({ modkey }, "#" .. i + 9,
  327.                   function ()
  328.                         local screen = mouse.screen
  329.                         if tags[screen][i] then
  330.                             awful.tag.viewonly(tags[screen][i])
  331.                         end
  332.                   end),
  333.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  334.                   function ()
  335.                       local screen = mouse.screen
  336.                       if tags[screen][i] then
  337.                           awful.tag.viewtoggle(tags[screen][i])
  338.                       end
  339.                   end),
  340.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  341.                   function ()
  342.                       if client.focus and tags[client.focus.screen][i] then
  343.                           awful.client.movetotag(tags[client.focus.screen][i])
  344.                       end
  345.                   end),
  346.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  347.                   function ()
  348.                       if client.focus and tags[client.focus.screen][i] then
  349.                           awful.client.toggletag(tags[client.focus.screen][i])
  350.                       end
  351.                   end))
  352. end
  353.  
  354. clientbuttons = awful.util.table.join(
  355.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  356.     awful.button({ modkey }, 1, awful.mouse.client.move),
  357.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  358.  
  359. -- Set keys
  360. root.keys(globalkeys)
  361. -- }}}
  362.  
  363. -- {{{ Rules
  364. awful.rules.rules = {
  365.     -- All clients will match this rule.
  366.     { rule = { },
  367.       properties = { border_width = beautiful.border_width,
  368.                      border_color = beautiful.border_normal,
  369.                      focus = 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 = "kppp" },
  380.       properties = { tag = tags[1][2] } },
  381.     { rule = { class = "Google Chrome" },
  382.       properties = { tag = tags[1][2] } },
  383.     { rule = { class = "Firefox" },
  384.       properties = { tag = tags[1][2] } },
  385.     { rule = { class = "Krusader" },
  386.       properties = { tag = tags[1][4] } },
  387.     { rule = { class = "Konsole" },
  388.       properties = { tag = tags[1][3] } },
  389.     { rule = { class = "Kopete" },
  390.       properties = { tag = tags[1][5] } },
  391. }
  392. -- }}}
  393.  
  394. -- {{{ Signals
  395. -- Signal function to execute when a new client appears.
  396. client.add_signal("manage", function (c, startup)
  397.     -- Add a titlebar
  398.     -- awful.titlebar.add(c, { modkey = modkey })
  399.  
  400.     -- Enable sloppy focus
  401.     c:add_signal("mouse::enter", function(c)
  402.         if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  403.             and awful.client.focus.filter(c) then
  404.             client.focus = c
  405.         end
  406.     end)
  407.  
  408.     if not startup then
  409.         -- Set the windows at the slave,
  410.         -- i.e. put it at the end of others instead of setting it master.
  411.         -- awful.client.setslave(c)
  412.  
  413.         -- Put windows in a smart way, only if they does not set an initial position.
  414.         if not c.size_hints.user_position and not c.size_hints.program_position then
  415.             awful.placement.no_overlap(c)
  416.             awful.placement.no_offscreen(c)
  417.         end
  418.     end
  419. end)
  420.  
  421. client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  422. client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  423. -- }}}
  424.  
  425.  
  426. awful.util.spawn_with_shell("krusader")
  427. awful.util.spawn_with_shell("konsole")
  428. awful.util.spawn_with_shell("kopete")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement