SHARE
TWEET

rc.lua

helenaryuu Dec 12th, 2012 2,662 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. --Other
  10. awful.util.spawn_with_shell("xcompmgr &")
  11. vicious = require("vicious")
  12. require('calendar2')
  13.  
  14. -- {{{ Error handling
  15. -- Check if awesome encountered an error during startup and fell back to
  16. -- another config (This code will only ever execute for the fallback config)
  17. if awesome.startup_errors then
  18.     naughty.notify({ preset = naughty.config.presets.critical,
  19.                      title = "Oops, ocurrieron errores al inicio!",
  20.                      text = awesome.startup_errors })
  21. end
  22.  
  23. -- Handle runtime errors after startup
  24. do
  25.     local in_error = false
  26.     awesome.add_signal("debug::error", function (err)
  27.         -- Make sure we don't go into an endless error loop
  28.         if in_error then return end
  29.         in_error = true
  30.  
  31.         naughty.notify({ preset = naughty.config.presets.critical,
  32.                          title = "Oops, un error a ocurrido!",
  33.                          text = err })
  34.         in_error = false
  35.     end)
  36. end
  37. -- }}}
  38.  
  39. -- {{{ Variable definitions
  40. -- Themes define colours, icons, and wallpapers
  41. beautiful.init("/usr/share/awesome/themes/dot/theme.lua")
  42.  
  43. -- This is used later as the default terminal and editor to run.
  44. terminal = "sakura"
  45. editor = os.getenv("EDITOR") or "nano"
  46. editor_cmd = terminal .. " -e " .. editor
  47. geany = "geany"
  48.  
  49. -- Default modkey.
  50. -- Usually, Mod4 is the key with a logo between Control and Alt.
  51. -- If you do not like this or do not have such a key,
  52. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  53. -- However, you can use another modifier like Mod1, but it may interact with others.
  54. modkey = "Mod4"
  55.  
  56. -- Table of layouts to cover with awful.layout.inc, order matters.
  57. layouts =
  58. {
  59.     awful.layout.suit.floating,
  60.     awful.layout.suit.tile,
  61.     awful.layout.suit.tile.left,
  62.     awful.layout.suit.tile.bottom,
  63.     awful.layout.suit.tile.top,
  64.     awful.layout.suit.fair,
  65.     awful.layout.suit.fair.horizontal,
  66. --  awful.layout.suit.spiral,
  67. --  awful.layout.suit.spiral.dwindle,
  68.     awful.layout.suit.max,
  69. --  awful.layout.suit.max.fullscreen,
  70. --  awful.layout.suit.magnifier
  71. }
  72. -- }}}
  73.  
  74. -- {{{ Tags
  75. -- Define a tag table which hold all screen tags.
  76. tags = {}
  77. for s = 1, screen.count() do
  78.     -- Each screen has its own tag table.
  79.     tags[s] = awful.tag({ "(*^▽^)", "へ(^∇^)", "(ノ^_^)ノ", "(・_・ )" }, s, layouts[1], layouts[9], layouts[1], layouts[1])
  80. end
  81. -- }}}
  82.  
  83. -- {{{ Menu
  84. -- Create a laucher widget and a main menu
  85. myawesomemenu = {
  86.    { "manual", terminal .. " -e man awesome" },
  87.    { "config", editor_cmd .. " " .. awesome.conffile },
  88.    { "restart", awesome.restart },
  89.    { "quit", awesome.quit }
  90. }
  91.  
  92. menueditors = {
  93.    { "Leafpad", "leafpad" },
  94.    { "Medit", "medit" },
  95.    { "Nano", terminal .. " -e nano" },
  96.    { "Vim", terminal .. " -e vim" },
  97.    { "Vi", terminal .. " -e vi" },
  98.    { "Zim", "zim" },
  99. }
  100.  
  101. menugraphics = {
  102.    { "Djview4", "djview4" },
  103.    { "GIMP", "gimp" },
  104.    { "Inkscape", "inkscape" },
  105.    { "Mcomix", "mcomix" },
  106. }
  107.  
  108. menuconf = {
  109.    { "Aparencia", "lxappearance" },
  110.    { "Awesome", geany .. "-e /home/helena/.config/awesome/rc.lua" },
  111.    { "Wallpaper", "nitrogen" },
  112.    { "Impresoras", "xdg-open http://localhost:631/" },
  113.    { "SCIM", "scim-setup" },
  114. }
  115.  
  116. menusys = {
  117.    { "Flash Conf", "flash-player-properties" },
  118.    { "Privilegios", "gksu-properties" },
  119.    { "dcfonf", "dconf-editor" },
  120.    { "pstree", terminal .. " -e /usr/bin/pstree.x11" },
  121. }
  122.  
  123. menuweb = {
  124.    { "Firefox", "firefox" },
  125.    { "gFTP", "gftp" },
  126.    { "Liferea", "liferea" },
  127.    { "Iron", "iron" },
  128.    { "Midori", "midori" },
  129.    { "Thunderbird", "thunderbird" },  
  130.    { "Wicd", "wicd-client" },
  131. }
  132.  
  133. menumultimedia = {
  134.    { "Alsamixer", terminal .. " -e alsamixer" },
  135.    { "Cmus", terminal .. " -e cmus" },
  136.    { "Audacity", "audacity" },
  137.    { "Qmmp", "qmmp" },
  138.    { "QTV4L2", "qv4l2" },
  139.    { "Tuxguitar", "tuxguitar" },
  140.    { "VLC", "vlc" },
  141.    { "UMplayer", "umplayer" },
  142. }
  143.  
  144. menuoffice = {
  145.    { "Nitro", "nitrotasks" },
  146.    { "ePDFviewer", "epdfview" },
  147.    { "LO Calc", "/usr/bin/libreoffice --calc" },
  148.    { "LO Draw", "/usr/bin/libreoffice --draw" },
  149.    { "LO Impress", "/usr/bin/libreoffice --impress" },
  150.    { "LO Math", "/usr/bin/libreoffice --math" },
  151.    { "LO Writer", "/usr/bin/libreoffice --writer" },
  152.    { "Lyx", "lyx" },
  153. }
  154.  
  155. submenucloud = {
  156.    { "Dropbox", "dropboxd" },
  157.    { "Wuala", "wuala" },
  158. }
  159.  
  160. menudevelop = {
  161.    { "Geany", "geany" },
  162.    { "IDLE", "idle" },
  163.    { "Qt Conf", "qtconfig" },
  164.    { "Python2", terminal .. " -e python2" },
  165.    { "Python2", terminal .. " -e python" },
  166. }
  167.  
  168. menushells = {
  169.    { "Sakura", "sakura" },
  170.    { "Terminator", "terminator" },
  171.    { "UXterm", "uxterm" },
  172.    { "Xterm", "xterm" },
  173. }
  174.  
  175. menuutil = {
  176.    { "7-Zip FM", "7zFM" },
  177.    { "Bleachbit", "bleachbit" },
  178.    { "File-Roller", "file-roller" },
  179.    { "Flash Player", "/opt/flashplayerdebugger" },
  180.    { "Timidity++", "timidity -ig" },
  181.    { "Notifyconf", "notifyconf" },
  182.    { "Info", terminal .. " -e info" },
  183.    { "Xev", terminal .. " -e xev" },
  184.    { "Xkill", "kill" },
  185.    { "Xrefresh", "xrefesh" },
  186.    { "Xsetroor", "xsetroot" },
  187. }
  188.  
  189. mymainmenu = awful.menu({ items = { { "Archlinux" },
  190.                                     { "Editores", menueditors },
  191.                                     { "Graficos", menugraphics },
  192.                                     { "Internet", menuweb },
  193.                                     { "cloud", submenucloud },
  194.                                     { "Multimedia", menumultimedia },
  195.                                     { "Oficina", menuoffice },
  196.                                     { "Desarrollo", menudevelop },
  197.                                     { "Shells", menushells },
  198.                                     { "Utilities", menuutil },
  199.                                     { "Sistema" },
  200.                                     { "Awesome", myawesomemenu },
  201.                                     { "Configurar", menuconf },
  202.                                     { "Sistema", menusys },
  203.                                     { "Terminal", terminal },
  204.                                     { "Anki", "anki" },
  205.                                     { "Firefox", "firefox" },
  206.                                     { "Spacefm", "spacefm" },
  207.                                     { "Reiniciar", "sudo systemctl reboot" },
  208.                                     { "Apagar", "sudo systemctl poweroff" }
  209.                                   }
  210.                         })
  211.  
  212. mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
  213.                                      menu = mymainmenu })
  214. -- }}}
  215.  
  216. -- {{{ Wibox
  217.  
  218. --- {{{ Volume Indicator
  219.   -- icon
  220.     volicon = widget({ type = "imagebox" })
  221.         volicon.image = image(beautiful.widget_vol)
  222.         volicon.resize = false
  223.         awful.widget.layout.margins[volicon] = { top = 2 }
  224.  -- scale
  225.         volwidget = widget({ type = "textbox", align = "right" })
  226.         vicious.register(volwidget, vicious.widgets.volume, "$1", 1, "Master")
  227. --- }}}
  228.  
  229. --- {{{ Wifi rate
  230.         wifi = widget({ type = "textbox" })
  231.         vicious.register(wifi, vicious.widgets.wifi, "${link}", 121, "wlan0")
  232.         wicon = widget({ type = "imagebox" })
  233.         wicon.image = image(beautiful.widget_wifi)
  234. --- }}}
  235.        
  236. --- {{{Sseparator/Spacer icons
  237.         separator = widget({ type = "textbox", align = "left"})
  238.         separator.text = '<span color="#14C3DE"> || </span>'
  239.         space = widget({ type = "textbox" })
  240.         space.text = " "
  241. --- }}}
  242.  
  243. --- {{{ OS info
  244.         sys = widget({ type= "textbox" })
  245.         sysicon = widget({type = "imagebox" })
  246.         sysicon.image = image(beautiful.widget_sys)
  247.         sysicon.resize = false
  248.         vicious.register(sys, vicious.widgets.os, "$1 $2")
  249. --- }}}
  250.  
  251. --- {{{ Battery Charge
  252.   -- Icon
  253.         baticon = widget({type = "imagebox" })
  254.         baticon.image = image(beautiful.widget_batt)
  255.         baticon.resize = false
  256.         awful.widget.layout.margins[baticon] = { top = 3 }
  257.         -- Percentage
  258.         battpct = widget({ type = "textbox", align = "right" })
  259.         vicious.register(battpct, vicious.widgets.bat, "$3", 61, "BAT0")
  260.   -- Meter
  261.         battbar = awful.widget.progressbar()
  262.         battbar:set_width(50)
  263.         battbar:set_height(10)
  264.         battbar:set_vertical(false)
  265.         battbar:set_background_color("#3F3F3F")
  266.         battbar:set_border_color(beautiful.bg_focus )
  267.         battbar:set_color("#ff6565" )
  268.         vicious.register(battbar, vicious.widgets.bat, "$2", 61, "BAT0")
  269.   -- Align progressbar
  270.         awful.widget.layout.margins[battbar.widget] = { top = 4 }
  271. --- }}}
  272.  
  273. -- {{{ Mem Usage
  274.   -- Icon
  275.     ramicon = widget({type = "imagebox" })
  276.     ramicon.image = image(beautiful.widget_mem)
  277.     ramicon.resize = false
  278.     awful.widget.layout.margins[ramicon] = { top = 3 }
  279.   -- Percentage
  280.         mempct = widget({ type= "textbox", align = "right"})
  281.         vicious.register(mempct, vicious.widgets.mem, "$1%", 13)
  282.   -- Meter
  283.         membar = awful.widget.progressbar()
  284.         membar:set_width(45)
  285.         membar:set_height(9)
  286.         membar:set_vertical(false)
  287.         membar:set_background_color("#3F3F3F")
  288.         membar:set_color("#ff6565" )
  289.         vicious.register(membar, vicious.widgets.mem, "$1", 13)
  290.   -- Megs used
  291.         memwidget = widget({ type= "textbox", align = "left"})
  292.         vicious.register(memwidget, vicious.widgets.mem, "$2Mb", 5)
  293.   -- Align progressbar
  294.         awful.widget.layout.margins[membar.widget] = { top = 4 }
  295.   -- Cache that shit
  296.         vicious.cache(vicious.widgets.mem)
  297. --- }}}
  298.        
  299. -- {{{ Filesystem info
  300.   -- Home Icons
  301.         fshomeicon = widget({ type = "imagebox" })
  302.         fshomeicon.image = image(beautiful.widget_fshome)
  303.         fshomeicon.resize = false
  304.         awful.widget.layout.margins[fshomeicon] = { top = 2 }
  305.   -- Root icon
  306.         fsrooticon = widget({ type = "imagebox" })
  307.         fsrooticon.image = image(beautiful.widget_fsroot)
  308.         fsrooticon.resize = false
  309.         awful.widget.layout.margins[fsrooticon] = { top = 2 }
  310.   -- Remaining
  311.         fsh = widget({ type = "textbox" })
  312.         vicious.register(fsh, vicious.widgets.fs, "${/home avail_gb}GB", 599)
  313.         fsr = widget({ type = "textbox" })
  314.         vicious.register(fsr, vicious.widgets.fs, "${/ avail_gb}GB", 599)
  315.   -- Home Meter
  316.         fshbar = awful.widget.progressbar()
  317.         fshbar:set_width(44)
  318.         fshbar:set_height(9)
  319.         fshbar:set_vertical(false)
  320.         fshbar:set_background_color("#3F3F3F")
  321.         fshbar:set_color("#ff6565" )
  322.         vicious.register(fshbar, vicious.widgets.fs, "${/home used_p}", 1501)
  323.   -- Root Meter
  324.         fsrbar = awful.widget.progressbar()
  325.         fsrbar:set_width(44)
  326.         fsrbar:set_height(9)
  327.         fsrbar:set_vertical(false)
  328.         fsrbar:set_background_color("#3F3F3F")
  329.         fsrbar:set_color("#ff6565" )
  330.         vicious.register(fsrbar, vicious.widgets.fs, "${/home used_p}", 1501)
  331.   -- Align progressbars
  332.         awful.widget.layout.margins[fshbar.widget] = { top = 4 }
  333.         awful.widget.layout.margins[fsrbar.widget] = { top = 4 }
  334.   -- Cache that shit
  335.         vicious.cache(vicious.widgets.fs)
  336. -- }}}
  337.  
  338. -- {{{ CPU
  339.   -- Core Temp
  340.         tempwidget = widget({ type = "textbox" })
  341.         vicious.register(tempwidget, vicious.widgets.thermal, "$1 C", 5, "thermal_zone0")
  342.  -- Icon
  343.         tempicon = widget({type = "imagebox" })
  344.         tempicon.image = image(beautiful.widget_temp)
  345. -- Readout
  346.   -- Icon
  347.         cpuicon = widget({ type = "imagebox" })
  348.         cpuicon.image = image(beautiful.widget_cpu)
  349.     cpuicon.resize = false
  350.     awful.widget.layout.margins[cpuicon] = { top = 3 }
  351.   -- Percentage
  352.         cpu1 = widget({ type = "textbox" })
  353.         vicious.register(cpu1, vicious.widgets.cpu, "(1): $1%")
  354.         cpu2 = widget ({ type = "textbox" })
  355.         vicious.register(cpu2, vicious.widgets.cpu, "(2): $2%")
  356.   -- CPU1 Meter
  357.         cpubar = awful.widget.progressbar()
  358.         cpubar:set_width(44)
  359.         cpubar:set_height(9)
  360.         cpubar:set_vertical(false)
  361.         cpubar:set_background_color("#3F3F3F")
  362.         cpubar:set_color("#ff6565" )
  363.         vicious.register(cpubar, vicious.widgets.cpu, "$1", 7)
  364.   -- CPU2 Meter
  365.         cpubar2 = awful.widget.progressbar()
  366.         cpubar2:set_width(44)
  367.         cpubar2:set_height(9)
  368.         cpubar2:set_vertical(false)
  369.         cpubar2:set_background_color("#3F3F3F")
  370.         cpubar2:set_color("#ff6565" )
  371.         vicious.register(cpubar2, vicious.widgets.cpu, "$2", 7)
  372.   -- Align progressbars
  373.         awful.widget.layout.margins[cpubar.widget] = { top = 4 }
  374.         awful.widget.layout.margins[cpubar2.widget] = { top = 4 }
  375.   -- Frequency
  376.         --freq1 = widget({ type = "textbox" })
  377.         --vicious.register(freq1, vicious.widgets.cpufreq, "$2 Ghz", 9, "cpu0")
  378.         --freq2 = widget({ type = "textbox" })
  379.         --vicious.register(freq2, vicious.widgets.cpufreq, "$2 Ghz", 9, "cpu1")
  380.   -- Cache that shit
  381.         vicious.cache(vicious.widgets.cpu)
  382. --- }}}
  383.  
  384. --- {{{ Network usage widget
  385.   -- icons
  386.     neticonup = widget({type = "imagebox" })
  387.     neticonup.image = image(beautiful.widget_net_up)
  388.     neticonup.resize = false
  389.     awful.widget.layout.margins[neticonup] = { top = 3 }
  390.     neticondown = widget({type = "imagebox" })
  391.     neticondown.image = image(beautiful.widget_net_down)
  392.     neticondown.resize = false
  393.     awful.widget.layout.margins[neticondown] = { top = 3 }
  394.   -- Initialize widget
  395.     netwidgetup = widget({ type = "textbox" })
  396.     vicious.register(netwidgetup, vicious.widgets.net, '<span color="#7F9F7F">${eth0 up_kb}</span>', 3)
  397.     netwidgetdown = widget({ type = "textbox" })
  398.     vicious.register(netwidgetdown, vicious.widgets.net, '<span color="#CC9393">${eth0 down_kb}</span>', 3)
  399. --- }}}
  400.  
  401. ---{{{ Keyboard widget
  402. kbdcfg = {}
  403. kbdcfg.cmd = "setxkbmap"
  404.  
  405. --list your own keyboard layouts here
  406. kbdcfg.layout = { "us","es","gb", "latam" }
  407.  
  408. kbdcfg.current = 1
  409. kbdcfg.widget = widget({ type = "textbox", align = "right" })
  410. kbdcfg.widget.text = " " .. kbdcfg.layout[kbdcfg.current] .. " "
  411. kbdcfg.switch = function ()
  412.     kbdcfg.current = kbdcfg.current % #(kbdcfg.layout) + 1
  413.     local t = " " .. kbdcfg.layout[kbdcfg.current] .. " "
  414.     kbdcfg.widget.text = t
  415.     os.execute( kbdcfg.cmd .. t )
  416. end
  417.  
  418. kbdcfg.widget:buttons(awful.util.table.join(
  419.     awful.button({ }, 1, function () kbdcfg.switch() end)
  420. ))
  421. ---}}}
  422.  
  423. -- Textclock widget
  424. mytextclock = awful.widget.textclock({ align = "right" }, "%a %d %b, %H:%M:%S", 1)
  425. -- Show calendar
  426. calendar2.addCalendarToWidget(mytextclock)
  427.  
  428. -- Create a systray
  429. mysystray = widget({ type = "systray" })
  430.  
  431. -- Create a wibox for each screen and add it
  432. mywibox = {}
  433. mypromptbox = {}
  434. mylayoutbox = {}
  435. mytaglist = {}
  436. mytaglist.buttons = awful.util.table.join(
  437.                     awful.button({ }, 1, awful.tag.viewonly),
  438.                     awful.button({ modkey }, 1, awful.client.movetotag),
  439.                     awful.button({ }, 3, awful.tag.viewtoggle),
  440.                     awful.button({ modkey }, 3, awful.client.toggletag),
  441.                     awful.button({ }, 4, awful.tag.viewnext),
  442.                     awful.button({ }, 5, awful.tag.viewprev)
  443.                     )
  444. mytasklist = {}
  445. mytasklist.buttons = awful.util.table.join(
  446.                      awful.button({ }, 1, function (c)
  447.                                               if c == client.focus then
  448.                                                   c.minimized = true
  449.                                               else
  450.                                                   if not c:isvisible() then
  451.                                                       awful.tag.viewonly(c:tags()[1])
  452.                                                   end
  453.                                                   -- This will also un-minimize
  454.                                                   -- the client, if needed
  455.                                                   client.focus = c
  456.                                                   c:raise()
  457.                                               end
  458.                                           end),
  459.                      awful.button({ }, 3, function ()
  460.                                               if instance then
  461.                                                   instance:hide()
  462.                                                   instance = nil
  463.                                               else
  464.                                                   instance = awful.menu.clients({ width=250 })
  465.                                               end
  466.                                           end),
  467.                      awful.button({ }, 4, function ()
  468.                                               awful.client.focus.byidx(1)
  469.                                               if client.focus then client.focus:raise() end
  470.                                           end),
  471.                      awful.button({ }, 5, function ()
  472.                                               awful.client.focus.byidx(-1)
  473.                                               if client.focus then client.focus:raise() end
  474.                                           end))
  475.  
  476. for s = 1, screen.count() do
  477.     -- Create a promptbox for each screen
  478.     mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
  479.     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  480.     -- We need one layoutbox per screen.
  481.     mylayoutbox[s] = awful.widget.layoutbox(s)
  482.     mylayoutbox[s]:buttons(awful.util.table.join(
  483.                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  484.                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  485.                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  486.                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  487.     -- Create a taglist widget
  488.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
  489.  
  490.     -- Create a tasklist widget
  491.     mytasklist[s] = awful.widget.tasklist(function(c)
  492.                                               return awful.widget.tasklist.label.currenttags(c, s)
  493.                                           end, mytasklist.buttons)
  494.  
  495.     -- Create the wibox
  496.     mywibox[s] = awful.wibox({ position = "top", screen = s, height=19, opacity = 0.65})
  497.     -- Add widgets to the wibox - order matters
  498.     mywibox[s].widgets = {
  499.         {
  500.             mylauncher,
  501.             mytaglist[s],
  502.             mypromptbox[s],
  503.             layout = awful.widget.layout.horizontal.leftright
  504.         },
  505.         mylayoutbox[s],
  506.         separator, -- mytextclock, separator,
  507.         s == 1 and mysystray or nil,
  508.         separator, kbdcfg.widget, separator,
  509.         mytasklist[s],
  510.         layout = awful.widget.layout.horizontal.rightleft
  511.     }
  512. -- Create the bottom wibox
  513.      mywibox[s] = awful.wibox({ position = "bottom", screen = s, height=19, opacity = 0.79})
  514.       mywibox[s].widgets = {
  515.         {
  516.            
  517.             space, sysicon, space, sys, separator,
  518.             neticonup, espace, netwidgetup, space,
  519.             neticondown, espace, netwidgetdown, separator,
  520.             baticon, space, battpct, space, battbar, separator,
  521.             ramicon, space, memwidget, space, membar, separator,
  522.             fshomeicon, space, fshbar, space, fsh, separator,
  523.             fsrooticon, space, fsrbar, space, fsr, separator,
  524.             volicon, space, volwidget, separator,    
  525.   --          cpuicon, space, cpu1, space, cpubar, space, space,  
  526.   --          cpuicon, space, cpu2, space, cpubar2, separator,
  527.             cpuicon, space, cpu1, separator, cpuicon, space, cpu2, separator,
  528.             mytextclock,
  529.             layout = awful.widget.layout.horizontal.leftright
  530.         },
  531.         layout = awful.widget.layout.horizontal.rightleft
  532.      }
  533. end
  534. -- {{{ Mouse bindings
  535. root.buttons(awful.util.table.join(
  536.     awful.button({ }, 3, function () mymainmenu:toggle() end),
  537.     awful.button({ }, 4, awful.tag.viewnext),
  538.     awful.button({ }, 5, awful.tag.viewprev)
  539. ))
  540. -- }}}
  541.  
  542. -- {{{ Key bindings
  543. globalkeys = awful.util.table.join(
  544.     awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
  545.     awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
  546.     awful.key({ modkey,           }, "Escape", awful.tag.history.restore),
  547.     awful.key({ modkey,           }, "j",
  548.         function ()
  549.             awful.client.focus.byidx( 1)
  550.             if client.focus then client.focus:raise() end
  551.         end),
  552.     awful.key({ modkey,           }, "k",
  553.         function ()
  554.             awful.client.focus.byidx(-1)
  555.             if client.focus then client.focus:raise() end
  556.         end),
  557.     awful.key({ modkey,           }, "w", function () mymainmenu:show({keygrabber=true}) end),
  558.  
  559.     -- Layout manipulation
  560.     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
  561.     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
  562.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  563.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  564.     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
  565.     awful.key({ modkey,           }, "Tab",
  566.         function ()
  567.             awful.client.focus.history.previous()
  568.             if client.focus then
  569.                 client.focus:raise()
  570.             end
  571.         end),
  572.  
  573.     -- Standard program
  574.     awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
  575.     awful.key({ modkey, "Control" }, "r", awesome.restart),
  576.     awful.key({ modkey, "Shift"   }, "q", awesome.quit),
  577.  
  578.     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
  579.     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
  580.     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
  581.     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
  582.     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
  583.     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
  584.     awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
  585.     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
  586.  
  587.     awful.key({ modkey, "Control" }, "n", awful.client.restore),
  588.  
  589.     -- Prompt
  590.     awful.key({ modkey },            "r",     function () mypromptbox[mouse.screen]:run() end),
  591.  
  592.     awful.key({ modkey }, "x",
  593.               function ()
  594.                   awful.prompt.run({ prompt = "Run Lua code: " },
  595.                   mypromptbox[mouse.screen].widget,
  596.                   awful.util.eval, nil,
  597.                   awful.util.getdir("cache") .. "/history_eval")
  598.               end)
  599. )
  600.  
  601. clientkeys = awful.util.table.join(
  602.     awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
  603.     awful.key({ modkey, "Shift"   }, "c",      function (c) c:kill()                         end),
  604.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
  605.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  606.     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
  607.     awful.key({ modkey, "Shift"   }, "r",      function (c) c:redraw()                       end),
  608.     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
  609.     awful.key({ modkey,           }, "n",
  610.         function (c)
  611.             -- The client currently has the input focus, so it cannot be
  612.             -- minimized, since minimized clients can't have the focus.
  613.             c.minimized = true
  614.         end),
  615.     awful.key({ modkey,           }, "m",
  616.         function (c)
  617.             c.maximized_horizontal = not c.maximized_horizontal
  618.             c.maximized_vertical   = not c.maximized_vertical
  619.         end)
  620. )
  621.  
  622. -- Compute the maximum number of digit we need, limited to 9
  623. keynumber = 0
  624. for s = 1, screen.count() do
  625.    keynumber = math.min(9, math.max(#tags[s], keynumber));
  626. end
  627.  
  628. -- Bind all key numbers to tags.
  629. -- Be careful: we use keycodes to make it works on any keyboard layout.
  630. -- This should map on the top row of your keyboard, usually 1 to 9.
  631. for i = 1, keynumber do
  632.     globalkeys = awful.util.table.join(globalkeys,
  633.         awful.key({ modkey }, "#" .. i + 9,
  634.                   function ()
  635.                         local screen = mouse.screen
  636.                         if tags[screen][i] then
  637.                             awful.tag.viewonly(tags[screen][i])
  638.                         end
  639.                   end),
  640.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  641.                   function ()
  642.                       local screen = mouse.screen
  643.                       if tags[screen][i] then
  644.                           awful.tag.viewtoggle(tags[screen][i])
  645.                       end
  646.                   end),
  647.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  648.                   function ()
  649.                       if client.focus and tags[client.focus.screen][i] then
  650.                           awful.client.movetotag(tags[client.focus.screen][i])
  651.                       end
  652.                   end),
  653.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  654.                   function ()
  655.                       if client.focus and tags[client.focus.screen][i] then
  656.                           awful.client.toggletag(tags[client.focus.screen][i])
  657.                       end
  658.                   end))
  659. end
  660.  
  661. clientbuttons = awful.util.table.join(
  662.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  663.     awful.button({ modkey }, 1, awful.mouse.client.move),
  664.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  665.  
  666. -- Set keys
  667. root.keys(globalkeys)
  668. -- }}}
  669.  
  670. -- {{{ Rules
  671. awful.rules.rules = {
  672.     -- All clients will match this rule.
  673.     { rule = { },
  674.       properties = { border_width = beautiful.border_width,
  675.                      border_color = beautiful.border_normal,
  676.                      focus = true,
  677.                      keys = clientkeys,
  678.                      buttons = clientbuttons } },
  679.     { rule = { class = "Spacefm" }, properties = { tag = tags[1][2] } },
  680.     { rule = { class = "MPlayer" },
  681.       properties = { floating = true } },
  682.     { rule = { class = "pinentry" },
  683.       properties = { floating = true } },
  684.     { rule = { class = "Gimp" }, properties = { tag = tags[1][4] } },
  685.     -- Set Firefox to always map on tags number 2 of screen 1.
  686.     { rule = { class = "Firefox" }, properties = { tag = tags[1][3] } },
  687. }
  688. -- }}}
  689.  
  690. -- {{{ Signals
  691. -- Signal function to execute when a new client appears.
  692. client.add_signal("manage", function (c, startup)
  693.     -- Add a titlebar
  694.     -- awful.titlebar.add(c, { modkey = modkey })
  695.  
  696.     -- Enable sloppy focus
  697.     c:add_signal("mouse::enter", function(c)
  698.         if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  699.             and awful.client.focus.filter(c) then
  700.             client.focus = c
  701.         end
  702.     end)
  703.  
  704.     if not startup then
  705.         -- Set the windows at the slave,
  706.         -- i.e. put it at the end of others instead of setting it master.
  707.         -- awful.client.setslave(c)
  708.  
  709.         -- Put windows in a smart way, only if they does not set an initial position.
  710.         if not c.size_hints.user_position and not c.size_hints.program_position then
  711.             awful.placement.no_overlap(c)
  712.             awful.placement.no_offscreen(c)
  713.         end
  714.     end
  715. end)
  716.  
  717. client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  718. client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  719. -- }}}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top