unixwz0r

rc.lua

Apr 30th, 2016
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 25.51 KB | None | 0 0
  1. --[[
  2.                                      
  3.      BSDBOX Config        
  4.                                      
  5. --]]
  6.  
  7. -- {{{ Required libraries
  8. local gears = require("gears")
  9. local awful = require("awful")
  10. awful.rules = require("awful.rules")
  11. require("awful.autofocus")
  12. local wibox = require("wibox")
  13. local beautiful = require("beautiful")
  14. local naughty = require("naughty")
  15. local menubar = require("menubar")
  16. local vicious = require("vicious")
  17. --local drop      = require("scratchdrop")
  18. --local lain      = require("lain")
  19. -- }}}
  20.  
  21. -- {{{ Error handling
  22. if awesome.startup_errors then
  23.     naughty.notify({ preset = naughty.config.presets.critical,
  24.                      title = "Oops, there were errors during startup!",
  25.                      text = awesome.startup_errors })
  26. end
  27.  
  28. do
  29.     local in_error = false
  30.     awesome.connect_signal("debug::error", function (err)
  31.         if in_error then return end
  32.         in_error = true
  33.  
  34.         naughty.notify({ preset = naughty.config.presets.critical,
  35.                          title = "Oops, an error happened!",
  36.                          text = err })
  37.         in_error = false
  38.     end)
  39. end
  40. -- }}}
  41.  
  42.  
  43.  
  44. -- {{{ Variable definitions
  45. -- Themes define colours, icons, font and wallpapers.
  46. beautiful.init("/usr/home/reaper/.config/awesome/themes/bsdbox/theme.lua")
  47.  
  48. -- This is used later as the default terminal and editor to run.
  49. terminal = "urxvt -e bash"
  50. irssi = "urxvt -e irssi"
  51. mc = "urxvt -e mc"
  52. tmux = "urxvt -e tmux"
  53. firefox = "firefox"
  54. geany = "geany"
  55. filemgr = "thunar"
  56. openshot = "openshot"
  57. lxappearance = "lxappearance"
  58. nitrogen = "nitrogen"
  59. gimp = "gimp"
  60. smplayer = "smplayer"
  61. top = "urxvt -e top"
  62. VIM = "urxvt -e vim"
  63. fileroller = "file-roller"
  64. gmail = "firefox www.gmail.com"
  65. youtube = "firefox www.youtube.com"
  66. lxmusic = "lxmusic"
  67. GParted = "gksu gparted"
  68. virtualbox = "VirtualBox"
  69. pwcview = "pwcview"
  70. steam = "steam"
  71.  
  72. editor = os.getenv("EDITOR") or "nano"
  73. editor_cmd = terminal .. " -e " .. editor
  74.  
  75. -- Default modkey.
  76. -- Usually, Mod4 is the key with a logo between Control and Alt.
  77. -- If you do not like this or do not have such a key,
  78. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  79. -- However, you can use another modifier like Mod1, but it may interact with others.
  80. modkey = "Mod4"
  81.  
  82. -- Table of layouts to cover with awful.layout.inc, order matters.
  83. local layouts =
  84. {
  85.     awful.layout.suit.floating,
  86.     awful.layout.suit.tile,
  87.     awful.layout.suit.tile.left,
  88.     awful.layout.suit.tile.bottom,
  89.     awful.layout.suit.tile.top,
  90.     awful.layout.suit.fair,
  91.     awful.layout.suit.fair.horizontal,
  92.     awful.layout.suit.spiral,
  93.     awful.layout.suit.spiral.dwindle,
  94.     awful.layout.suit.max,
  95.     awful.layout.suit.max.fullscreen,
  96.     awful.layout.suit.magnifier
  97. }
  98. -- }}}
  99.  
  100. -- {{{ Wallpaper
  101. if beautiful.wallpaper then
  102.     for s = 1, screen.count() do
  103.         gears.wallpaper.maximized(beautiful.wallpaper, s, true)
  104.     end
  105. end
  106. -- }}}
  107.  
  108.  -- {{{ Tags
  109.  -- Define a tag table which will hold all screen tags.
  110.  tags = {
  111.    names  = { "main", "net", "irc", "term", "edit", "fm", "vm", "media", "xmms2" },
  112.    layout = { layouts[1], layouts[1], layouts[1], layouts[1], layouts[1],
  113.               layouts[1], layouts[1], layouts[1], layouts[1], layouts[1]
  114.  }}
  115.  for s = 1, screen.count() do
  116.      -- Each screen has its own tag table.
  117.      tags[s] = awful.tag(tags.names, s, tags.layout)
  118.  end
  119.  -- }}}
  120.  
  121. -- {{{ Menu
  122. -- Create a laucher widget and a main menu
  123. myawesomemenu = {
  124.    { "manual", terminal .. " -e man awesome" },
  125.    { "edit config", editor_cmd .. " " .. awesome.conffile },
  126.    { "restart", awesome.restart },
  127.    { "quit", awesome.quit }
  128. }
  129. -- Icons for the Menu
  130. image0 = "/usr/home/reaper/.config/awesome/themes/bsdbox/awesome-icon.png"
  131. image1 = "/usr/home/reaper/.config/awesome/themes/bsdbox/term.png"
  132. image2 = "/usr/home/reaper/.config/awesome/themes/bsdbox/defcon.png"
  133. image3 = "/usr/home/reaper/.config/awesome/themes/bsdbox/file-manager.png"
  134. image4 = "/usr/home/reaper/.config/awesome/themes/bsdbox/geany.png"
  135. image5 = "/usr/home/reaper/.config/awesome/themes/bsdbox/firefox2.png"
  136. image6 = "/usr/home/reaper/.config/awesome/themes/bsdbox/mplayer.png"
  137. image7 = "/usr/home/reaper/.config/awesome/themes/bsdbox/openshot.png"
  138. image8 = "/usr/home/reaper/.config/awesome/themes/bsdbox/gimp.png"
  139. image10 = "/usr/home/reaper/.config/awesome/themes/bsdbox/vim.png"
  140. image11 = "/usr/home/reaper/.config/awesome/themes/bsdbox/gmail.png"
  141. image12 = "/usr/home/reaper/.config/awesome/themes/bsdbox/minitube.png"
  142. image13 = "/usr/home/reaper/.config/awesome/themes/bsdbox/lxappearance.png"
  143. image14 = "/usr/home/reaper/.config/awesome/themes/bsdbox/nitrogen.png"
  144. image15 = "/usr/home/reaper/.config/awesome/themes/bsdbox/file-roller.png"
  145. image16 = "/usr/home/reaper/.config/awesome/themes/bsdbox/lxmusic.png"
  146. image17 = "/usr/home/reaper/.config/awesome/themes/bsdbox/disk.png"
  147. image18 = "/usr/home/reaper/.config/awesome/themes/bsdbox/virtualbox.png"
  148. image19 = "/usr/home/reaper/.config/awesome/themes/bsdbox/camera.png"
  149.  
  150.  
  151. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, image0 },
  152.                                     { "VirtualBox", virtualbox, image18 },
  153.                                     { "URXVT Bash $", terminal, image1 },
  154.                                     { "Irssi", irssi, image2 },
  155.                                     { "FileMgr", filemgr, image3 },
  156.                                     { "File-Roller", fileroller, image15 },
  157.                                     { "Geany", geany, image4 },
  158.                                     { "Vim", VIM, image10 },
  159.                                     { "Firefox", firefox, image5 },
  160.                                     { "LXMusic", lxmusic, image16 },
  161.                                     { "SMplayer", smplayer, image6 },
  162.                                     { "Video Camera", pwcview, image19 },
  163.                                     { "Openshot", openshot, image7 },
  164.                                     { "Gimp", gimp, image8 },
  165.                                     { "LXappearance", lxappearance, image13 },
  166.                                     { "Nitrogen", nitrogen, image14 },
  167.                                     { "GMail", gmail, image11 },
  168.                                     { "Youtube", youtube, image12 },
  169.                                    
  170.                                    
  171.                                   }
  172.                         })
  173.  
  174. mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
  175.                                      menu = mymainmenu })
  176.  
  177. -- Menubar configuration
  178. menubar.utils.terminal = terminal -- Set the terminal for applications that require it
  179. -- }}}
  180.  
  181. -- {{{ Wibox
  182. -- Create a textclock widget
  183. -- Textclock
  184. --clockicon = wibox.widget.imagebox(beautiful.widget_clock)
  185. --mytextclock = awful.widget.textclock("%A %d %B - %H:%M ")
  186.  
  187. -- My Memory Usesage
  188. memuse = wibox.widget.textbox()
  189. memuse:set_align("left")
  190. function memuse_s(widget)
  191.        local status = io.popen('memuse'):read("*all")
  192.        local color = "#C06D44"
  193.        memuse:set_markup("<span color=\"" .. color .. "\">" .. status .. "</span>")
  194. end
  195. memuse_s(memuse)
  196. mytimer = timer({ timeout = 1 })
  197. mytimer:connect_signal("timeout", function () memuse_s(memuse) end)
  198. mytimer:start()
  199.  
  200. -- My Uptime
  201. uptimeawm = wibox.widget.textbox()
  202. uptimeawm:set_align("left")
  203. function uptimeawm_s(widget)
  204.        local status = io.popen('uptimeawm'):read("*all")
  205.        local color = "#C06D44"
  206.        uptimeawm:set_markup("<span color=\"" .. color .. "\">" .. status .. "</span>")
  207. end
  208. uptimeawm_s(uptimeawm)
  209. mytimer = timer({ timeout = 1 })
  210. mytimer:connect_signal("timeout", function () uptimeawm_s(uptimeawm) end)
  211. mytimer:start()
  212.  
  213. -- My Time
  214. timeawm = wibox.widget.textbox()
  215. timeawm:set_align("left")
  216. function timeawm_s(widget)
  217.        local status = io.popen('timeawm'):read("*all")
  218.        local color = "#C06D44"
  219.        timeawm:set_markup("<span color=\"" .. color .. "\">" .. status .. "</span>")
  220. end
  221. timeawm_s(timeawm)
  222. mytimer = timer({ timeout = 1 })
  223. mytimer:connect_signal("timeout", function () timeawm_s(timeawm) end)
  224. mytimer:start()
  225.  
  226. -- Deadbeef Now playing
  227. -- db = wibox.widget.textbox()
  228. -- db:set_align("left")
  229. -- function db_s(widget)
  230. --       local status = io.popen('xmms2 current'):read("*all")
  231. -- local status = io.popen('deadbeef --nowplaying "°|%e-%l|°|%a - %t|°"'):read("*all")
  232. -- local color = "#C06D44"
  233. -- db:set_markup("<span color=\"" .. color .. "\">" .. status .. "</span>")
  234. -- end
  235. -- db_s(db)
  236. -- mytimer = timer({ timeout = 1 })
  237. -- mytimer:connect_signal("timeout", function () db_s(db) end)
  238. -- mytimer:start()
  239.  
  240. -- Mem:
  241. memstat = wibox.widget.textbox(" Mem: ")
  242. -- Up:
  243. upstat = wibox.widget.textbox(" Up: ")
  244. -- -
  245. --seperater
  246. sep = wibox.widget.textbox(" | ")
  247. sep2 = wibox.widget.textbox("|")
  248. -- Spacer
  249. spacer = wibox.widget.textbox(" ")
  250.  
  251.  
  252. -- Create a wibox for each screen and add it
  253. mywibox = {}
  254. mybottomwibox = {}
  255. mypromptbox = {}
  256. mylayoutbox = {}
  257. mytaglist = {}
  258. mytaglist.buttons = awful.util.table.join(
  259.                     awful.button({ }, 1, awful.tag.viewonly),
  260.                     awful.button({ modkey }, 1, awful.client.movetotag),
  261.                     awful.button({ }, 3, awful.tag.viewtoggle),
  262.                     awful.button({ modkey }, 3, awful.client.toggletag),
  263.                     awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
  264.                     awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
  265.                     )
  266. mytasklist = {}
  267. mytasklist.buttons = awful.util.table.join(
  268.                      awful.button({ }, 1, function (c)
  269.                                               if c == client.focus then
  270.                                                   c.minimized = true
  271.                                               else
  272.                                                   -- Without this, the following
  273.                                                   -- :isvisible() makes no sense
  274.                                                   c.minimized = false
  275.                                                   if not c:isvisible() then
  276.                                                       awful.tag.viewonly(c:tags()[1])
  277.                                                   end
  278.                                                   -- This will also un-minimize
  279.                                                   -- the client, if needed
  280.                                                   client.focus = c
  281.                                                   c:raise()
  282.                                               end
  283.                                           end),
  284.                      awful.button({ }, 3, function ()
  285.                                               if instance then
  286.                                                   instance:hide()
  287.                                                   instance = nil
  288.                                               else
  289.                                                   instance = awful.menu.clients({
  290.                                                       theme = { width = 250 }
  291.                                                   })
  292.                                               end
  293.                                           end),
  294.                      awful.button({ }, 4, function ()
  295.                                               awful.client.focus.byidx(1)
  296.                                               if client.focus then client.focus:raise() end
  297.                                           end),
  298.                      awful.button({ }, 5, function ()
  299.                                               awful.client.focus.byidx(-1)
  300.                                               if client.focus then client.focus:raise() end
  301.                                           end))
  302.  
  303. for s = 1, screen.count() do
  304.     -- Create a promptbox for each screen
  305.     mypromptbox[s] = awful.widget.prompt()
  306.     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  307.     -- We need one layoutbox per screen.
  308.     mylayoutbox[s] = awful.widget.layoutbox(s)
  309.     mylayoutbox[s]:buttons(awful.util.table.join(
  310.                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  311.                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  312.                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  313.                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  314.     -- Create a taglist widget
  315.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
  316.  
  317.     -- Create a tasklist widget
  318.     mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
  319.  
  320.     -- Create the wibox
  321.     mywibox[s] = awful.wibox({ position = "top", screen = s })
  322.     --right_layout:add(uptimewidget)
  323.     -- Widgets that are aligned to the left
  324.     local left_layout = wibox.layout.fixed.horizontal()
  325.     left_layout:add(mylauncher)
  326.     left_layout:add(mytaglist[s])
  327.     left_layout:add(sep2)
  328.     left_layout:add(mypromptbox[s])
  329.  
  330.     -- Widgets that are aligned to the right
  331.     local right_layout = wibox.layout.fixed.horizontal()
  332.     if s == 1 then right_layout:add(wibox.widget.systray()) end
  333.     right_layout:add(sep2)
  334.     right_layout:add(memstat)
  335.     right_layout:add(memuse)
  336.     right_layout:add(spacer)
  337.     right_layout:add(upstat)
  338.     right_layout:add(uptimeawm)
  339.     right_layout:add(sep)
  340.     right_layout:add(timeawm)  
  341.     right_layout:add(spacer)
  342.     right_layout:add(mylayoutbox[s])
  343.      
  344.     -- Now bring it all together (with the tasklist in the middle)
  345.     local layout = wibox.layout.align.horizontal()
  346.     layout:set_left(left_layout)
  347.     layout:set_middle(mytasklist[s])
  348.     layout:set_right(right_layout)
  349.  
  350.     mywibox[s]:set_widget(layout)
  351.      
  352.     -- Create the bottom wibox
  353.     -- mybottomwibox[s] = awful.wibox({ position = "bottom", screen = s, border_width = 0, height = 20 })
  354.     -- mybottomwibox[s].visible = false
  355.  
  356.     -- Widgets that are aligned to the bottom left
  357.     -- bottom_left_layout = wibox.layout.fixed.horizontal()
  358.  
  359.     -- bottom_right_layout = wibox.layout.fixed.horizontal()
  360.     -- bottom_right_layout:add(sep2)
  361.     -- if s == 1 then bottom_right_layout:add(wibox.widget.systray()) end
  362.  
  363.     -- bottom_right_layout:add(mytextclock)
  364.  
  365.     -- Now bring it all together (with the tasklist in the middle)
  366.     -- bottom_layout = wibox.layout.align.horizontal()
  367.     -- bottom_layout:set_left(bottom_left_layout)
  368.     -- bottom_layout:set_left(db)
  369.     -- bottom_layout:set_middle(mytasklist[s])
  370.     -- bottom_layout:set_right(bottom_right_layout)
  371.     -- mybottomwibox[s]:set_widget(bottom_layout)
  372.     -- bottom_right_layout:add(mytextclock)
  373.    
  374. end
  375. -- }}}
  376.  
  377. -- {{{ Mouse bindings
  378. root.buttons(awful.util.table.join(
  379.     awful.button({ }, 3, function () mymainmenu:toggle() end),
  380.     awful.button({ }, 4, awful.tag.viewnext),
  381.     awful.button({ }, 5, awful.tag.viewprev)
  382. ))
  383. -- }}}
  384.  
  385. -- {{{ Key bindings
  386. globalkeys = awful.util.table.join(
  387.     awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
  388.     awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
  389.     awful.key({ modkey,           }, "Escape", awful.tag.history.restore),
  390.  
  391.     awful.key({ modkey,           }, "j",
  392.         function ()
  393.             awful.client.focus.byidx( 1)
  394.             if client.focus then client.focus:raise() end
  395.         end),
  396.     awful.key({ modkey,           }, "k",
  397.         function ()
  398.             awful.client.focus.byidx(-1)
  399.             if client.focus then client.focus:raise() end
  400.         end),
  401.     awful.key({ modkey, "Control" }, "space", function () mymainmenu:show() end),
  402.  
  403.     -- Layout manipulation
  404.     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
  405.     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
  406.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  407.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  408.     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
  409.     awful.key({ modkey,           }, "Tab",
  410.         function ()
  411.             awful.client.focus.history.previous()
  412.             if client.focus then
  413.                 client.focus:raise()
  414.             end
  415.         end),
  416.  
  417.     -- Standard program
  418.     awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
  419.     awful.key({ modkey, "Control" }, "r", awesome.restart),
  420.     awful.key({ modkey,           }, "q", awesome.quit),
  421.  
  422.     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incmwfact( 0.05)    end),
  423.     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
  424.     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
  425.     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
  426.     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
  427.     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
  428.     awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
  429.     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
  430.  
  431.     awful.key({ modkey, "Control" }, "n", awful.client.restore),
  432.  
  433.     -- My Key bindings
  434.     awful.key({ modkey,           }, "t", function () awful.util.spawn(terminal) end),
  435.     awful.key({ modkey,           }, "f", function () awful.util.spawn(filemgr) end),
  436.     awful.key({ modkey,           }, "i", function () awful.util.spawn(irssi) end),
  437.     awful.key({ modkey,           }, "e", function () awful.util.spawn(geany) end),
  438.     awful.key({ modkey,           }, "g", function () awful.util.spawn(gimp) end),
  439.     awful.key({ modkey,           }, "w", function () awful.util.spawn(firefox) end),
  440.     awful.key({ modkey,           }, "l", function () awful.util.spawn(lxappearance) end),
  441.     awful.key({ modkey,           }, "n", function () awful.util.spawn(nitrogen) end),
  442.     awful.key({ modkey,           }, "a", function () awful.util.spawn(lxmusic) end),
  443.     awful.key({ modkey,           }, "o", function () awful.util.spawn(openshot) end),
  444.     awful.key({ modkey,           }, "s", function () awful.util.spawn(steam) end),
  445.     -- Prompt
  446.     awful.key({ modkey },            "r",     function () mypromptbox[mouse.screen]:run() end),
  447.  
  448.     awful.key({ modkey }, "x",
  449.               function ()
  450.                   awful.prompt.run({ prompt = "Run Lua code: " },
  451.                   mypromptbox[mouse.screen].widget,
  452.                   awful.util.eval, nil,
  453.                   awful.util.getdir("cache") .. "/history_eval")
  454.               end),
  455.     -- Menubar
  456.     awful.key({ modkey }, "p", function() menubar.show() end)
  457. )
  458.  
  459. clientkeys = awful.util.table.join(
  460.     awful.key({ modkey,           }, "z",      function (c) c.fullscreen = not c.fullscreen  end),
  461.     awful.key({ modkey,           }, "c",      function (c) c:kill()                         end),
  462.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
  463.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  464.     awful.key({ modkey, "Control" }, "o",      awful.client.movetoscreen                        ),
  465.     awful.key({ modkey, "Control" }, "t",      function (c) c.ontop = not c.ontop            end),
  466.     awful.key({ modkey, "Control" }, "n",
  467.         function (c)
  468.             -- The client currently has the input focus, so it cannot be
  469.             -- minimized, since minimized clients can't have the focus.
  470.             c.minimized = true
  471.         end),
  472.     awful.key({ modkey,           }, "m",
  473.         function (c)
  474.             c.maximized_horizontal = not c.maximized_horizontal
  475.             c.maximized_vertical   = not c.maximized_vertical
  476.         end)
  477. )
  478.  
  479. -- Bind all key numbers to tags.
  480. -- Be careful: we use keycodes to make it works on any keyboard layout.
  481. -- This should map on the top row of your keyboard, usually 1 to 9.
  482. for i = 1, 9 do
  483.     globalkeys = awful.util.table.join(globalkeys,
  484.         -- View tag only.
  485.         awful.key({ modkey }, "#" .. i + 9,
  486.                   function ()
  487.                         local screen = mouse.screen
  488.                         local tag = awful.tag.gettags(screen)[i]
  489.                         if tag then
  490.                            awful.tag.viewonly(tag)
  491.                         end
  492.                   end),
  493.         -- Toggle tag.
  494.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  495.                   function ()
  496.                       local screen = mouse.screen
  497.                       local tag = awful.tag.gettags(screen)[i]
  498.                       if tag then
  499.                          awful.tag.viewtoggle(tag)
  500.                       end
  501.                   end),
  502.         -- Move client to tag.
  503.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  504.                   function ()
  505.                       if client.focus then
  506.                           local tag = awful.tag.gettags(client.focus.screen)[i]
  507.                           if tag then
  508.                               awful.client.movetotag(tag)
  509.                           end
  510.                      end
  511.                   end),
  512.         -- Toggle tag.
  513.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  514.                   function ()
  515.                       if client.focus then
  516.                           local tag = awful.tag.gettags(client.focus.screen)[i]
  517.                           if tag then
  518.                               awful.client.toggletag(tag)
  519.                           end
  520.                       end
  521.                   end))
  522. end
  523.  
  524. clientbuttons = awful.util.table.join(
  525.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  526.     awful.button({ modkey }, 1, awful.mouse.client.move),
  527.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  528.  
  529. -- Set keys
  530. root.keys(globalkeys)
  531. -- }}}
  532.  
  533. -- {{{ Rules
  534. -- Rules to apply to new clients (through the "manage" signal).
  535. awful.rules.rules = {
  536.     -- All clients will match this rule.
  537.     { rule = { },
  538.       properties = { border_width = beautiful.border_width,
  539.                      border_color = beautiful.border_normal,
  540.                      focus = awful.client.focus.filter,
  541.                      raise = true,
  542.                      keys = clientkeys,
  543.                      buttons = clientbuttons } },
  544.     { rule = { class = "MPlayer" },
  545.       properties = { floating = true } },
  546.     { rule = { class = "pinentry" },
  547.       properties = { floating = true } },
  548.     { rule = { class = "gimp" },
  549.       properties = { floating = true } },
  550.     -- Set Firefox to always map on tags number 2 of screen 1.
  551.     -- { rule = { class = "Firefox" },
  552.     --   properties = { tag = tags[1][2] } },
  553. }
  554. -- }}}
  555.  
  556. -- {{{ Signals
  557. -- Signal function to execute when a new client appears.
  558. client.connect_signal("manage", function (c, startup)
  559.     -- Enable sloppy focus
  560.     c:connect_signal("mouse::enter", function(c)
  561.         if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  562.             and awful.client.focus.filter(c) then
  563.             client.focus = c
  564.         end
  565.     end)
  566.  
  567.     if not startup then
  568.         -- Set the windows at the slave,
  569.         -- i.e. put it at the end of others instead of setting it master.
  570.         -- awful.client.setslave(c)
  571.  
  572.         -- Put windows in a smart way, only if they does not set an initial position.
  573.         if not c.size_hints.user_position and not c.size_hints.program_position then
  574.             awful.placement.no_overlap(c)
  575.             awful.placement.no_offscreen(c)
  576.         end
  577.     end
  578.  
  579.     local titlebars_enabled = true
  580.     if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
  581.         -- buttons for the titlebar
  582.         local buttons = awful.util.table.join(
  583.                 awful.button({ }, 1, function()
  584.                     client.focus = c
  585.                     c:raise()
  586.                     awful.mouse.client.move(c)
  587.                 end),
  588.                 awful.button({ }, 3, function()
  589.                     client.focus = c
  590.                     c:raise()
  591.                     awful.mouse.client.resize(c)
  592.                 end)
  593.                 )
  594.  
  595.         -- Widgets that are aligned to the left
  596.         local left_layout = wibox.layout.fixed.horizontal()
  597.         left_layout:add(awful.titlebar.widget.closebutton(c))
  598.         left_layout:add(awful.titlebar.widget.maximizedbutton(c))
  599.            
  600.         -- Widgets that are aligned to the right
  601.         local right_layout = wibox.layout.fixed.horizontal()
  602.         right_layout:add(awful.titlebar.widget.floatingbutton(c))
  603.         right_layout:add(awful.titlebar.widget.minimizebutton(c))
  604.        
  605.         -- The title goes in the middle
  606.         local middle_layout = wibox.layout.flex.horizontal()
  607.         local title = awful.titlebar.widget.titlewidget(c)
  608.         title:set_align("center")
  609.         middle_layout:add(title)
  610.         middle_layout:buttons(buttons)
  611.  
  612.         -- Now bring it all together
  613.         local layout = wibox.layout.align.horizontal()
  614.         layout:set_left(left_layout)
  615.         layout:set_right(right_layout)
  616.         layout:set_middle(middle_layout)
  617.  
  618.         awful.titlebar(c):set_widget(layout)
  619.     end
  620. end)
  621.  
  622. client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  623. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  624. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment