Advertisement
Guest User

rc.lua

a guest
Sep 12th, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.66 KB | None | 0 0
  1. --  L O A D L I B R A R Y   ----------------------------------------
  2. require("awful")
  3. require("awful.autofocus")
  4. require("awful.rules")
  5. require("beautiful")
  6. require("naughty")
  7.  
  8. require("vicious")
  9.  
  10.  
  11. --  E R R O R S ----------------------------------------
  12. if awesome.startup_errors then
  13.     naughty.notify({ preset = naughty.config.presets.critical,
  14.                     title = "Oops, there were errors during startup!",
  15.                     text = awesome.startup_errors })
  16. end
  17.  
  18. do
  19.     local in_error = false
  20.     awesome.add_signal("debug::error", function (err)
  21.         -- Make sure we don't go into an endless error loop
  22.         if in_error then return end
  23.         in_error = true
  24.  
  25.         naughty.notify({ preset = naughty.config.presets.critical,
  26.                         title = "Oops, an error happened!",
  27.                         text = err })
  28.         in_error = false
  29.     end)
  30. end
  31.  
  32. --  T H E M E   ----------------------------------------
  33. beautiful.init("/home/funeralismatic/.config/awesome/themes/funeralismatic/theme.lua")
  34.  
  35. --  V A R I A B L E S   ----------------------------------------
  36. terminal = "terminator"
  37. editor = os.getenv("EDITOR") or "nano"
  38. editor_cmd = terminal .. " -e " .. editor
  39.  
  40. --  D E F A U L T   M O D K E Y ----------------------------------------
  41. modkey = "Mod4"
  42.  
  43. --  L A Y O U T T A B L E   ----------------------------------------
  44. layouts = {
  45.     awful.layout.suit.floating,
  46.     awful.layout.suit.tile,
  47.     awful.layout.suit.tile.left,
  48.     awful.layout.suit.tile.bottom,
  49.     awful.layout.suit.tile.top,
  50.     awful.layout.suit.max
  51. --    awful.layout.suit.fair,
  52. --    awful.layout.suit.fair.horizontal,
  53. --    awful.layout.suit.spiral,
  54. --    awful.layout.suit.spiral.dwindle,
  55. --    awful.layout.suit.max.fullscreen,
  56. --    awful.layout.suit.magnifier
  57. }
  58.  
  59.  
  60. --  T A G S ----------------------------------------
  61. tags = {
  62.     names  = { "main", "internet", "terminal", "media", "design", "other"},
  63.     layout = { layouts[3], layouts[2], layouts[6], layouts[1], layouts[3], layouts[1], layouts[1]}
  64. }
  65.  
  66.  for s = 1, screen.count() do
  67.      tags[s] = awful.tag(tags.names, s, tags.layout)
  68.  end
  69.  
  70.  
  71. --  M E N U ----------------------------------------
  72. myawesomemenu = {
  73.     { "manual", terminal .. " -e man awesome" },
  74.     { "edit config", editor_cmd .. " " .. awesome.conffile },
  75.     { "restart", awesome.restart },
  76.     { "quit", awesome.quit }
  77. }
  78.  
  79. myinternetmenu = {
  80.     { "Chromium", "chromium" },
  81.     { "Firefox", "firefox" },
  82.     { "Thunderbird", "thunderbird" },
  83.     { "Deluge", "deluge" },
  84.     { "lICQ", "licq" },
  85.     { "Skype", "skype" },
  86.     { "Vacuum IM", "vacuum" }
  87. }
  88.  
  89. mydesignmenu = {
  90.     { "Inkscape", "inkscape" },
  91.     { "Font Editor", "fontforge" },
  92.     { "MyPaint", "mypaint" },
  93.     { "gimp", "gimp" }
  94. }
  95.  
  96. mymediamenu = {
  97.     { "Deadbeef", "deadbeef" },
  98.     { "Volume", "aumix" },
  99.     { "XfBurn", "xfburn" }
  100. }
  101.  
  102. mysettingsmenu = {
  103.     { "Awesome", myawesomemenu, beautiful.awesome_icon },
  104.     { "hTop", terminal .. " -e htop" },
  105.     { "GTK+ Theme", "lxappearance" },
  106.     { "Task Manager", "lxtask" },
  107.     { "Terminal", terminal },
  108.     { "ROOT Terminal", "ktsuss --user root terminator" },
  109.     { "Connections", "ktsuss --user root nm-connection-editor" },
  110.     { "Qt Configure", "qtconfig" },
  111.     { "Gparted", "ktsuss --user root gparted-pkexec" }
  112. }
  113.  
  114. myofficemenu = {
  115.     { "Reader", "evince" },
  116.     { "Charmap", "mucharmap" },
  117.     { "Clipboard Manager", "parcellite" },
  118.     { "Calculator", "mate-calc" },
  119.     { "Osmo", "osmo" }
  120. }
  121.  
  122. mymainmenu = awful.menu({ items = {
  123.         { "Internet", myinternetmenu, beautiful.awesome_icon },
  124.         { "Design", mydesignmenu, beautiful.awesome_icon },
  125.         { "Multimedia", mymediamenu, beautiful.awesome_icon },
  126.         { "Settings", mysettingsmenu, beautiful.awesome_icon },
  127.         { "Office", myofficemenu, beautiful.awesome_icon },
  128.         { "Editra", "editra" },
  129.         { "Archive Manager", "engrampa" },
  130.         { "File Manager", "spacefm" },
  131.         { "RecordMyDesktop", "gtk-recordmydesktop" },
  132.         { "NEStopia", "nestopia" }
  133.     }
  134. })
  135.  
  136. mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon), menu = mymainmenu })
  137.  
  138.  
  139. -- {{{ Wibox
  140. -- Create a textclock widget
  141. mytextclock = awful.widget.textclock({ align = "right" })
  142.  
  143. -- Create a systray
  144. mysystray = widget({ type = "systray" })
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160. -- Reusable separators
  161. spacer  = widget({ type = "textbox"  })
  162. separator = widget({ type = "imagebox" })
  163. spacer.text = " | "
  164. separator.image = image(beautiful.widget_sep)
  165.  
  166.     -- Keyboard map indicator and changer
  167.     kbdcfg = {}
  168.     kbdcfg.cmd = "setxkbmap"
  169.     kbdcfg.layout = { { "us", "" }, { "ru", "" } }
  170.     kbdcfg.current = 1  -- us is our default layout
  171.     kbdcfg.widget = widget({ type = "textbox", align = "right"})
  172.     kbdcfg.widget.text = " " .. kbdcfg.layout[kbdcfg.current][1] .. " "
  173.     kbdcfg.switch = function ()
  174.      kbdcfg.current = kbdcfg.current % #(kbdcfg.layout) + 1
  175.      local t = kbdcfg.layout[kbdcfg.current]
  176.      kbdcfg.widget.text = " " .. t[1] .. " "
  177.      os.execute( kbdcfg.cmd .. " " .. t[1] .. " " .. t[2] )
  178.     end
  179.    
  180.     -- Mouse bindings
  181.     kbdcfg.widget:buttons(awful.util.table.join(
  182.         awful.button({ }, 1, function () kbdcfg.switch() end)
  183.     ))
  184.  
  185.  
  186. -- DDB Text
  187. --ddbtxt = widget({ type = "textbox" })
  188. --ddbtxt.text = "DDB:"
  189.  
  190. -- Deadbeef
  191. --ddbicon = widget({ type = "imagebox" })
  192. --ddbicon.image = image(beautiful.widget_music)
  193. --ddbtext = widget({ type = "textbox" })
  194. --ddbwidget = widget({ type = "textbox" })
  195. --function ddbnow()
  196. --  local ddb = io.popen("deadbeef --nowplaying \"%a - %t\"", "r")
  197. --  local current = ddb:read()
  198. --  return current
  199. --end
  200. --ddbtimer = timer({ timeout = 5 })
  201. --ddbtimer:add_signal("timeout", function() ddbwidget.text = ddbnow() end)
  202. --ddbtimer:start()
  203.  
  204. -- DeadBeef album art
  205. --local coverart_nf
  206. --function coverart_show()
  207. --  local artcache = '/home/funeralismatic/.cache/deadbeef/covers'
  208. --  local artist_var = io.popen("deadbeef --nowplaying %a", "r")   
  209. --  local artist = artist_var:read()
  210. --  local title_var = io.popen("deadbeef --nowplaying %t", "r")
  211. --  local title = title_var:read()
  212. --  local album_var = io.popen("deadbeef --nowplaying %b", "r")
  213. --  local album = album_var:read() 
  214. --  local year_var = io.popen("deadbeef --nowplaying %y", "r")
  215. --  local year = year_var:read()
  216. --  local time_var = io.popen("deadbeef --nowplaying \"%e/%l\"", "r")
  217. --  local time = time_var:read()
  218. --  local img = string.format("%s/%s/%s.jpg", artcache, artist, album)
  219. --  local ico = image(img)
  220. --  local txt = string.format('Исполнитель: %s\nНазвание: %s\nАльбом: %s\nГод: %s\nДлина: %s',
  221. --  artist, title, album, year, time)
  222. --  coverart_nf = naughty.notify({icon = ico, icon_size = 80, text = txt,
  223. --  position = "top_right", timeout = 10 })
  224. --end
  225. --function coverart_hide()
  226. --  if coverart_nf ~= nil then
  227. --      naughty.destroy(coverart_nf)
  228. --  end
  229. --end
  230. --ddbwidget:add_signal("mouse::enter", function() coverart_show() end)
  231. --ddbwidget:add_signal("mouse::leave", function() coverart_hide() end)
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  --  Network usage widget
  239.  -- Initialize widget
  240. --netwidget = widget({ type = "textbox" })
  241. --vicious.register(netwidget, vicious.widgets.net, '<span color="#CC9393">${eth0 down_kb}</span> <span color="#7F9F7F">${eth0 up_kb}</span>', 3)
  242. --vicious.register(netwidget, vicious.widgets.net, '<span background="#777E76" font="Terminus 12"> <span font="Terminus 9" color="#EEEEEE" background="#777E76">${eth0 up_kb}</span></span>', 13)
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269. -- Create a wibox for each screen and add it
  270. mywibox = {}
  271. mypromptbox = {}
  272. mylayoutbox = {}
  273. mytaglist = {}
  274. mytaglist.buttons = awful.util.table.join(
  275.                     awful.button({ }, 1, awful.tag.viewonly),
  276.                     awful.button({ modkey }, 1, awful.client.movetotag),
  277.                     awful.button({ }, 3, awful.tag.viewtoggle),
  278.                     awful.button({ modkey }, 3, awful.client.toggletag),
  279.                     awful.button({ }, 4, awful.tag.viewnext),
  280.                     awful.button({ }, 5, awful.tag.viewprev)
  281.                     )
  282. mytasklist = {}
  283. mytasklist.buttons = awful.util.table.join(
  284.                     awful.button({ }, 1, function (c)
  285.                                             if c == client.focus then
  286.                                                 c.minimized = true
  287.                                             else
  288.                                                 if not c:isvisible() then
  289.                                                     awful.tag.viewonly(c:tags()[1])
  290.                                                 end
  291.                                                 -- This will also un-minimize
  292.                                                 -- the client, if needed
  293.                                                 client.focus = c
  294.                                                 c:raise()
  295.                                             end
  296.                                         end),
  297.                     awful.button({ }, 3, function ()
  298.                                             if instance then
  299.                                                 instance:hide()
  300.                                                 instance = nil
  301.                                             else
  302.                                                 instance = awful.menu.clients({ width=250 })
  303.                                             end
  304.                                         end),
  305.                     awful.button({ }, 4, function ()
  306.                                             awful.client.focus.byidx(1)
  307.                                             if client.focus then client.focus:raise() end
  308.                                         end),
  309.                     awful.button({ }, 5, function ()
  310.                                             awful.client.focus.byidx(-1)
  311.                                             if client.focus then client.focus:raise() end
  312.                                         end))
  313.  
  314. for s = 1, screen.count() do
  315.     -- Create a promptbox for each screen
  316.     mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
  317.     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  318.     -- We need one layoutbox per screen.
  319.     mylayoutbox[s] = awful.widget.layoutbox(s)
  320.     mylayoutbox[s]:buttons(awful.util.table.join(
  321.                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  322.                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  323.                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  324.                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  325.     -- Create a taglist widget
  326.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
  327.  
  328.     -- Create a tasklist widget
  329.   --  mytasklist[s] = awful.widget.tasklist(function(c)
  330.   --                                            return awful.widget.tasklist.label.currenttags(c, s)
  331.     --                                   end, mytasklist.buttons)
  332.  
  333.   -- Create a tasklist widget
  334.   mytasklist[s] = awful.widget.tasklist(function(c)
  335.     local task = { awful.widget.tasklist.label.currenttags(c, s) }
  336.     return '', task[2], task[3], task[4]
  337.   end, mytasklist.buttons)
  338.  
  339.     -- Create the wibox
  340.     mywibox[s] = awful.wibox({ position = "top", screen = s, height="24" })
  341.     -- Add widgets to the wibox - order matters
  342.     mywibox[s].widgets = {
  343.         {
  344.             mylauncher,
  345.             mytaglist[s],
  346.             mypromptbox[s],
  347.             layout = awful.widget.layout.horizontal.leftright
  348.         },
  349.         mylayoutbox[s],
  350.         mytextclock,
  351.         kbdcfg.widget,
  352.         separator,
  353. --      ddbwidget,
  354.         netwidget,
  355.         s == 1 and mysystray or nil,
  356.         mytasklist[s],
  357.         layout = awful.widget.layout.horizontal.rightleft
  358.     }
  359. end
  360. -- }}}
  361.  
  362. -- {{{ Mouse bindings
  363. root.buttons(awful.util.table.join(
  364.     awful.button({ }, 3, function () mymainmenu:toggle() end),
  365.     awful.button({ }, 4, awful.tag.viewnext),
  366.     awful.button({ }, 5, awful.tag.viewprev)
  367. ))
  368. -- }}}
  369.  
  370. -- {{{ Key bindings
  371. globalkeys = awful.util.table.join(
  372.     awful.key({ modkey,      }, "Left", awful.tag.viewprev   ),
  373.     awful.key({ modkey,      }, "Right",  awful.tag.viewnext     ),
  374.     awful.key({ modkey,      }, "Escape", awful.tag.history.restore),
  375.  
  376.     -- Alt + Right Shift switches the current keyboard layout
  377.     awful.key({ modkey,      }, "space", function () kbdcfg.switch() end),
  378.  
  379.     awful.key({ modkey,      }, "j",
  380.         function ()
  381.             awful.client.focus.byidx( 1)
  382.             if client.focus then client.focus:raise() end
  383.         end),
  384.     awful.key({ modkey,      }, "k",
  385.         function ()
  386.             awful.client.focus.byidx(-1)
  387.             if client.focus then client.focus:raise() end
  388.         end),
  389.     awful.key({ modkey,      }, "w", function () mymainmenu:show({keygrabber=true}) end),
  390.  
  391.     -- Layout manipulation
  392.     awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx(  1)    end),
  393.     awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1)    end),
  394.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  395.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  396.     awful.key({ modkey,      }, "u", awful.client.urgent.jumpto),
  397.     awful.key({ modkey,      }, "Tab",
  398.         function ()
  399.             awful.client.focus.history.previous()
  400.             if client.focus then
  401.                 client.focus:raise()
  402.             end
  403.         end),
  404.  
  405.     -- Standard program
  406.     awful.key({ modkey,      }, "Return", function () awful.util.spawn(terminal) end),
  407.     awful.key({ modkey, "Control" }, "r", awesome.restart),
  408.     awful.key({ modkey, "Shift" }, "q", awesome.quit),
  409.  
  410.     awful.key({ modkey,      }, "l",    function () awful.tag.incmwfact( 0.05)  end),
  411.     awful.key({ modkey,      }, "h",    function () awful.tag.incmwfact(-0.05)  end),
  412.     awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1)    end),
  413.     awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1)    end),
  414.     awful.key({ modkey, "Control" }, "h",   function () awful.tag.incncol( 1)       end),
  415.     awful.key({ modkey, "Control" }, "l",   function () awful.tag.incncol(-1)       end),
  416.    
  417.      --awful.key({ modkey,       }, "space", function () awful.layout.inc(layouts,  1) end),
  418.      --awful.key({ modkey, "Shift"  }, "space", function () awful.layout.inc(layouts, -1) end),
  419.  
  420.     awful.key({ modkey, "Control" }, "n", awful.client.restore),
  421.  
  422.     -- Prompt
  423.     awful.key({ modkey },           "r",    function () mypromptbox[mouse.screen]:run() end),
  424.  
  425.     awful.key({ modkey }, "x",
  426.             function ()
  427.                 awful.prompt.run({ prompt = "Run Lua code: " },
  428.                 mypromptbox[mouse.screen].widget,
  429.                 awful.util.eval, nil,
  430.                 awful.util.getdir("cache") .. "/history_eval")
  431.             end)
  432. )
  433.  
  434. clientkeys = awful.util.table.join(
  435.     awful.key({ modkey,      }, "f",    function (c) c.fullscreen = not c.fullscreen  end),
  436.     awful.key({ modkey, "Shift" }, "c", function (c) c:kill()                       end),
  437.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                 ),
  438.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  439.     awful.key({ modkey,      }, "o",    awful.client.movetoscreen                       ),
  440.     awful.key({ modkey, "Shift" }, "r", function (c) c:redraw()                  end),
  441.     awful.key({ modkey,      }, "t",    function (c) c.ontop = not c.ontop          end),
  442.     awful.key({ modkey,      }, "n",
  443.         function (c)
  444.             -- The client currently has the input focus, so it cannot be
  445.             -- minimized, since minimized clients can't have the focus.
  446.             c.minimized = true
  447.         end),
  448.     awful.key({ modkey,      }, "m",
  449.         function (c)
  450.             c.maximized_horizontal = not c.maximized_horizontal
  451.             c.maximized_vertical    = not c.maximized_vertical
  452.         end)
  453. )
  454.  
  455. -- Compute the maximum number of digit we need, limited to 9
  456. keynumber = 0
  457. for s = 1, screen.count() do
  458.     keynumber = math.min(9, math.max(#tags[s], keynumber));
  459. end
  460.  
  461. -- Bind all key numbers to tags.
  462. -- Be careful: we use keycodes to make it works on any keyboard layout.
  463. -- This should map on the top row of your keyboard, usually 1 to 9.
  464. for i = 1, keynumber do
  465.     globalkeys = awful.util.table.join(globalkeys,
  466.         awful.key({ modkey }, "#" .. i + 9,
  467.                 function ()
  468.                         local screen = mouse.screen
  469.                         if tags[screen][i] then
  470.                             awful.tag.viewonly(tags[screen][i])
  471.                         end
  472.                 end),
  473.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  474.                 function ()
  475.                     local screen = mouse.screen
  476.                     if tags[screen][i] then
  477.                         awful.tag.viewtoggle(tags[screen][i])
  478.                     end
  479.                 end),
  480.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  481.                 function ()
  482.                     if client.focus and tags[client.focus.screen][i] then
  483.                         awful.client.movetotag(tags[client.focus.screen][i])
  484.                     end
  485.                 end),
  486.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  487.                 function ()
  488.                     if client.focus and tags[client.focus.screen][i] then
  489.                         awful.client.toggletag(tags[client.focus.screen][i])
  490.                     end
  491.                 end))
  492. end
  493.  
  494. clientbuttons = awful.util.table.join(
  495.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  496.     awful.button({ modkey }, 1, awful.mouse.client.move),
  497.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  498.  
  499. -- Set keys
  500. root.keys(globalkeys)
  501. -- }}}
  502.  
  503. -- {{{ Rules
  504. awful.rules.rules = {
  505.     -- All clients will match this rule.
  506.     { rule = { },
  507.     properties = { border_width = beautiful.border_width,
  508.                     border_color = beautiful.border_normal,
  509.                     focus = true,
  510.                     keys = clientkeys,
  511.                     buttons = clientbuttons } },
  512.     { rule = { class = "MPlayer" },
  513.     properties = { floating = true } },
  514.     { rule = { class = "pinentry" },
  515.     properties = { floating = true } },
  516.     -- Set Firefox to always map on tags number 2 of screen 1.
  517.     -- { rule = { class = "Firefox" },
  518.     --  properties = { tag = tags[1][2] } },
  519.     { rule = { class = "Gimp" },
  520.      properties = { tag = tags[1][5] } },
  521.     { rule = { class = "Terminator" },
  522.      properties = { tag = tags[1][3] } },
  523.     { rule = { class = "Chromium" },
  524.      properties = { tag = tags[1][2] } },
  525.     { rule = { class = "Deadbeef" },
  526.      properties = { tag = tags[1][4] } },
  527.     { rule = { class = "Vacuum" },
  528.      properties = { tag = tags[1][2] } },
  529.     { rule = { class = "Firefox" },
  530.      properties = { tag = tags[1][2] } },
  531.     { rule = { class = "Licq" },
  532.      properties = { tag = tags[1][2] } },
  533. }
  534. -- }}}
  535.  
  536. -- {{{ Signals
  537. -- Signal function to execute when a new client appears.
  538. client.add_signal("manage", function (c, startup)
  539.     -- Add a titlebar
  540.     -- awful.titlebar.add(c, { modkey = modkey })
  541.  
  542.  
  543.     -- Enable sloppy focus
  544.     c:add_signal("mouse::click", function(c)
  545.         if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  546.             and awful.client.focus.filter(c) then
  547.             client.focus = c
  548.         end
  549.     end)
  550.  
  551.     if not startup then
  552.         -- Set the windows at the slave,
  553.         -- i.e. put it at the end of others instead of setting it master.
  554.         -- awful.client.setslave(c)
  555.  
  556.         -- Put windows in a smart way, only if they does not set an initial position.
  557.         if not c.size_hints.user_position and not c.size_hints.program_position then
  558.             awful.placement.no_overlap(c)
  559.             awful.placement.no_offscreen(c)
  560.             awful.placement.under_mouse(c)
  561.         end
  562.     end
  563. end)
  564.  
  565. client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  566. client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  567.  
  568. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement