Advertisement
Guest User

Untitled

a guest
Jul 2nd, 2010
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 19.16 KB | None | 0 0
  1. -- Standard awesome library
  2. require("awful")
  3. require("awful.autofocus")
  4. require("awful.rules")
  5. require("beautiful")
  6. require("naughty")
  7. require("vicious")
  8. require("wicked")
  9.  
  10. os.setlocale(os.getenv("LANG"))
  11. -------------------------------------------------------------------------
  12. beautiful.init("/usr/share/awesome/themes/death/theme.lua")
  13. -- This is used later as the default terminal and editor to run.
  14. terminal = "urxvt"
  15. editor = os.getenv("EDITOR") or "nano"
  16. editor_cmd = terminal .. " -e " .. editor
  17.  
  18. -- Default modkey.
  19. -- Usually, Mod4 is the key with a logo between Control and Alt.
  20. -- If you do not like this or do not have such a key,
  21. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  22. -- However, you can use another modifier like Mod1, but it may interact with others.
  23. modkey = "Mod4"
  24. modkey1 = "Mod1"
  25.  
  26. -- Table of layouts to cover with awful.layout.inc, order matters.
  27. layouts =
  28. {
  29.  
  30.     awful.layout.suit.tile,
  31.     awful.layout.suit.floating,
  32.     --awful.layout.suit.tile.left,
  33.     awful.layout.suit.tile.bottom,
  34.     --awful.layout.suit.tile.top,
  35.     awful.layout.suit.fair,
  36.     --awful.layout.suit.fair.horizontal,
  37.     --awful.layout.suit.spiral,
  38.     --awful.layout.suit.spiral.dwindle,
  39.     --awful.layout.suit.max,
  40.     awful.layout.suit.max.fullscreen,
  41.     --awful.layout.suit.magnifier
  42.  
  43. }
  44. -- }}}
  45.  
  46. -- {{{ Tags
  47. -- Define a tag table which hold all screen tags.
  48. tags = {}
  49. for s = 1, screen.count() do
  50.     -- Each screen has its own tag table.
  51.     tags[s] = awful.tag({ "misc", "files", "web", "im", "term" }, s, layouts[1] )
  52. end
  53. -- }}}
  54.  
  55. -- {{{ Menu
  56. -- Create a laucher widget and a main menu
  57.  
  58.  
  59. mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
  60.                                      menu = mymainmenu })
  61. --}}}
  62.  
  63. -- {{{ Wibox
  64. -- Create a textclock widget
  65. mytextclock = awful.widget.textclock({align = "right"}, "%a %b %d, %H:%M", 1  )
  66. mytextclock:buttons(awful.util.table.join(
  67. awful.button({ }, 3, function () awful.util.spawn("orage --toggle")    end),
  68. awful.button({ }, 1, function () awful.util.spawn("orage --toggle")    end)))
  69.  
  70. spacer = widget({ type = "textbox"})
  71. separator = widget({ type = "textbox"})
  72. spacer.text = " "
  73. separator.text = "|"
  74.  
  75. fswidget = widget({ type = "textbox" })
  76.   --fswidget:buttons(
  77.     --awful.button({ }, 1, function () awful.util.spawn('sudo thunar /') end))
  78. vicious.register(fswidget, vicious.widgets.fs, "<span><b>root:</b></span> ${/ avail_gb}GB", 30)
  79.  
  80. fsmwidget = widget({ type = "textbox" })
  81.   --fsmwidget:buttons(
  82.     --awful.button({ }, 1, function () awful.util.spawn('thunar') end))
  83. vicious.register(fsmwidget, vicious.widgets.fs, "<span><b>home:</b></span> ${/home avail_gb}GB", 30)
  84.  
  85. memwidget = widget({ type = "textbox" })
  86. vicious.register(memwidget, vicious.widgets.mem, "<span><b>mem:</b></span> $2MB", 3)
  87.  
  88. cpuwidget = widget({ type = "textbox" })
  89. vicious.register(cpuwidget, vicious.widgets.cpu, "<span><b>cpu:</b></span> $1%" , 3)
  90.  
  91. batwidget = widget({ type = "textbox" })
  92.  batwidget:buttons(
  93.     awful.button({ }, 1, function () awful.util.spawn('/home/death/.shutdown') end))
  94. vicious.register(batwidget, vicious.widgets.bat,"<span><b>bat:</b></span> $1$2% [$3]", 61, "BAT0")
  95.  
  96. wifiwidget = widget({ type = "textbox" })
  97. wifiwidget:buttons(
  98.     awful.button({ }, 1, function () awful.util.spawn('urxvt -e "wicd-curses"') end))
  99. vicious.register(wifiwidget, vicious.widgets.wifi, "${ssid} ${link}%", 5, "wlan0")
  100.  
  101. deadbeefwidget = widget({ type = "textbox" })
  102. local function update_deadbeef()
  103.   local fd = io.popen("sh ~/.conky/deadbeef.sh")
  104.        deadbeefwidget.text = '' .. fd:read("*all")
  105.   fd:close()
  106. end
  107. update_deadbeef()
  108. mytimer1 = timer({ timeout = 5 })
  109. mytimer1:add_signal("timeout", update_deadbeef)
  110. mytimer1:start()
  111.  
  112. --moneywidget = widget({ type = "textbox" })
  113. --local function update_money()
  114.   --local fd = io.popen("sudo python ~/.conky/traffic_mts.py")
  115.         --moneywidget.text = '' .. fd:read("*all")
  116.   --fd:close()
  117. --end
  118. --update_money()
  119. --mytimer2 = timer({ timeout = 180 })
  120. --mytimer2:add_signal("timeout", update_money)
  121. --mytimer2:start()
  122.  
  123. thermalwidget = widget({ type = "textbox" })
  124. vicious.register(thermalwidget, vicious.widgets.thermal, "$1°", 19, "thermal_zone0")
  125.  
  126.  
  127. --pacwidget = widget({ type = "textbox" })
  128. --vicious.register(pacwidget, vicious.widgets.pkg,
  129.   --function (widget, args)
  130.       --return 'pkgs [' .. args[1] .. ']'
  131.   --end, 3607, 'Arch')
  132.  
  133. -- Create a systray
  134.  
  135. mysystray = widget({ type = "systray" })
  136.  
  137. -- Create a wibox for each screen and add it
  138. mywibox = {}
  139. mywiboxbottom = {}
  140. mypromptbox = {}
  141. mylayoutbox = {}
  142. mytaglist = {}
  143. mytaglist.buttons = awful.util.table.join(
  144.                     awful.button({ }, 1, awful.tag.viewonly),
  145.                     awful.button({ modkey }, 1, awful.client.movetotag),
  146.                     awful.button({ }, 3, awful.tag.viewtoggle),
  147.                     awful.button({ modkey }, 3, awful.client.toggletag),
  148.                     awful.button({ }, 5, awful.tag.viewnext),
  149.                     awful.button({ }, 4, awful.tag.viewprev)
  150.                     )
  151. mytasklist = {}
  152. mytasklist.buttons = awful.util.table.join(
  153.                      awful.button({ }, 1, function (c)
  154.                                               if not c:isvisible() then
  155.                                                   awful.tag.viewonly(c:tags()[1])
  156.                                               end
  157.                                               client.focus = c
  158.                                               c:raise()
  159.                                           end),
  160.  awful.button({ }, 3,function (c) c.minimized = not c.minimized end),
  161.  awful.button({ }, 2,      function (c) c:kill()                         end),
  162.                      awful.button({ }, 4, function ()
  163.                                               awful.client.focus.byidx(1)
  164.                                               if client.focus then client.focus:raise() end
  165.                                           end),
  166.                      awful.button({ }, 5, function ()
  167.                                               awful.client.focus.byidx(-1)
  168.                                               if client.focus then client.focus:raise() end
  169.                                           end))
  170.  
  171. for s = 1, screen.count() do
  172.     -- Create a promptbox for each screen
  173.     mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
  174.     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  175.     -- We need one layoutbox per screen.
  176.     mylayoutbox[s] = awful.widget.layoutbox(s)
  177.     mylayoutbox[s]:buttons(awful.util.table.join(
  178.                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  179.                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  180.                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  181.                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  182.     -- Create a taglist widget
  183.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
  184.  
  185.     -- Create a tasklist widget
  186.     mytasklist[s] = awful.widget.tasklist(function(c)
  187.                                               return awful.widget.tasklist.label.currenttags(c, s)
  188.                                           end, mytasklist.buttons)
  189.  
  190.     -- Create the wibox
  191.     mywibox[s] = awful.wibox({ position = "bottom", screen = s })
  192.  -- Add widgets to the wibox - order matters
  193.     mywibox[s].widgets = {
  194.         {
  195.           --  mylauncher,
  196.             mytaglist[s],
  197.             mypromptbox[s],
  198.             layout = awful.widget.layout.horizontal.leftright
  199.         },
  200.         closeicon,
  201.     mylayoutbox[s],
  202.         --mytextclock,
  203.         --s == 1 and mysystray or nil,
  204.         mytasklist[s],
  205.         layout = awful.widget.layout.horizontal.rightleft
  206.     }
  207. -- Create bottom wibox
  208.  mywiboxbottom[s] = awful.wibox({ ontop,visible, position = "top", height = "21"  , align = "center" , screen = s})
  209.  
  210.  
  211. --mywiboxbottom[1]:geometry(900x21)
  212. mywiboxbottom[1]:buttons(awful.util.table.join(
  213. awful.button({ }, 5, awful.tag.viewnext),
  214. awful.button({ }, 4, awful.tag.viewprev)))
  215. -- Add widgets to the bottomwibox
  216.   mywiboxbottom[s].widgets = { {
  217. mylauncher,
  218. spacer,
  219. cpuwidget,
  220. spacer,
  221. thermalwidget,
  222. spacer,
  223. separator,
  224. spacer,
  225. memwidget,
  226.   spacer,
  227. separator,
  228. spacer,
  229. wifiwidget,
  230. spacer,
  231.  separator,
  232.  spacer,
  233.    fswidget,
  234. spacer,
  235.   fsmwidget,
  236.   spacer,
  237.   separator,
  238.   spacer,
  239.   batwidget,
  240.     spacer,
  241.     separator,
  242.     spacer,
  243.     deadbeefwidget,
  244.   layout = awful.widget.layout.horizontal.leftright,},
  245. mytextclock,
  246. spacer,
  247. separator,
  248. s == 1 and mysystray or nil,
  249. layout = awful.widget.layout.horizontal.rightleft
  250.  
  251. }
  252.  
  253.  
  254.  
  255. end
  256. -- }}}
  257.  
  258. -- {{{ Mouse bindings
  259. --root.buttons(awful.util.table.join(
  260.     --awful.button({ }, 3, function () mymainmenu:toggle() end)
  261.     --awful.button({ }, 5, awful.tag.viewnext),
  262.     --awful.button({ }, 4, awful.tag.viewprev)
  263. --))
  264. -- }}}
  265.  
  266. globalkeys = awful.util.table.join(
  267.     awful.key({ modkey }, "b",
  268.        function ()
  269.            if mywibox[mouse.screen].screen == nil then
  270.                mywibox[mouse.screen].screen = mouse.screen
  271.            else
  272.                mywibox[mouse.screen].screen = nil
  273.            end
  274.        end),
  275.     awful.key({ modkey1,           }, "Left",   awful.tag.viewprev       ),
  276.     awful.key({ modkey1,           }, "Right",  awful.tag.viewnext       ),
  277.     awful.key({ modkey,           }, "Escape", awful.tag.history.restore),
  278.  
  279.     awful.key({ modkey,           }, "Down",
  280.         function ()
  281.             awful.client.focus.byidx( 1)
  282.             if client.focus then client.focus:raise() end
  283.         end),
  284.     awful.key({ modkey,           }, "Up",
  285.         function ()
  286.             awful.client.focus.byidx(-1)
  287.             if client.focus then client.focus:raise() end
  288.         end),
  289.     awful.key({ modkey,           }, "w", function () mymainmenu:show(true)        end),
  290.  
  291.     -- Layout manipulation
  292.     awful.key({ modkey1   }, "Down", function () awful.client.swap.byidx(  1)    end),
  293.     awful.key({ modkey1  }, "Up", function () awful.client.swap.byidx( -1)    end),
  294.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  295.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  296.     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
  297.     awful.key({ modkey1,           }, "Tab",
  298.         function ()
  299.             awful.client.focus.history.previous()
  300.             if client.focus then
  301.                 client.focus:raise()
  302.             end
  303.         end),
  304.  
  305.     -- Standard program
  306.     awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
  307.     awful.key({ modkey, "Control" }, "r", awesome.restart),
  308.     awful.key({ modkey, "Shift"   }, "q", awesome.quit),
  309.  
  310.     awful.key({ modkey,           }, "Right",     function () awful.tag.incmwfact( 0.05)    end),
  311.     awful.key({ modkey,           }, "Left",     function () awful.tag.incmwfact(-0.05)    end),
  312.     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
  313.     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
  314.     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
  315.     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
  316.     awful.key({ modkey1,           }, "space", function () awful.layout.inc(layouts,  1) end),
  317.     awful.key({ modkey1, "Control"   }, "space", function () awful.layout.inc(layouts, -1) end),
  318.  
  319.     -- Program
  320.     --key({ modkey1}, "F12",    function () awful.util.spawn ("chromium") end),
  321.    -- key({ "Control" }, "space",    function () awful.util.spawn ("thunar") end),
  322.      awful.key({ modkey1}, "F12",             function () awful.util.spawn("chromium")  end),
  323.      awful.key({ modkey1}, "F7",             function () awful.util.spawn("qutim")  end),
  324.      awful.key({ modkey1}, "F5",             function () awful.util.spawn("deadbeef")  end),
  325.      --awful.key({ modkey1}, "x",             function () awful.util.spawn("quodlibet --play-pause")  end),
  326.      --awful.key({ modkey1}, "c",             function () awful.util.spawn("quodlibet --next")  end),
  327.      --awful.key({ modkey1}, "z",             function () awful.util.spawn("quodlibet --previous")  end),
  328.      --awful.key({ modkey1}, "v",             function () awful.util.spawn("quodlibet --toggle-window")  end),
  329.      awful.key({ modkey1}, "F1",             function () awful.util.spawn("sudo thunar /")  end),
  330.      awful.key({ "Control"}, "space",             function () awful.util.spawn("thunar")  end),
  331.  
  332.     -- Prompt
  333.     awful.key({modkey1},            "F2",     function () mypromptbox[mouse.screen]:run() end)
  334.  
  335. )
  336.  
  337. clientkeys = awful.util.table.join(
  338.     awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
  339.     awful.key({ modkey   }, "space",      function (c) c:kill()                         end),
  340.     awful.key({ modkey,  }, "t",  awful.client.floating.toggle                     ),
  341.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  342.     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
  343.     awful.key({ modkey, "Shift"   }, "r",      function (c) c:redraw()                       end),
  344.     awful.key({ modkey,           }, "n",      function (c) c.minimized = not c.minimized    end),
  345.     awful.key({ modkey,           }, "m",
  346.         function (c)
  347.             c.maximized_horizontal = not c.maximized_horizontal
  348.             c.maximized_vertical   = not c.maximized_vertical
  349.         end)
  350. )
  351.  
  352. -- Compute the maximum number of digit we need, limited to 9
  353. keynumber = 0
  354. for s = 1, screen.count() do
  355.   keynumber = math.min(9, math.max(#tags[s], keynumber));
  356. end
  357.  
  358. -- Bind all key numbers to tags.
  359. -- Be careful: we use keycodes to make it works on any keyboard layout.
  360. -- This should map on the top row of your keyboard, usually 1 to 9.
  361. for i = 1, keynumber do
  362.   globalkeys = awful.util.table.join(globalkeys,
  363.     awful.key({ modkey }, "#" .. i + 9,
  364.           function ()
  365.             local screen = mouse.screen
  366.           if tags[screen][i] then
  367.               awful.tag.viewonly(tags[screen][i])
  368.       end
  369. end),
  370.  awful.key({ modkey, "Control" }, "#" .. i + 9,
  371.          function ()
  372.                     local screen = mouse.screen
  373.                 if tags[screen][i] then
  374.                    awful.tag.viewtoggle(tags[screen][i])
  375.              end
  376.          end),
  377.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  378.                 function ()
  379.                 if client.focus and tags[client.focus.screen][i] then
  380.                  awful.client.movetotag(tags[client.focus.screen][i])
  381.              end
  382.         end),
  383.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  384.                 function ()
  385.                  if client.focus and tags[client.focus.screen][i] then
  386.                     awful.client.toggletag(tags[client.focus.screen][i])
  387.             end
  388.         end)
  389. )
  390. end
  391.  
  392. clientbuttons = awful.util.table.join(
  393.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  394.     awful.button({ modkey }, 1, awful.mouse.client.move),
  395.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  396.  
  397. -- Set keys
  398. root.keys(globalkeys)
  399. -- }}}
  400.  
  401. -- {{{ Rules
  402. awful.rules.rules = {
  403.     -- All clients will match this rule.
  404.     { rule = { },
  405.       properties = { border_width = beautiful.border_width,
  406.                      border_color = beautiful.border_normal,
  407.                      focus = true,
  408.                      keys = clientkeys,
  409.                      buttons = clientbuttons } },
  410.     { rule = { class = "MPlayer" },
  411.       properties = { floating = true } },
  412.   { rule = { class = "Gtkdialog" },
  413.       properties = { floating = true } , callback = awful.placement.centered },
  414. { rule = { class = "Xfce4-taskmanager"},
  415.       properties = { floating = true }, callback = awful.placement.centered },
  416.     { rule = { class = "Tilda" },
  417.       properties = { floating = true } },
  418. { rule = { name = "Event Tester" },
  419.       properties = { floating = true } , callback = awful.placement.centered },
  420.     { rule = { class = "Gmrun" },
  421.       properties = { floating = true }, callback = awful.placement.centered},
  422. { rule = { class = "Kcalc" },
  423.       properties = { floating = true }, callback = awful.placement.centered },
  424. { rule = { class = "Transmission" },
  425.       properties = { floating = true }, callback = awful.placement.centered },
  426. { rule = { class = "Pcmanfm" },
  427.       properties = { floating = true }, callback = awful.placement.centered },
  428. { rule = { name = "Копирование*" },
  429.       properties = { floating = true } },
  430. { rule = { name = "Перемещение*" },
  431.       properties = { floating = true } },
  432. { rule = { class = "Xfce4-terminal" },
  433.       properties = { floating = true , tag = tags[1][1]} },
  434. { rule = { class = "Knotes" },
  435.       properties = { floating = true , tag = tags[1][1]} },
  436. { rule = { class = "Qutim" },
  437.      properties = { tag = tags[1][4] } },
  438.  
  439.     -- Set Firefox to always map on tags number 2 of screen 1.
  440.     { rule = { class = "Chromium" },
  441.      properties = { tag = tags[1][3] } },
  442. --{ rule = { class = "Vlc" },
  443.   --   properties = { tag = tags[1][1] } },
  444. --{ rule = { name = "VLC (XVideo output)" },
  445.   --   properties = { tag = tags[1][1] } },
  446. { rule = { class = "Synaptic" },
  447.      properties = { tag = tags[1][1] } },
  448. { rule = { class = "Gimp" },
  449.      properties = { tag = tags[1][1] } },
  450. { rule = { class = "OpenOffice.org 3.1" },
  451.      properties = { tag = tags[1][1] } },
  452. { rule = { class = "urxvt" },
  453.      properties = { tag = tags[1][5] } },
  454. { rule = { class = "VirtualBox" },
  455.      properties = { tag = tags[1][1] } },
  456. { rule = { class = "Kmail" },
  457.      properties = { tag = tags[1][1] } },
  458. { rule = { class = "Znotes" },
  459.      properties = { tag = tags[1][1] , floating = true } },
  460. { rule = { class = "Krusader" },
  461.      properties = { tag = tags[1][2] ,} },
  462. }
  463. -- }}}
  464.  
  465. -- {{{ Signals
  466. -- Signal function to execute when a new client appears.
  467. client.add_signal("manage", function (c, startup)
  468.     -- Add a titlebar
  469.      --awful.titlebar.add(c, { modkey = modkey })
  470.  
  471.     -- Enable sloppy focus
  472.     c:add_signal("mouse::enter", function(c)
  473.        -- if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  474.          --   and awful.client.focus.filter(c) then
  475.            -- client.focus = c
  476.         --end
  477.     end)
  478.  
  479.     if not startup then
  480.         -- Set the windows at the slave,
  481.         -- i.e. put it at the end of others instead of setting it master.
  482.         awful.client.setslave(c)
  483.  
  484.         -- Put windows in a smart way, only if they does not set an initial position.
  485.         if not c.size_hints.user_position and not c.size_hints.program_position then
  486.             awful.placement.no_overlap(c)
  487.             awful.placement.no_offscreen(c)
  488.         end
  489.     end
  490. end)
  491.  
  492.  
  493. client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  494. client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  495. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement