Guest User

rc.lua

a guest
Dec 15th, 2013
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 32.71 KB | None | 0 0
  1. -- Standard awesome library
  2. local gears = require("gears")
  3. local awful = require("awful")
  4. awful.rules = require("awful.rules")
  5. require("awful.autofocus")
  6. -- Widget and layout library
  7. local wibox = require("wibox")
  8. local vicious = require("vicious")
  9. -- Theme handling library
  10. local beautiful = require("beautiful")
  11. -- Notification library
  12. local naughty = require("naughty")
  13. local menubar = require("menubar")
  14. -- Lain
  15. local lain = require("lain")
  16. local lain_custom_mpd = require("lain_custom.mpd")
  17. local sysinfo = require("lain_custom.sysinfo")
  18. -- local drop = require("scratchdrop")
  19.  
  20. -- {{{ Error handling
  21. -- Check if awesome encountered an error during startup and fell back to
  22. -- another config (This code will only ever execute for the fallback config)
  23. if awesome.startup_errors then
  24.     naughty.notify({ preset = naughty.config.presets.critical,
  25.                      title = "Oops, there were errors during startup!",
  26.                      text = awesome.startup_errors })
  27. end
  28.  
  29. -- Handle runtime errors after startup
  30. do
  31.     local in_error = false
  32.     awesome.connect_signal("debug::error", function (err)
  33.         -- Make sure we don't go into an endless error loop
  34.         if in_error then return end
  35.         in_error = true
  36.  
  37.         naughty.notify({ preset = naughty.config.presets.critical,
  38.                          title = "Oops, an error happened!",
  39.                          text = err })
  40.         in_error = false
  41.     end)
  42. end
  43. -- }}}
  44.  
  45. -- {{{ Variable definitions
  46. -- Themes define colours, icons, and wallpapers
  47. beautiful.init("/home/gregory/.config/awesome/themes/20131205/theme.lua")
  48.  
  49. -- This is used later as the default terminal and editor to run.
  50. terminal = "termite"
  51. editor = os.getenv("EDITOR") or "nano"
  52. editor_gui = "bluefish"
  53. editor_cmd = editor_gui
  54. --editor_cmd = terminal .. " -e " .. editor_gui
  55.  
  56. -- Default modkey.
  57. -- Usually, Mod4 is the key with a logo between Control and Alt.
  58. -- If you do not like this or do not have such a key,
  59. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  60. -- However, you can use another modifier like Mod1, but it may interact with others.
  61. modkey = "Mod4"
  62.  
  63. -- Table of layouts to cover with awful.layout.inc, order matters.
  64. local layouts =
  65. {
  66.     awful.layout.suit.floating, --1
  67.     awful.layout.suit.tile, --2
  68.     awful.layout.suit.tile.left, --3
  69.     awful.layout.suit.tile.bottom, --4
  70.     awful.layout.suit.tile.top, --5
  71.     awful.layout.suit.fair, --6
  72.     awful.layout.suit.fair.horizontal, --7
  73.     awful.layout.suit.spiral, --8
  74.     awful.layout.suit.spiral.dwindle, --9
  75.     awful.layout.suit.max, --10
  76.     awful.layout.suit.max.fullscreen, --11
  77.     awful.layout.suit.magnifier, --12
  78.      lain.layout.uselesstile, --13
  79.      lain.layout.uselesstile.left, --14
  80.      lain.layout.uselessfair, --15
  81.      lain.layout.uselesspiral --16
  82. }
  83. -- }}}
  84.  
  85. -- {{{ Wallpaper
  86. -- if beautiful.wallpaper then
  87. --    for s = 1, screen.count() do
  88. --        gears.wallpaper.maximized(beautiful.wallpaper, s, true)
  89. --    end
  90. -- end
  91. -- }}}
  92.  
  93. -- {{{ Tags
  94. -- Define a tag table which hold all screen tags.
  95.  tags = {
  96.    settings = {
  97.      { names  = { "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII", "XIII"  },
  98.        layout = { layouts[13], layouts[1], layouts[13], layouts[13], layouts[14], layouts[14], layouts[1], layouts[13], layouts[13], layouts[13], layouts[13], layouts[13], layouts[13] }
  99.      },
  100.      { names  = { "I", "II", "III", "IV", "V" },
  101.        layout = { layouts[13], layouts[13], layouts[13], layouts[13], layouts[13] }
  102.  }}}
  103.  
  104. -- ●
  105.  
  106.  for s = 1, screen.count() do
  107.      tags[s] = awful.tag(tags.settings[s].names, s, tags.settings[s].layout)
  108.  end
  109.  
  110. -- {{{ Menu
  111. -- Create a laucher widget and a main menu
  112. myawesomemenu = {
  113.    { "manual", terminal .. " -e man awesome" },
  114.    { "edit config", editor_cmd .. " " .. awesome.conffile },
  115.    { "restart", awesome.restart },
  116.    { "quit", awesome.quit }
  117. }
  118.  
  119. myappmenu_accessories = {
  120.     { "Calculator", "galculator"},
  121. }
  122.  
  123. myappmenu_texteditors = {
  124.     { "Mousepad", "mousepad"},
  125.     { "Bluefish", "bluefish"},
  126. }
  127.  
  128. myappmenu_office = {
  129.     { "Abiword", "abiword"},
  130.     { "Gnumeric", "gnumeric"},
  131. }
  132.  
  133. myappmenu_graphics = {
  134.     { "Gimp", "gimp" },
  135. }
  136.  
  137. myappmenu_audiovideo = {
  138.     { "Soundconverter", "soundconverter" },
  139. }
  140.  
  141. myappmenu_network = {
  142.     { "Deluge", "deluge" },
  143.     { "Pidgin", "pidgin" },
  144.     { "Hotot",  "hotot-gtk3" },
  145. }
  146.  
  147. myapplicationsmenu = {
  148.     { "Accessories", myappmenu_accessories },
  149.     { "Text Editors", myappmenu_texteditors },
  150.     { "Office", myappmenu_office },
  151.     { "Games", nil },
  152.     { "Financial", nil },
  153.     { "Graphics", myappmenu_graphics },
  154.     { "Audio/Video", myappmenu_audiovideo },
  155.     { "Network", myappmenu_network },
  156. }
  157.  
  158. mymenu_finance = {
  159.     { "Ledger" , "gnucash --name=gnucashmain"},
  160.     {nil,nil},
  161.     { "Refresh Ledger Analysis", "termite -e \"java -jar /home/gregory/bin/java/GnucashJasperReporting.jar && read\"" },
  162.     {nil,nil},
  163.     { "PDF Ledger Analysis", "llpp /mnt/warehouse/documents/financial/reports/GnuCashBatchExportPostgreSQL.pdf" },
  164.     { "HTML Ledger Analysis", nil}
  165. }
  166.  
  167. mymenu_imagemanagement = {
  168.     { "My Photos" , "shotwell -d /mnt/warehouse/multimedia/images/photographs/db_app/shotwell_db/personal/"},
  169.     { "Family Photos", "shotwell -d /mnt/warehouse/multimedia/images/photographs/db_app/shotwell_db/family/" },
  170.     { "Wallpaper", "shotwell -d /mnt/warehouse/multimedia/images/photographs/db_app/shotwell_db/wallpaper/"},
  171. }
  172.  
  173. mysystemmenu = {
  174.     { "Desktop Wallpaper", "nitrogen --sort=alpha" },
  175.     { "nVidia Settings", "nvidia-settings" },
  176.     { "ALSA Mixer", "gnome-alsamixer"},
  177.     { "VirtualBox Machines", "VirtualBox" },
  178.     { nil, nil},
  179.     { "Systemd Administration", "systemadm"},
  180.     { nil, nil},   
  181.     { "Awesome WM Configuration", editor_cmd .. " " .. awesome.conffile },
  182.     { "GTk Appearance", "lxappearance"},
  183.     { "Conky Configuration", editor_cmd .. " /home/gregory/config/conky/conky-awesome-detail.conf "},
  184. }
  185.  
  186. mymainmenu = awful.menu(
  187.     { items = {
  188.         { "Internet", "firefox" },
  189.         { "Internet (Tor)", "tor-browser-en" },
  190.         { "E-Mail", "thunderbird" },
  191.         { "Terminal", terminal },
  192.         { "Notes (zim)", "zim" },
  193.         { "Music", "sonata" },
  194.         { "Calculator", "galculator" },
  195.         { "Task Manager","lxtask" },
  196.         { "PostgreSQL Administration", "pgadmin3" },
  197.         { nil, nil },
  198.         { "VM - Windows 7", "VBoxManage startvm \"Windows 7\"" },
  199.         { "VM - Linux", "VBoxManage startvm \"Linux\"" },
  200.         { nil, nil },
  201.         { "Eclipse", "eclipse" },
  202.         { "Spring Tool Suite", "/opt/springsource/sts-3.4.0.RELEASE/STS" },
  203.         { "Jasper iReport", "/opt/iReport-5.1.0/bin/ireport"},
  204.         { nil,nil },
  205.         { "Finance", mymenu_finance },
  206.         { "Image Management", mymenu_imagemanagement },
  207.         { nil, nil },
  208.         { "Home", "thunar /home/gregory"},
  209.         { "Scripts", "thunar /home/gregory/scripts"},
  210.         { "Downloads", "thunar /mnt/warehouse/staging/incoming"},                  
  211.         { nil, nil },
  212.         { "Applications", myapplicationsmenu },                
  213.         { "System", mysystemmenu },
  214.         { nil, nil },
  215.         { "Restart WM", awesome.restart },
  216.         { "Quit", awesome.quit }
  217.     },
  218.         theme = {width = 250}
  219.    })
  220.  
  221. mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
  222.                                      menu = mymainmenu })
  223.  
  224. -- Menubar configuration
  225. menubar.utils.terminal = terminal -- Set the terminal for applications that require it
  226. -- }}}
  227.  
  228. -- {{{ Wibox
  229. markup = lain.util.markup
  230. white = beautiful.fg_focus
  231. gray = "#858585"
  232.  
  233. -- Initiate all the widgets
  234. -- Space
  235. space = wibox.widget.textbox()
  236. space:set_text(' ')
  237.  
  238. divider = wibox.widget.textbox()
  239. divider:set_text('|')
  240.  
  241. iwidget = wibox.widget.imagebox()
  242. iwidget:fit(10,10)
  243. iwidget:set_resize(true)
  244. iwidget:set_image(beautiful.widget_info03)
  245. sysinfo.update()
  246. iwidget:connect_signal("mouse::enter", function() sysinfo.show() end )
  247. iwidget:connect_signal("mouse::leave", function() sysinfo.hide() end )
  248.  
  249. cpuwidget = wibox.widget.textbox()
  250. vicious.register(cpuwidget, vicious.widgets.cpu, "CPU $1%")
  251.  
  252. memwidget = lain.widgets.mem({
  253.     settings = function()
  254.         timeout = 7
  255.       widget:set_markup(" MEM " .. (string.format("%." .. (2 or 0) .. "f", ((mem_now.free + mem_now.buf + mem_now.cache)/1000))) .. "G ")
  256.     end
  257. })
  258.  
  259.  netwidget = wibox.widget.textbox()
  260.  vicious.register(netwidget, vicious.widgets.net, 'NET: ${enp3s0 down_kb} / ${enp3s0 up_kb}', 3)
  261.  
  262. volwidget = wibox.widget.textbox()
  263. vicious.register(volwidget, vicious.widgets.volume, "VOL: $1% ", 2, "PCM -M -c 0")
  264. volwidget:buttons(awful.util.table.join(
  265.     awful.button({ }, 1, function () awful.util.spawn("amixer -q set Master toggle", false) end),
  266.    awful.button({ }, 3, function () awful.util.spawn("termite -e alsamixer", true) end),
  267.    awful.button({ }, 4, function () awful.util.spawn("amixer -q set PCM 2dB+", false) end),
  268.    awful.button({ }, 5, function () awful.util.spawn("amixer -q set PCM 2dB-", false) end)
  269. ))
  270.  
  271.  
  272. -- Initialize MPD Icon / Widget
  273. mpdwidget = lain_custom_mpd({
  274.     music_dir = "/mnt/warehouse/multimedia/audio/music",
  275.    cover_size = 150,
  276.    default_art = os.getenv("HOME") .. "/mpd/nocoverart.jpg",
  277.    settings = function()
  278.    -- mpd_notification_preset.fg = white
  279.    mpd_notification_preset.title = ""
  280.    mpd_notification_preset.text = string.format("%s\n%s\n%s\n%s\n%s", mpd_now.title, mpd_now.artist, mpd_now.album, mpd_now.track, mpd_now.date)
  281.    mpd_notification_preset.width = 500
  282.    mpd_notification_preset.timeout = 2
  283.    artist = mpd_now.artist
  284.    album = mpd_now.album
  285.    track = mpd_now.track
  286.    title = mpd_now.title
  287.    time  = mpd_now.time
  288.    spos  = mpd_now.spos
  289.    slen  = mpd_now.slen
  290.        
  291.    if mpd_now.state == "play" then
  292.     widget:set_markup(artist .. " (" .. album .. " " .. track .. ") " .. title .. "   (" .. spos .. "/" .. slen .. ")")
  293.     else
  294.     artist = ""
  295.     album = ""
  296.     track = ""
  297.     title = ""
  298.     time = ""
  299.     spos = ""
  300.     slen = ""
  301.         if mpd_now.state == "pause" then
  302.             widget:set_markup("MPD: Paused")
  303.         end
  304.         if mpd_now.state == "stop" then
  305.             widget:set_markup("MPD: Stopped")
  306.         end
  307.     end        
  308. end
  309. })
  310.  
  311. -- /home fs
  312. --fshome = lain.widgets.fs({
  313. --    partition = "/home",
  314. --    settings = function()
  315. --        fs_notification_preset.fg = white
  316. --        fs_notification_preset.font = "Droid Sans Mono 8"
  317. --        fs_header = ""
  318. --        fs_p = ""
  319.  
  320.        
  321. --       --if fs_now.used >= 90 then
  322. --            fs_header = " Hdd "
  323. --            fs_p = fs_now.used
  324. --        --end
  325.  
  326. --        widget:set_markup(markup(gray, fs_header) .. markup(white, fs_p))
  327. --    end
  328. --})
  329.  
  330. mytextclock = awful.widget.textclock(" %a %b %d %I:%M ", 61)
  331.  
  332. -- Set up a Calendar to be called when you hover over the mytextclock widget
  333.  
  334. local calendar = nil
  335.  
  336. function remove_calendar()
  337.     if calendar ~= nil then
  338.         naughty.destroy(calendar)
  339.         calendar = nil
  340.     end
  341. end
  342.  
  343. function add_calendar()
  344.     remove_calendar()
  345.     local cal = awful.util.pread("cal -3m ")
  346.     cal = string.gsub(cal, "^%s*(.-)%s*$", "%1")
  347.     calendar = naughty.notify({text = string.format('<span font_desc="%s">%s</span>', "Droid Sans Mono Bold 9", "\n" .. cal), timeout = 0, hover_timeout = 0.5, width = 470, })
  348. end
  349.  
  350. mytextclock:connect_signal("mouse::enter", function() add_calendar() end )
  351. mytextclock:connect_signal("mouse::leave", function() remove_calendar() end )
  352.  
  353. -- Custom Functions
  354.  
  355.  
  356.  
  357.  
  358. -- Create a wibox for each screen and add it
  359. mywibox = {}
  360. mywiboxsystem = {}
  361. mywiboxmusic = {}
  362. mywiboxtasklist = {}
  363.  
  364. mypromptbox = {}
  365. mylayoutbox = {}
  366.  
  367. mytaglist = {}
  368.  
  369. mytaglist.buttons = awful.util.table.join(
  370.                     awful.button({ }, 1, awful.tag.viewonly),
  371.                     awful.button({ modkey }, 1, awful.client.movetotag),
  372.                     awful.button({ }, 3, awful.tag.viewtoggle),
  373.                     awful.button({ modkey }, 3, awful.client.toggletag),
  374.                     awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
  375.                     awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
  376.                     )
  377. mytasklist = {}
  378. mytasklist.buttons = awful.util.table.join(
  379.                      awful.button({ }, 1, function (c)
  380.                                               if c == client.focus then
  381.                                                   c.minimized = true
  382.                                               else
  383.                                                   -- Without this, the following
  384.                                                   -- :isvisible() makes no sense
  385.                                                   c.minimized = false
  386.                                                   if not c:isvisible() then
  387.                                                       awful.tag.viewonly(c:tags()[1])
  388.                                                   end
  389.                                                   -- This will also un-minimize
  390.                                                   -- the client, if needed
  391.                                                   client.focus = c
  392.                                                   c:raise()
  393.                                               end
  394.                                           end),
  395.                      awful.button({ }, 3, function ()
  396.                                               if instance then
  397.                                                   instance:hide()
  398.                                                   instance = nil
  399.                                               else
  400.                                                   instance = awful.menu.clients({ width=250 })
  401.                                               end
  402.                                           end),
  403.                      awful.button({ }, 4, function ()
  404.                                               awful.client.focus.byidx(1)
  405.                                               if client.focus then client.focus:raise() end
  406.                                           end),
  407.                      awful.button({ }, 5, function ()
  408.                                               awful.client.focus.byidx(-1)
  409.                                               if client.focus then client.focus:raise() end
  410.                                           end))
  411.  
  412.  
  413. for s = 1, screen.count() do
  414.     -- Create a promptbox for each screen
  415.     mypromptbox[s] = awful.widget.prompt()
  416.     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  417.     -- We need one layoutbox per screen.
  418.     mylayoutbox[s] = awful.widget.layoutbox(s)
  419.     mylayoutbox[s]:buttons(awful.util.table.join(
  420.                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  421.                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  422.                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  423.                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  424.     -- Create a taglist widget
  425.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
  426.  
  427.     -- Create a tasklist widget
  428.     mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
  429.  
  430.     -- Create the wibox
  431.     mywibox[s] = awful.wibox({ position = "top", screen = s })
  432.      
  433.     -- Widgets that are aligned to the left
  434.     local left_layout = wibox.layout.fixed.horizontal()
  435.     left_layout:add(mylauncher)
  436.     left_layout:add(mytaglist[s])
  437.     left_layout:add(mypromptbox[s])
  438.  
  439.     -- Widgets that are aligned to the right
  440.     local right_layout = wibox.layout.fixed.horizontal()
  441.     if s == 1 then
  442.         --right_layout:add(mpdicon)
  443.         --right_layout:add(fshome)
  444.         right_layout:add(mpdwidget)
  445.         right_layout:add(space)
  446.         right_layout:add(space)
  447.         right_layout:add(space)
  448.         right_layout:add(space)
  449.         right_layout:add(volwidget)
  450.         right_layout:add(space)
  451.         right_layout:add(space)
  452.         right_layout:add(space)
  453.         right_layout:add(netwidget)
  454.         right_layout:add(space)
  455.         right_layout:add(space)
  456.         right_layout:add(space)
  457.         right_layout:add(memwidget)
  458.         right_layout:add(space)
  459.         right_layout:add(space)
  460.         right_layout:add(space)
  461.         right_layout:add(cpuwidget)
  462.         right_layout:add(space)
  463.         right_layout:add(space)
  464.         right_layout:add(space)
  465.         right_layout:add(iwidget)
  466.         right_layout:add(space)
  467.         right_layout:add(space)
  468.         right_layout:add(space)
  469.         right_layout:add(wibox.widget.systray())
  470.         right_layout:add(space)
  471.         right_layout:add(space)
  472.         right_layout:add(space)
  473.         right_layout:add(mytextclock)
  474.     end
  475.     right_layout:add(mylayoutbox[s])
  476.  
  477.     -- Now bring it all together (with the tasklist in the middle)
  478.     local layout = wibox.layout.align.horizontal()
  479.     layout:set_left(left_layout)
  480.     layout:set_right(right_layout)
  481.  
  482.     mywibox[s]:set_widget(layout)
  483.  
  484.     -- Create the wibox for the tasklist   
  485.     mywiboxtasklist[s] = awful.wibox({ position = "bottom", screen = s, ontop = true })
  486.  
  487.     local layout = wibox.layout.align.horizontal()
  488.     layout:set_middle(mytasklist[s])
  489.    
  490.     mywiboxtasklist[s]:set_widget(layout)
  491.    
  492. end
  493.  
  494.  
  495.  
  496. -- }}}
  497.  
  498. -- {{{ Mouse bindings
  499. root.buttons(awful.util.table.join(
  500.     awful.button({ }, 3, function () mymainmenu:toggle() end),
  501.     awful.button({ }, 4, awful.tag.viewnext),
  502.     awful.button({ }, 5, awful.tag.viewprev)
  503. ))
  504. -- }}}
  505.  
  506. -- {{{ Key bindings
  507. globalkeys = awful.util.table.join(
  508.     awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
  509.     awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
  510.     awful.key({ modkey,           }, "Escape", awful.tag.history.restore),
  511.  
  512.     awful.key({ modkey,           }, "j",
  513.         function ()
  514.             awful.client.focus.byidx( 1)
  515.             if client.focus then client.focus:raise() end
  516.         end),
  517.     awful.key({ modkey,           }, "k",
  518.         function ()
  519.             awful.client.focus.byidx(-1)
  520.             if client.focus then client.focus:raise() end
  521.         end),
  522.     awful.key({ modkey,           }, "w", function () mymainmenu:show() end),
  523.  
  524.     -- Layout manipulation
  525.     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
  526.     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
  527.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  528.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  529.     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
  530.     awful.key({ modkey,           }, "Tab",
  531.         function ()
  532.             awful.client.focus.history.previous()
  533.             if client.focus then
  534.                 client.focus:raise()
  535.             end
  536.         end),
  537.  
  538.     -- Standard program
  539.     awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
  540.     awful.key({ modkey, "Control" }, "r", awesome.restart),
  541.     awful.key({ modkey, "Shift"   }, "q", awesome.quit),
  542.  
  543.     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
  544.     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
  545.     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
  546.     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
  547.     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
  548.     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
  549.     awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
  550.     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
  551.  
  552.     awful.key({ modkey, "Control" }, "n", awful.client.restore),
  553.  
  554.     awful.key({ "Mod1",           }, "Tab",
  555.         function ()
  556.             -- awful.client.focus.history.previous()
  557.             awful.client.focus.byidx(-1)
  558.             if client.focus then
  559.                 client.focus:raise()
  560.             end
  561.         end),
  562.  
  563.     awful.key({ "Mod1", "Shift"   }, "Tab",
  564.         function ()
  565.             -- awful.client.focus.history.previous()
  566.             awful.client.focus.byidx(1)
  567.             if client.focus then
  568.                 client.focus:raise()
  569.             end
  570.         end),
  571.  
  572.     -- MPD
  573.     awful.key({ modkey,           }, "KP_Subtract", function () awful.util.spawn("mpc volume -2") end),
  574.     awful.key({ modkey,           }, "KP_Add", function () awful.util.spawn("mpc volume +2") end),
  575.     awful.key({ modkey,           }, "Next", function () awful.util.spawn("mpc next") end),
  576.     awful.key({ modkey,           }, "Prior", function () awful.util.spawn("mpc prev") end),
  577.     awful.key({ modkey,           }, "Home", function () awful.util.spawn("mpc toggle") end),
  578.     awful.key({ modkey,           }, "End", function () awful.util.spawn("mpc stop") end), 
  579.  
  580.     -- Prompt
  581.     awful.key({ modkey },            "r",     function () mypromptbox[mouse.screen]:run() end),
  582.  
  583.     awful.key({ modkey }, "x",
  584.               function ()
  585.                   awful.prompt.run({ prompt = "Run Lua code: " },
  586.                   mypromptbox[mouse.screen].widget,
  587.                   awful.util.eval, nil,
  588.                   awful.util.getdir("cache") .. "/history_eval")
  589.               end),
  590.     -- Menubar
  591.     awful.key({ modkey }, "p", function() menubar.show() end)
  592. )
  593.  
  594. clientkeys = awful.util.table.join(
  595.     awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
  596.     awful.key({ modkey, "Shift"   }, "c",      function (c) c:kill()                         end),
  597.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
  598.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  599.     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
  600.     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
  601.     awful.key({ modkey,           }, "n",
  602.         function (c)
  603.             -- The client currently has the input focus, so it cannot be
  604.             -- minimized, since minimized clients can't have the focus.
  605.             c.minimized = true
  606.         end),
  607.     awful.key({ modkey,           }, "m",
  608.         function (c)
  609.             c.maximized_horizontal = not c.maximized_horizontal
  610.             c.maximized_vertical   = not c.maximized_vertical
  611.         end)
  612. )
  613.  
  614. -- Compute the maximum number of digit we need, limited to 9
  615. keynumber = 0
  616. for s = 1, screen.count() do
  617.    keynumber = math.min(13, math.max(#tags[s], keynumber))
  618. end
  619.  
  620. -- Bind all key numbers to tags.
  621. -- Be careful: we use keycodes to make it works on any keyboard layout.
  622. -- This should map on the top row of your keyboard, usually 1 to 9.
  623. for i = 1, keynumber do
  624.     globalkeys = awful.util.table.join(globalkeys,
  625.         awful.key({ modkey }, "#" .. i + 9,
  626.                   function ()
  627.                         local screen = mouse.screen
  628.                         if tags[screen][i] then
  629.                             awful.tag.viewonly(tags[screen][i])
  630.                         end
  631.                   end),
  632.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  633.                   function ()
  634.                       local screen = mouse.screen
  635.                       if tags[screen][i] then
  636.                           awful.tag.viewtoggle(tags[screen][i])
  637.                       end
  638.                   end),
  639.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  640.                   function ()
  641.                       if client.focus and tags[client.focus.screen][i] then
  642.                           awful.client.movetotag(tags[client.focus.screen][i])
  643.                       end
  644.                   end),
  645.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  646.                   function ()
  647.                       if client.focus and tags[client.focus.screen][i] then
  648.                           awful.client.toggletag(tags[client.focus.screen][i])
  649.                       end
  650.                   end))
  651. end
  652.  
  653. clientbuttons = awful.util.table.join(
  654.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  655.     awful.button({ modkey }, 1, awful.mouse.client.move),
  656.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  657.  
  658. -- Set keys
  659. root.keys(globalkeys)
  660. -- }}}
  661.  
  662. -- {{{ Rules
  663. awful.rules.rules = {
  664.     -- All clients will match this rule.
  665.     { rule = { },
  666.       properties = { border_width = beautiful.border_width,
  667.                      border_color = beautiful.border_normal,
  668.                      focus = awful.client.focus.filter,
  669.                      keys = clientkeys,
  670.                      buttons = clientbuttons } },
  671.     { rule = { class = "Conky" },
  672. --      properties = { floating = true, sticky = false, ontop = true, focusable = true },
  673.         properties = { floating = true, sticky = false, ontop = true, focusable = true,
  674.         function(z)
  675.             --z:geometry({ width=400, height=800 })
  676.             awful.placement.centered(z,nil)
  677.       end }
  678.      },
  679.     { rule = { class = "MPlayer" },
  680.       properties = { floating = true } },
  681.     { rule = { class = "pinentry" },
  682.       properties = { floating = true } },
  683.     { rule = { class = "gimp" },
  684.       properties = { floating = true } },
  685.     { rule = { class = "Galculator" },
  686.       properties = { floating = true } },
  687. --[[    { rule = { class = "Conky" },
  688.       properties = { tag = tags[1][1], border_width = 0 },
  689.       -- source: http://stackoverflow.com/questions/5120399/setting-windows-layout-for-a-specific-application-in-awesome-wm
  690.         callback = function (c)
  691.             local cl_width = 445    -- width of buddy list window
  692.             local def_left = false  -- default placement. note: you have to restart
  693.                                     -- pidgin for changes to take effect
  694.  
  695.             local scr_area = screen[c.screen].workarea
  696.             local cl_strut = c:struts()
  697.             local geometry = nil
  698.  
  699.             -- adjust scr_area for this client's struts
  700.             if cl_strut ~= nil then
  701.                 if cl_strut.left ~= nil and cl_strut.left > 0 then
  702.                     geometry = {x=scr_area.x-cl_strut.left, y=scr_area.y,
  703.                                 width=cl_strut.left}
  704.                 elseif cl_strut.right ~= nil and cl_strut.right > 0 then
  705.                     geometry = {x=scr_area.x+scr_area.width, y=scr_area.y,
  706.                                 width=cl_strut.right}
  707.                 end
  708.             end
  709.             -- scr_area is unaffected, so we can use the naive coordinates
  710.             if geometry == nil then
  711.                 if def_left then
  712.                     c:struts({left=cl_width, right=0})
  713.                     geometry = {x=scr_area.x, y=scr_area.y,
  714.                                 width=cl_width}
  715.                 else
  716.                     c:struts({right=cl_width, left=0})
  717.                     geometry = {x=scr_area.x+scr_area.width-cl_width, y=scr_area.y,
  718.                                 width=cl_width}
  719.                 end
  720.             end
  721.             c:geometry(geometry)
  722.         end
  723.  
  724.     }, ]]--      
  725.     { rule = { type = "normal", class = "Thunderbird" },
  726.       properties = { tag = tags[1][2],  floating = false } },
  727.     -- Set what should be the Thunderbird password dialog to float
  728.     { rule = { type = "dialog", class = "Thunderbird" },
  729.       properties = { floating = true } },
  730.     { rule = { class = "Pidgin", role = "buddy_list" },
  731.       -- source: http://stackoverflow.com/questions/5120399/setting-windows-layout-for-a-specific-application-in-awesome-wm
  732.         properties = { tag = tags[1][3], floating = true, maximized_vertical = true, maximized_horizontal = false },
  733.         callback = function (c)
  734.             local cl_width = 250    -- width of buddy list window
  735.             local def_left = true   -- default placement. note: you have to restart
  736.                                     -- pidgin for changes to take effect
  737.  
  738.             local scr_area = screen[c.screen].workarea
  739.             local cl_strut = c:struts()
  740.             local geometry = nil
  741.  
  742.             -- adjust scr_area for this client's struts
  743.             if cl_strut ~= nil then
  744.                 if cl_strut.left ~= nil and cl_strut.left > 0 then
  745.                     geometry = {x=scr_area.x-cl_strut.left, y=scr_area.y,
  746.                                 width=cl_strut.left}
  747.                 elseif cl_strut.right ~= nil and cl_strut.right > 0 then
  748.                     geometry = {x=scr_area.x+scr_area.width, y=scr_area.y,
  749.                                 width=cl_strut.right}
  750.                 end
  751.             end
  752.             -- scr_area is unaffected, so we can use the naive coordinates
  753.             if geometry == nil then
  754.                 if def_left then
  755.                     c:struts({left=cl_width, right=0})
  756.                     geometry = {x=scr_area.x, y=scr_area.y,
  757.                                 width=cl_width}
  758.                 else
  759.                     c:struts({right=cl_width, left=0})
  760.                     geometry = {x=scr_area.x+scr_area.width-cl_width, y=scr_area.y,
  761.                                 width=cl_width}
  762.                 end
  763.             end
  764.             c:geometry(geometry)
  765.         end
  766.     },
  767.     { rule = { class = "Firefox" },
  768.       properties = { tag = tags[1][4] } },
  769.     { rule = { class = "Sonata" },
  770.       properties = { tag = tags[1][5] } },
  771.     -- Gnucash must be started with --name gnucashmain for these to work
  772.     { rule = { name = "GnuCash", class = "Gnucash", instance = "gnucashmain" },
  773.       properties = { tag = tags[1][6], floating = true, maximized = false } },
  774.     { rule = { name = "Username and Password", class = "Gnucash", instance = "gnucashmain" },
  775.       properties = { tag = tags[1][6], floating = true } },
  776.     { rule = { name = "postgres://gregory@localhost/gnucash_production - Accounts - GnuCash", class = "Gnucash", instance = "gnucashmain" },
  777.       properties = { tag = tags[1][6], floating = false } },
  778.     { rule = { name = "pgAdmin III" },
  779.       properties = { tag = tags[1][7], floating = false } },
  780.     { rule = { class = "Thunar" },
  781.       properties = { tag = tags[1][10], floating = false, switchtotag = true } },
  782.     { rule = { class = "Thunar", type = "dialog" },
  783.       properties = { tag = tags[1][10], floating = true } },
  784.     { rule = { class = "Zim" },
  785.       properties = { tag = tags[1][13], floating = false, switchtotag = true } },
  786.  
  787. }
  788. -- }}}
  789.  
  790. -- {{{ Signals
  791. -- Signal function to execute when a new client appears.
  792. client.connect_signal("manage", function (c, startup)
  793.     -- Enable sloppy focus
  794.     c:connect_signal("mouse::enter", function(c)
  795.         if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  796.             and awful.client.focus.filter(c) then
  797.             client.focus = c
  798.         end
  799.     end)
  800.  
  801.     if not startup then
  802.         -- Set the windows at the slave,
  803.         -- i.e. put it at the end of others instead of setting it master.
  804.         -- awful.client.setslave(c)
  805.  
  806.         -- Put windows in a smart way, only if they does not set an initial position.
  807.         if not c.size_hints.user_position and not c.size_hints.program_position then
  808.             awful.placement.no_overlap(c)
  809.             awful.placement.no_offscreen(c)
  810.         end
  811.     end
  812.  
  813.     local titlebars_enabled = false
  814.     if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
  815.         -- Widgets that are aligned to the left
  816.         local left_layout = wibox.layout.fixed.horizontal()
  817.         left_layout:add(awful.titlebar.widget.iconwidget(c))
  818.  
  819.         -- Widgets that are aligned to the right
  820.         local right_layout = wibox.layout.fixed.horizontal()
  821.         right_layout:add(awful.titlebar.widget.floatingbutton(c))
  822.         right_layout:add(awful.titlebar.widget.maximizedbutton(c))
  823.         right_layout:add(awful.titlebar.widget.stickybutton(c))
  824.         right_layout:add(awful.titlebar.widget.ontopbutton(c))
  825.         right_layout:add(awful.titlebar.widget.closebutton(c))
  826.  
  827.         -- The title goes in the middle
  828.         local title = awful.titlebar.widget.titlewidget(c)
  829.         title:buttons(awful.util.table.join(
  830.                 awful.button({ }, 1, function()
  831.                     client.focus = c
  832.                     c:raise()
  833.                     awful.mouse.client.move(c)
  834.                 end),
  835.                 awful.button({ }, 3, function()
  836.                     client.focus = c
  837.                     c:raise()
  838.                     awful.mouse.client.resize(c)
  839.                 end)
  840.                 ))
  841.  
  842.         -- Now bring it all together
  843.         local layout = wibox.layout.align.horizontal()
  844.         layout:set_left(left_layout)
  845.         layout:set_right(right_layout)
  846.         layout:set_middle(title)
  847.  
  848.         awful.titlebar(c):set_widget(layout)
  849.     end
  850. end)
  851.  
  852. client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  853. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  854. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment