Advertisement
Guest User

rc.lua

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