Advertisement
Guest User

rc.lua

a guest
Jan 22nd, 2012
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 20.16 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("vicious")
  10. require("shifty")
  11.  
  12. -- {{{ Variable definitions
  13. -- Themes define colours, icons, and wallpapers
  14. beautiful.init("/home/alexis/.config/awesome/themes/daes/theme.lua")
  15.  
  16. -- This is used later as the default terminal and editor to run.
  17. terminal = "lxterminal"
  18. editor = os.getenv("EDITOR") or "nano"
  19. editor_cmd = terminal .. " -e " .. editor
  20.  
  21. -- Default modkey.
  22. -- Usually, Mod4 is the key with a logo between Control and Alt.
  23. -- If you do not like this or do not have such a key,
  24. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  25. -- However, you can use another modifier like Mod1, but it may interact with others.
  26. modkey = "Mod4"
  27.  
  28. -- Titlebar
  29. use_titlebar = false
  30.  
  31.  
  32. -- Table of layouts to cover with awful.layout.inc, order matters.
  33. layouts =
  34. {
  35.     awful.layout.suit.floating, --1
  36.     awful.layout.suit.tile, --2
  37.     awful.layout.suit.tile.left, --3
  38.     --awful.layout.suit.tile.bottom, --4
  39.     --awful.layout.suit.tile.top, --5
  40.     awful.layout.suit.fair, --6
  41.     --awful.layout.suit.fair.horizontal, --7
  42.     --awful.layout.suit.spiral, --8
  43.     --awful.layout.suit.spiral.dwindle, --9
  44.     --awful.layout.suit.max, --10
  45.     --awful.layout.suit.max.fullscreen, --11
  46.     --awful.layout.suit.magnifier --12
  47. }
  48. -- }}}
  49.  
  50. -- {{{ Tags
  51. -- Define a tag table which hold all screen tags.
  52. --tags = {}
  53. --tags.settings = {
  54.     --{ name = "terminal",  layout = layouts[2] },
  55.     --{ name = "hdd", layout = layouts[1] },
  56.     --{ name = "internet", layout = layouts[2] },
  57.     --{ name = "media", layout = layouts[1] },
  58.     --{ name = "vbox", layout = layouts[2] },
  59.     --{ name = "socnet", layout = layouts[3] }
  60. ---}
  61. --for s = 1, screen.count() do
  62.     --tags[s] = {}
  63.     --for i, v in ipairs(tags.settings) do
  64.         --tags[s][i] = tag({ name = v.name })
  65.         --tags[s][i].screen = s
  66.         --awful.tag.setproperty(tags[s][i], "layout", v.layout)
  67.     --end
  68.     --tags[s][1].selected = true
  69. --end
  70. -- }}}
  71.  
  72. -- {{{ Tags
  73.  
  74. shifty.config.tags = {
  75.     ["[Internet]"]      = { position = 1, },
  76.     ["[msg]"]       = { position = 2, exclusive = true,  nopopup = true,  },
  77.     ["[gimp]"]      = { position = 3, exclusive = true, nopopup = true, spawn = gimp, },
  78.     ["[dl]"]        = { position = 4, nopopup = true, spawn = "Transmission" },
  79.     ["[multimedia]"]    = { position = 5, nopopup = true, },
  80.     ["[OOo]"]       = { position = 6, exclusive = false, },
  81.     ["[mail]"]      = { position = 7, exclusive = true, nopopup = true, },
  82.     ["[fichiers]"]  = { position = 8, },
  83.     ["[term]"]      = { position = 9, },   
  84. }
  85.  
  86. shifty.taglist = mytaglist
  87. -- Clients rules
  88.  
  89. shifty.config.apps = {
  90.  
  91.          { match = {"Transmission","tucan","Tucan"}, tag = "[dl]"},
  92.          { match = {"^Download$", "Preferences", "VideoDownloadHelper","Extension"}, float = true, intrusive = true},
  93.          { match = {"Firefox"} , tag = "[Internet]", opacity = 1.0} ,
  94.          { match = {"Gimp"}, tag = "[gimp]", float = true , opacity = 1.0},
  95.          { match = {"MPlayer","vlc","VLC"}, float = true,  tag = "[multimedia]", opacity = 1.0},
  96.          { match = {"Thunderbird"}, tag = "[mail]"},
  97.          { match = {"Pidgin"}, tag = "[msg]"},
  98.          { match = {"lxappearence"}, float = true, opacity = 1.0},
  99.      { match = {"mpd"}, tag = "[multimedia]"},
  100.          { match = {"LibreOffice"}, tag = "[OOo]"},
  101.      { match = {"PcmanFM","pcmanfm" }, tag = "[fichiers]"},
  102.      { match = {"Lxterminal"}, opacity = 1.0},
  103.      { match = { "gimp%-image%-window" }, geometry = {250,15,1125,900}, border_width = 0 },
  104.      { match = { "^gimp%-toolbox$" }, geometry = {0,15,250,900}, slave = true, border_width = 0 },
  105.      { match = { "^gimp%-dock$" }, geometry = {1400,15,1600,900}, slave = true, border_width = 0 },
  106.      { match = { "lxterminal" }, geometry = {0,15,1600,900}, border_width = 0, tag = "[term]" },
  107.          --{ match = { "" },
  108.  
  109.                    --buttons = awful.util.table.join(
  110.                        --awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  111.                     --awful.button({ modkey }, 1, awful.mouse.client.move),
  112.                      --awful.button({ modkey }, 3, awful.mouse.client.resize),
  113.               --awful.button({ modkey }, 8, awful.mouse.client.resize))
  114.   --}
  115. }
  116.  
  117. -- Options par défaut.
  118. shifty.config.defaults = {
  119.   layout = awful.layout.suit.tile,
  120.   ncol = 1,
  121.   mwfact = 0.60,
  122.   floatBars=true,  
  123. }
  124.  
  125. -- {{{ Menu
  126. -- Create a laucher widget and a main menu
  127. myawesomemenu = {
  128.    { "Manuel", terminal .. " -e man awesome" },
  129.    { "Edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
  130.    { "Edit theme", editor_cmd .. " " .. awful.util.getdir("config") .. "/themes/daes/theme.lua" },
  131.    { "Restart", awesome.restart },
  132.    { "Quit", awesome.quit },
  133.    { "Oblogout", "oblogout" }
  134. }
  135. internetmenu = {  
  136.    { "Firefox", "firefox" },
  137.    { "Pidgin", "pidgin" },
  138.    { "Thunderbird", "thunderbird" },
  139.    { "Transmission", "transmission-gtk" }
  140. }
  141. mediamenu = {
  142.    { "Aegisub", "aegisub-2.1" },
  143.    { "AnimeNFO", "lxterminal -e mplayer -playlist /home/alexis/Multimédia/Radios/AnimeNFO.pls" },
  144.    { "Avidemux", "avidemux2_gtk" },
  145.    { "Exfalso", "exfalso" },
  146.    { "G-mplayer", "gnome-mplayer" },
  147.    { "Sonata", "sonata" },
  148.    { "XFBurn", "xfburn" }
  149. }
  150. officemenu = {
  151.    { "L-office","libreoffice" },
  152.    { "Epdfview","epdfview" }
  153. }
  154. gamemenu = {
  155.    { "VBAdvance", "gvba" }
  156. }
  157. manamenu = {
  158.    { "PcmanFM", "pcmanfm" }
  159. }
  160. editormenu = {
  161.    { "Nano", "urxvt -e nano" },
  162.    { "Medit", "medit" }
  163. }
  164. graphimenu = {
  165.    { "Gimp", "gimp" },
  166.    { "MyPaint", "mypaint" }
  167. }
  168. sistemenu = {
  169.    { "Htop", "urxvt -e htop"},
  170.    { "Bleachbit", "gksudo bleachbit" },
  171.    { "Fond d'écran", "nitrogen /home/alexis/Images/Wallpapers" },
  172.    { "Ecran de veille", "xscreensaver-demo" },
  173.    { "Thème GTK", "lxappearance" },
  174.    { "Lxtask", "lxtask" }
  175. }
  176.  
  177. mymainmenu = awful.menu({ items = { { "Awesome", myawesomemenu },
  178.                                     { "Internet", internetmenu },
  179.                     { "Media", mediamenu },
  180.                     { "Manager", manamenu },
  181.                     { "Games", gamemenu },
  182.                     { "Office", officemenu },
  183.                     { "Graphics", graphimenu },
  184.                     { "Editor", editormenu },
  185.                                     { "System", sistemenu },
  186.                     { "Terminal", terminal },
  187.                     --{ "Oblogout", "oblogout" }
  188.                                   }
  189.                         })
  190.  
  191. mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
  192.                                      menu = mymainmenu })
  193. -- }}}
  194.  
  195. -- {{{ Wibox
  196. -- Create a textclock widget
  197. mytextclock = awful.widget.textclock({ align = "right" })
  198.  
  199. -- Create a systray
  200. mysystray = widget({ type = "systray" })
  201.  
  202. -- Separator (daes)
  203. separator = widget({ type = "textbox" })
  204. separator.text = '<span color="#a2a2a2"> </span>'
  205.  
  206. -- Clock widget (daes)
  207. datewidget = widget({ type = "textbox" })
  208. vicious.register(datewidget, vicious.widgets.date, '<span color="#a86500">[</span> %d %B %R <span color="#a86500">]</span>', 60)
  209.  
  210. -- Vol widget (daes)
  211. volwidget = widget({ type = "textbox" })
  212. vicious.register(volwidget, vicious.widgets.volume, '<span color="#a2a2a2">$1%</span>', 1, "Master")
  213.  
  214. -- Vol icon (daes)
  215. volicon = widget({ type = "imagebox", align = "right" })
  216. volicon.image = image("/home/alexis/.config/awesome/themes/daes/icons/vol.png")
  217.  
  218. -- CPU widget (daes)
  219. cpuwidget = widget({ type = "textbox" })
  220. vicious.register(cpuwidget, vicious.widgets.cpu, 'Cpu1: <span color="#a2a2a2">$1%</span>')
  221.  
  222. -- Cpu icon (daes)
  223. cpuicon = widget({ type = "imagebox", align = "right" })
  224. cpuicon.image = image("/home/alexis/.config/awesome/themes/daes/icons/cpu.png")
  225.  
  226. -- Memory usage (daes)
  227. memwidget = widget({ type = "textbox" })
  228. vicious.register(memwidget, vicious.widgets.mem, 'Ram: <span color="#a2a2a2">$1%</span>', 13)
  229.  
  230.  
  231. -- Mem icon (daes)
  232. memicon = widget({ type = "imagebox", align = "right" })
  233. memicon.image = image("/home/alexis/.config/awesome/themes/daes/icons/mem.png")
  234.  
  235. -- Create a wibox for each screen and add it
  236. mywibox = {}
  237. mypromptbox = {}
  238. mylayoutbox = {}
  239. mytaglist = {}
  240. mytaglist.buttons = awful.util.table.join(
  241.                     awful.button({ }, 1, awful.tag.viewonly),
  242.                     awful.button({ modkey }, 1, awful.client.movetotag),
  243.                     awful.button({ }, 3, awful.tag.viewtoggle),
  244.                     awful.button({ modkey }, 3, awful.client.toggletag),
  245.                     awful.button({ }, 4, awful.tag.viewnext),
  246.                     awful.button({ }, 5, awful.tag.viewprev)
  247.                     )
  248. mytasklist = {}
  249. mytasklist.buttons = awful.util.table.join(
  250.                      awful.button({ }, 1, function (c)
  251.                                               if not c:isvisible() then
  252.                                                   awful.tag.viewonly(c:tags()[1])
  253.                                               end
  254.                                               client.focus = c
  255.                                               c:raise()
  256.                                           end),
  257.                      awful.button({ }, 3, function ()
  258.                                               if instance then
  259.                                                   instance:hide()
  260.                                                   instance = nil
  261.                                               else
  262.                                                   instance = awful.menu.clients({ width=250 })
  263.                                               end
  264.                                           end),
  265.                      awful.button({ }, 4, function ()
  266.                                               awful.client.focus.byidx(1)
  267.                                               if client.focus then client.focus:raise() end
  268.                                           end),
  269.                      awful.button({ }, 5, function ()
  270.                                               awful.client.focus.byidx(-1)
  271.                                               if client.focus then client.focus:raise() end
  272.                                           end))
  273.  
  274. for s = 1, screen.count() do
  275.     -- Create a promptbox for each screen
  276.     mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
  277.     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  278.     -- We need one layoutbox per screen.
  279.     mylayoutbox[s] = awful.widget.layoutbox(s)
  280.     mylayoutbox[s]:buttons(awful.util.table.join(
  281.                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  282.                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  283.                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  284.                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  285.     -- Create a taglist widget
  286.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
  287.  
  288.     -- Create a tasklist widget
  289.     mytasklist[s] = awful.widget.tasklist(function(c)
  290.                                               return awful.widget.tasklist.label.currenttags(c, s)
  291.                                           end, mytasklist.buttons)
  292.  
  293.     -- Create the wibox
  294.     mywibox[s] = awful.wibox({
  295.         position = "top",
  296.         -- screen = s
  297.         height = 16,
  298.         border_color = beautiful.border_panel,
  299.         border_width = beautiful.border_width_panel
  300.     })
  301.     -- Add widgets to the wibox - order matters
  302.     mywibox[s].widgets = {
  303.         {
  304.             -- mylauncher,
  305.             mytaglist[s],
  306.             mypromptbox[s],
  307.             layout = awful.widget.layout.horizontal.leftright
  308.         },
  309.         -- mylayoutbox[s],
  310.         separator,
  311.         datewidget,
  312.         separator,
  313.         --separator,
  314.         --memwidget,
  315.         --separator,
  316.         --separator,
  317.         --cpuwidget,
  318.         --separator,
  319.         --separator,
  320.         volwidget,
  321.         separator,
  322.         volicon,
  323.         separator,
  324.         -- mytextclock,
  325.         s == 1 and mysystray or nil,
  326.         mytasklist[s],
  327.         layout = awful.widget.layout.horizontal.rightleft
  328.     }
  329. end
  330. -- }}}
  331.  
  332. -- {{{ Mouse bindings
  333. root.buttons(awful.util.table.join(
  334.     awful.button({ }, 3, function () mymainmenu:toggle() end),
  335.     awful.button({ }, 4, awful.tag.viewnext),
  336.     awful.button({ }, 5, awful.tag.viewprev)
  337. ))
  338. -- }}}
  339.  
  340. -- {{{ Key bindings
  341. globalkeys = awful.util.table.join(
  342.     awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
  343.     awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
  344.     awful.key({ modkey,           }, "Escape", awful.tag.history.restore),
  345.  
  346.     awful.key({ modkey,           }, "Tab",
  347.         function ()
  348.             awful.client.focus.byidx( 1)
  349.             if client.focus then client.focus:raise() end
  350.         end),
  351.     awful.key({ modkey,           }, "k",
  352.         function ()
  353.             awful.client.focus.byidx(-1)
  354.             if client.focus then client.focus:raise() end
  355.         end),
  356.     awful.key({ modkey,           }, "w", function () mymainmenu:show({keygrabber=true}) end),
  357.  
  358.     -- Layout manipulation
  359.     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
  360.     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
  361.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  362.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  363.     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
  364.     -- awful.key({ modkey,           }, "Tab",
  365.         -- function ()
  366.            -- awful.client.focus.history.previous()
  367.            -- if client.focus then
  368.                -- client.focus:raise()
  369.           -- end
  370.         -- end),
  371.  
  372.     -- Standard program
  373.     awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
  374.     awful.key({ modkey, "Control" }, "r", awesome.restart),
  375.     awful.key({ modkey, "Shift"   }, "q", awesome.quit),
  376.  
  377.     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
  378.     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
  379.     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
  380.     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
  381.     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
  382.     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
  383.     awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
  384.     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
  385.  
  386.     -- Daes keys
  387.     awful.key({ modkey,           }, "-",     function () awful.util.spawn("urxvt -e htop" )    end),
  388.     awful.key({ modkey,           }, "0",     function () awful.util.spawn("urxvt -e ncmpcpp" )    end),
  389.     awful.key({ modkey,           }, "BackSpace",     function () awful.util.spawn("pcmanfm" )    end),
  390.     awful.key({                   }, "Print", function () awful.util.spawn("scrot '%Y-%m-%d-%H:%M_$wx$h.png' -e 'mv $f ~/Images/Screens/") end),
  391.    
  392.     -- Daes multimedia keys
  393.     awful.key({            }, "XF86AudioRaiseVolume",     function () awful.util.spawn("amixer -q sset Master 2dB+" )   end),
  394.     awful.key({            }, "XF86AudioLowerVolume",     function () awful.util.spawn("amixer -q sset Master 2dB-" )   end),
  395.     awful.key({            }, "XF86AudioPlay", function () awful.util.spawn("sonata") end),
  396.     awful.key({            }, "XF86AudioMute", function () awful.util.spawn("amixer set Master toggle") end),
  397.  
  398.     -- Daes music keys
  399.     awful.key({ modkey,           }, "p",     function () awful.util.spawn("mpc toggle" )  end),
  400.     awful.key({ modkey,           }, "s",     function () awful.util.spawn("mpc next" )    end),
  401.     awful.key({ modkey,           }, "a",     function () awful.util.spawn("mpc prev" )    end),
  402.     -- Perso
  403.     awful.key({modkey}, "F2", function () awful.util.spawn("gmrun") end),
  404.     awful.key({},"XF86PowerOff", function () awful.util.spawn("sudo pm-suspend") end),
  405.     awful.key({ modkey}, "a", function () awful.util.spawn("xscreensaver-command -lock") end)
  406. )      
  407. clientkeys = awful.util.table.join(
  408.     awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
  409.     awful.key({ modkey, "Shift"   }, "c",      function (c) c:kill()                         end),
  410.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
  411.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  412.     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
  413.     awful.key({ modkey, "Shift"   }, "r",      function (c) c:redraw()                       end),
  414.     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
  415.     awful.key({ modkey,           }, "n",      function (c) c.minimized = not c.minimized    end),
  416.     awful.key({ modkey,           }, "m",
  417.         function (c)
  418.             c.maximized_horizontal = not c.maximized_horizontal
  419.             c.maximized_vertical   = not c.maximized_vertical
  420.         end)   
  421. )
  422. clientbuttons = awful.util.table.join(
  423.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  424.     awful.button({ modkey }, 1, awful.mouse.client.move),
  425.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  426.  
  427. -- Set keys
  428. root.keys(globalkeys)
  429. -- }}}
  430.  
  431. -- {{{ Rules
  432. awful.rules.rules = {
  433.     -- All clients will match this rule.
  434.     { rule = { },
  435.       properties = { border_width = beautiful.border_width,
  436.                      border_color = beautiful.border_normal,
  437.                      focus = true,
  438.                      keys = clientkeys,
  439.                      buttons = clientbuttons,
  440.              size_hints_honor = false } },
  441.     { rule = { class = "MPlayer" },
  442.       properties = { floating = true } },
  443.     { rule = { class = "gimp" },
  444.       properties = { floating = true } },
  445.     { rule = { class = "Pcmanfm" },
  446.       properties = { floating = true } },
  447.     { rule = { class = "Gmrun" },
  448.       properties = { floating = true } },
  449.     -- Set Firefox to always map on tags number 2 of screen 1.
  450.     -- { rule = { class = "Firefox" },
  451.     --   properties = { tag = tags[1][2] } },
  452. }
  453. -- }}}
  454.  
  455. -- {{{ Signals
  456. -- Signal function to execute when a new client appears.
  457. client.add_signal("manage", function (c, startup)
  458.     -- Add a titlebar
  459.     -- awful.titlebar.add(c, { modkey = modkey })
  460.  
  461.     -- Enable sloppy focus
  462.     c:add_signal("mouse::enter", function(c)
  463.         if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  464.             and awful.client.focus.filter(c) then
  465.             client.focus = c
  466.         end
  467.     end)
  468.  
  469.     if not startup then
  470.         -- Set the windows at the slave,
  471.         -- i.e. put it at the end of others instead of setting it master.
  472.         -- awful.client.setslave(c)
  473.  
  474.         -- Put windows in a smart way, only if they does not set an initial position.
  475.         if not c.size_hints.user_position and not c.size_hints.program_position then
  476.             awful.placement.no_overlap(c)
  477.             awful.placement.no_offscreen(c)
  478.         end
  479.     end
  480. end)
  481.  
  482. -- Daes focus
  483. client.add_signal("focus", function(c) c.border_color = beautiful.border_focus
  484.                                        c.opacity = 0.9
  485.                    end)
  486. client.add_signal("unfocus", function(c) c.border_color = beautiful.border_wnormal
  487.                                      c.opacity = 0.5
  488.                 end)
  489. --Démarrage                   
  490.    os.execute("pidgin &")              
  491.    os.execute("parcellite &")
  492.   -- launch the Cairo Composite Manager
  493.    awful.util.spawn_with_shell("cairo-compmgr &")
  494.    
  495. -- Daes autorun
  496. --function run_once(prg)
  497. --  if not prg then
  498. --      do return nil end
  499. --  end
  500. --  awful.util.spawn_with_shell("pgrep -u $USER -x " .. prg .. " || (" .. prg .. ")")
  501. --end
  502.  
  503. --run_once("thunar --daemon")
  504. --run_once("xcompmgr")
  505. -- run_once("conky")
  506.  
  507. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement