lutherus

rc.lua

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