Advertisement
Guest User

Untitled

a guest
Nov 4th, 2013
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 24.63 KB | None | 0 0
  1. --[[
  2.                                      
  3.      Blackburn Awesome WM config 2.0
  4.      github.com/copycat-killer      
  5.                                      
  6. --]]
  7.  
  8. -- {{{ Required libraries
  9. local gears     = require("gears")
  10. local awful     = require("awful")
  11. awful.rules     = require("awful.rules")
  12. require("awful.autofocus")
  13. local wibox     = require("wibox")
  14. local beautiful = require("beautiful")
  15. local naughty   = require("naughty")
  16. local drop      = require("scratchdrop")
  17. local lain      = require("lain")
  18. -- }}}
  19.  
  20. -- {{{ Error handling
  21. if awesome.startup_errors then
  22.     naughty.notify({ preset = naughty.config.presets.critical,
  23.                      title = "Oops, there were errors during startup!",
  24.                      text = awesome.startup_errors })
  25. end
  26.  
  27. do
  28.     local in_error = false
  29.     awesome.connect_signal("debug::error", function (err)
  30.         if in_error then return end
  31.         in_error = true
  32.  
  33.         naughty.notify({ preset = naughty.config.presets.critical,
  34.                          title = "Oops, an error happened!",
  35.                          text = err })
  36.         in_error = false
  37.     end)
  38. end
  39. -- }}}
  40.  
  41. -- {{{ Autostart applications
  42. function run_once(cmd)
  43.   findme = cmd
  44.   firstspace = cmd:find(" ")
  45.   if firstspace then
  46.      findme = cmd:sub(0, firstspace-1)
  47.   end
  48.   awful.util.spawn_with_shell("pgrep -u $USER -x " .. findme .. " > /dev/null || (" .. cmd .. ")")
  49. end
  50.  
  51. run_once("unclutter -idle 10")
  52. run_once("urxvtd")
  53. run_once("xrdb -merge ~/.Xresources")
  54. run_once("setxkbmap pl")
  55. run_once("mpd")
  56. run_once("/usr/bin/xscreensaver -no-splash &")
  57. run_once("/home/rlk120/.scripts/lightson.sh &")
  58. -- }}}
  59.  
  60. -- {{{ Variable definitions
  61. -- localization
  62. os.setlocale(os.getenv("LANG"))
  63.  
  64. -- home path
  65. homedir = os.getenv("HOME") .. "/.config/awesome/"
  66.  
  67. -- beautiful init
  68. beautiful.init(awful.util.getdir("config") .. "/themes/blackburn/theme.lua")
  69.  
  70. -- common
  71. modkey     = "Mod4"
  72. altkey     = "Mod1"
  73. terminal   = "urxvtc" or "xterm"
  74. editor     = os.getenv("EDITOR") or "nano" or "vi"
  75. editor_cmd = terminal .. " -e " .. editor
  76.  
  77. -- user defined
  78. browser    = "dwb"
  79. gui_editor = "gvim"
  80. graphics   = "gimp"
  81. musicplr = terminal .. " -g 130x34-320+16 -e ncmpcpp "
  82. tasks = terminal .. " -e htop "
  83. explorer = "spacefm"
  84.  
  85. local layouts = {
  86.     awful.layout.suit.floating,
  87.     lain.layout.uselesstile,
  88.     awful.layout.suit.fair,
  89.     lain.layout.uselesstile.left,
  90.     lain.layout.uselesstile.top
  91. }
  92. -- }}}
  93.  
  94. -- {{{ Tags
  95. tags = {
  96.        names = { "web", "term", "docs", "media", "down"},
  97.        layout = { layouts[1], layouts[3], layouts[2], layouts[1], layouts[5] }
  98.        }
  99. for s = 1, screen.count() do
  100.    tags[s] = awful.tag(tags.names, s, tags.layout)
  101. end
  102. -- }}}
  103.  
  104. -- {{{ Wallpaper
  105. if beautiful.wallpaper then
  106.     for s = 1, screen.count() do
  107.         gears.wallpaper.maximized(beautiful.wallpaper, s, true)
  108.     end
  109. end
  110. -- }}}
  111. -- {{{ Menu
  112. require("freedesktop/freedesktop")
  113. -- }}}
  114.  
  115. -- {{{ Wibox
  116. markup = lain.util.markup
  117. gray   = "#9E9C9A"
  118.  
  119. -- Textclock
  120. mytextclock = awful.widget.textclock(" %H:%M ")
  121.  
  122. -- Calendar
  123. lain.widgets.calendar:attach(mytextclock)
  124.  
  125. -- Mail IMAP check
  126. -- commented because it needs to be set before use
  127. mailwidget = lain.widgets.imap({
  128.     is_plain = true,
  129.     timeout  = 5,
  130.     server   = "imap.gmail.com",
  131.     mail     = "xorgx3@gmail.com",
  132.     password = "tkoK7WR4ejshL6fz",
  133.     settings = function()
  134.         mail  = ""
  135.         count = ""
  136.  
  137.         if mailcount > 0 then
  138.             mail = "Mail: "
  139.             count = mailcount .. " "
  140.         end
  141.  
  142.         widget:set_markup(markup(gray, mail) .. count)
  143.     end
  144. })
  145.  
  146.  
  147. -- MPD
  148. mpdwidget = lain.widgets.mpd({
  149.     settings = function()
  150.         artist = mpd_now.artist .. " "
  151.         title  = mpd_now.title  .. "  "
  152.  
  153.         if mpd_now.state == "pause" then
  154.             artist = "mpd "
  155.             title  = "paused  "
  156.         elseif mpd_now.state == "stop" then
  157.             artist = ""
  158.             title  = ""
  159.         end
  160.  
  161.         widget:set_markup(markup(gray, artist) .. title)
  162.     end
  163. })
  164. mpdwidget:buttons(awful.util.table.join(awful.button({ }, 1, function () awful.util.spawn_with_shell(musicplr) end)))
  165.  
  166. -- /home fs
  167. fshome = lain.widgets.fs({
  168.     partition = "/home",
  169.     settings  = function()
  170.         fs_header = ""
  171.         fs_p      = ""
  172.  
  173.         if fs_now.used >= 90 then
  174.             fs_header = " Hdd "
  175.             fs_p      = fs_now.used
  176.         end
  177.  
  178.         widget:set_markup(markup(gray, fs_header) .. fs_p)
  179.     end
  180. })
  181.  
  182. -- Battery
  183. batwidget = lain.widgets.bat({
  184.     settings = function()
  185.         bat_header = " Bat "
  186.         bat_p      = bat_now.perc .. " "
  187.  
  188.         if bat_now.status == "Not present" then
  189.             bat_header = ""
  190.             bat_p      = ""
  191.         end
  192.  
  193.         widget:set_markup(markup(gray, bat_header) .. bat_p)
  194.     end
  195. })
  196.  
  197. -- ALSA volume
  198. volumewidget = lain.widgets.alsa({
  199.     settings = function()
  200.         header = " Vol "
  201.         level  = volume_now.level
  202.  
  203.         if volume_now.status == "off" then
  204.             level = "Mute "
  205.         else
  206.             level = level .. " "
  207.         end
  208.  
  209.         widget:set_markup(markup(gray, header) .. level)
  210.     end
  211. })
  212.  
  213. -- Weather
  214. yawn = lain.widgets.yawn(523920,
  215. {
  216.     settings = function()
  217.         widget:set_markup(" " .. units .. " ")
  218.     end
  219. })
  220.  
  221. -- Separators
  222. first = wibox.widget.textbox('<span font="Tamsyn 4"> </span>')
  223. arrl_pre = wibox.widget.imagebox()
  224. arrl_pre:set_image(beautiful.arrl_lr_pre)
  225. arrl_post = wibox.widget.imagebox()
  226. arrl_post:set_image(beautiful.arrl_lr_post)
  227.  
  228. -- Create a wibox for each screen and add it
  229. mywibox = {}
  230. mypromptbox = {}
  231. mylayoutbox = {}
  232. mytaglist = {}
  233. mytaglist.buttons = awful.util.table.join(
  234.                     awful.button({ }, 1, awful.tag.viewonly),
  235.                     awful.button({ modkey }, 1, awful.client.movetotag),
  236.                     awful.button({ }, 3, awful.tag.viewtoggle),
  237.                     awful.button({ modkey }, 3, awful.client.toggletag),
  238.                     awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
  239.                     awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
  240.                     )
  241. mytasklist = {}
  242. mytasklist.buttons = awful.util.table.join(
  243.                      awful.button({ }, 1, function (c)
  244.                                               if c == client.focus then
  245.                                                   c.minimized = true
  246.                                               else
  247.                                                   -- Without this, the following
  248.                                                   -- :isvisible() makes no sense
  249.                                                   c.minimized = false
  250.                                                   if not c:isvisible() then
  251.                                                       awful.tag.viewonly(c:tags()[1])
  252.                                                   end
  253.                                                   -- This will also un-minimize
  254.                                                   -- the client, if needed
  255.                                                   client.focus = c
  256.                                                   c:raise()
  257.                                               end
  258.                                           end),
  259.                      awful.button({ }, 3, function ()
  260.                                               if instance then
  261.                                                   instance:hide()
  262.                                                   instance = nil
  263.                                               else
  264.                                                   instance = awful.menu.clients({ width=250 })
  265.                                               end
  266.                                           end),
  267.                      awful.button({ }, 4, function ()
  268.                                               awful.client.focus.byidx(1)
  269.                                               if client.focus then client.focus:raise() end
  270.                                           end),
  271.                      awful.button({ }, 5, function ()
  272.                                               awful.client.focus.byidx(-1)
  273.                                               if client.focus then client.focus:raise() end
  274.                                           end))
  275.  
  276. for s = 1, screen.count() do
  277.     -- Create a promptbox for each screen
  278.     mypromptbox[s] = awful.widget.prompt()
  279.     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
  280.     -- We need one layoutbox per screen.
  281.     mylayoutbox[s] = awful.widget.layoutbox(s)
  282.     mylayoutbox[s]:buttons(awful.util.table.join(
  283.                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
  284.                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
  285.                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
  286.                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
  287.     -- Create a taglist widget
  288.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
  289.  
  290.     -- Create a tasklist widget
  291.     mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
  292.  
  293.     -- Create the wibox
  294.     mywibox[s] = awful.wibox({ position = "top", screen = s, height = 18 })
  295.  
  296.     -- Widgets that are aligned to the left
  297.     local left_layout = wibox.layout.fixed.horizontal()
  298.     left_layout:add(first)
  299.     left_layout:add(mytaglist[s])
  300.     left_layout:add(arrl_pre)
  301.     left_layout:add(mylayoutbox[s])
  302.     left_layout:add(arrl_post)
  303.     left_layout:add(mypromptbox[s])
  304.     left_layout:add(first)
  305.  
  306.     -- Widgets that are aligned to the right
  307.     local right_layout = wibox.layout.fixed.horizontal()
  308.     if s == 1 then right_layout:add(wibox.widget.systray()) end
  309.     right_layout:add(first)
  310.     right_layout:add(mpdwidget)
  311.     right_layout:add(mailwidget)
  312.     right_layout:add(yawn.icon)
  313.     right_layout:add(yawn.widget)
  314.     right_layout:add(fshome)
  315.     --right_layout:add(batwidget)
  316.     right_layout:add(volumewidget)
  317.     right_layout:add(mytextclock)
  318.  
  319.     -- Now bring it all together (with the tasklist in the middle)
  320.     local layout = wibox.layout.align.horizontal()
  321.     layout:set_left(left_layout)
  322.     layout:set_middle(mytasklist[s])
  323.     layout:set_right(right_layout)
  324.  
  325.     mywibox[s]:set_widget(layout)
  326.  
  327.     -- Set proper background, instead of beautiful.bg_normal
  328.     mywibox[s]:set_bg(beautiful.topbar_path .. screen[mouse.screen].workarea.width .. ".png")
  329. end
  330. -- }}}
  331.  
  332. -- {{{ Mouse bindings
  333. root.buttons(awful.util.table.join(
  334.     awful.button({ }, 3, function () mymainmenu:toggle() end),
  335.     awful.button({ }, 4, awful.tag.viewnext),
  336.     awful.button({ }, 5, awful.tag.viewprev)
  337. ))
  338. -- }}}
  339.  
  340. -- {{{ Key bindings
  341. globalkeys = awful.util.table.join(
  342.     -- Take a screenshot
  343.     -- https://github.com/copycat-killer/dots/blob/master/bin/screenshot
  344.     awful.key({  }, "#99", function() os.execute("screenshot") end),
  345.  
  346.     -- Tag browsing
  347.     awful.key({ modkey }, "Left",   awful.tag.viewprev       ),
  348.     awful.key({ modkey }, "Right",  awful.tag.viewnext       ),
  349.     awful.key({ modkey }, "Escape", awful.tag.history.restore),
  350.  
  351.     -- Non-empty tag browsing
  352.     awful.key({ altkey }, "Left", function () lain.util.tag_view_nonempty(-1) end),
  353.     awful.key({ altkey }, "Right", function () lain.util.tag_view_nonempty(1) end),
  354.  
  355.     -- Default client focus
  356.     awful.key({ altkey }, "k",
  357.         function ()
  358.             awful.client.focus.byidx( 1)
  359.             if client.focus then client.focus:raise() end
  360.         end),
  361.     awful.key({ altkey }, "j",
  362.         function ()
  363.             awful.client.focus.byidx(-1)
  364.             if client.focus then client.focus:raise() end
  365.         end),
  366.  
  367.     -- By direction client focus
  368.     awful.key({ modkey }, "j",
  369.         function()
  370.             awful.client.focus.bydirection("down")
  371.             if client.focus then client.focus:raise() end
  372.         end),
  373.     awful.key({ modkey }, "k",
  374.         function()
  375.             awful.client.focus.bydirection("up")
  376.             if client.focus then client.focus:raise() end
  377.         end),
  378.     awful.key({ modkey }, "h",
  379.         function()
  380.             awful.client.focus.bydirection("left")
  381.             if client.focus then client.focus:raise() end
  382.         end),
  383.     awful.key({ modkey }, "l",
  384.         function()
  385.             awful.client.focus.bydirection("right")
  386.             if client.focus then client.focus:raise() end
  387.         end),
  388.  
  389.     -- Show Menu
  390.     awful.key({ modkey }, "w",
  391.         function ()
  392.             mymainmenu:show({ keygrabber = true })
  393.         end),
  394.  
  395.     -- Show/Hide Wibox
  396.     awful.key({ modkey }, "b", function ()
  397.         mywibox[mouse.screen].visible = not mywibox[mouse.screen].visible
  398.     end),
  399.  
  400.     -- On the fly useless gaps change
  401.     awful.key({ altkey, "Control" }, "+", function () lain.util.useless_gaps_resize(1) end),
  402.     awful.key({ altkey, "Control" }, "-", function () lain.util.useless_gaps_resize(-1) end),
  403.  
  404.     -- Layout manipulation
  405.     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
  406.     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
  407.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
  408.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
  409.     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
  410.     awful.key({ modkey,           }, "Tab",
  411.         function ()
  412.             awful.client.focus.history.previous()
  413.             if client.focus then
  414.                 client.focus:raise()
  415.             end
  416.         end),
  417.     awful.key({ altkey, "Shift"   }, "l",      function () awful.tag.incmwfact( 0.05)     end),
  418.     awful.key({ altkey, "Shift"   }, "h",      function () awful.tag.incmwfact(-0.05)     end),
  419.     awful.key({ modkey, "Shift"   }, "l",      function () awful.tag.incnmaster(-1)       end),
  420.     awful.key({ modkey, "Shift"   }, "h",      function () awful.tag.incnmaster( 1)       end),
  421.     awful.key({ modkey, "Control" }, "l",      function () awful.tag.incncol(-1)          end),
  422.     awful.key({ modkey, "Control" }, "h",      function () awful.tag.incncol( 1)          end),
  423.     awful.key({ modkey,           }, "space",  function () awful.layout.inc(layouts,  1)  end),
  424.     awful.key({ modkey, "Shift"   }, "space",  function () awful.layout.inc(layouts, -1)  end),
  425.     awful.key({ modkey, "Control" }, "n",      awful.client.restore),
  426.  
  427.     -- Standard program
  428.     awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
  429.     awful.key({ altkey, modkey, "Control" }, "r",      awesome.restart),
  430.     awful.key({ modkey, "Shift"   }, "q",      awesome.quit),
  431.  
  432.     -- Dropdown terminal
  433.    -- awful.key({ modkey,             }, "z",      function () drop(terminal) end),
  434.  
  435.     -- Widgets popups
  436.     awful.key({ altkey,           }, "c",      function () lain.widgets.calendar:show(7) end),
  437.     awful.key({ altkey,           }, "h",      function () fshome.show(7) end),
  438.     awful.key({ altkey,           }, "w",      function () yawn.show(7) end),
  439.  
  440.     -- ALSA volume control
  441.     --[[awful.key({ altkey }, "Up",
  442.         function ()
  443.             awful.util.spawn("amixer -q set Master 1%+")
  444.             volumewidget.update()
  445.         end),
  446.     awful.key({ altkey }, "Down",
  447.         function ()
  448.             awful.util.spawn("amixer -q set Master 1%-")
  449.             volumewidget.update()
  450.         end),
  451.     awful.key({ altkey }, "m",
  452.         function ()
  453.             awful.util.spawn("amixer -q set Master playback toggle")
  454.             volumewidget.update()
  455.         end),
  456.     awful.key({ altkey, "Control" }, "m",
  457.         function ()
  458.             awful.util.spawn("amixer -q set Master playback 100%")
  459.             volumewidget.update()
  460.         end),]]
  461.      awful.key({ }, "XF86AudioRaiseVolume", function ()
  462.                                        awful.util.spawn("amixer -q set Master 2+ unmute", false )
  463.                                        volumewidget.update()
  464.                                    end),
  465.     awful.key({ }, "XF86AudioLowerVolume", function ()
  466.                                        awful.util.spawn("amixer -q set Master 2- unmute", false )
  467.                                        volumewidget.update()
  468.                                      end),
  469.     awful.key({ }, "XF86AudioMute", function ()
  470.                                        awful.util.spawn("amixer set Master toggle", false )
  471.                                        volumewidget.update()
  472.                                      end),
  473.  
  474.     -- MPD control
  475.     awful.key({ }, "#172",
  476.         function ()
  477.             awful.util.spawn_with_shell("mpc toggle || ncmpcpp toggle || ncmpc toggle || pms toggle")
  478.             mpdwidget.update()
  479.         end),
  480.     awful.key({}, "#174",
  481.         function ()
  482.             awful.util.spawn_with_shell("mpc stop || ncmpcpp stop || ncmpc stop || pms stop")
  483.             mpdwidget.update()
  484.         end),
  485.     awful.key({}, "#173",
  486.         function ()
  487.             awful.util.spawn_with_shell("mpc prev || ncmpcpp prev || ncmpc prev || pms prev")
  488.             mpdwidget.update()
  489.         end),
  490.     awful.key({}, "#171",
  491.         function ()
  492.             awful.util.spawn_with_shell("mpc next || ncmpcpp next || ncmpc next || pms next")
  493.             mpdwidget.update()
  494.         end),
  495.  
  496.     -- Copy to clipboard
  497.     awful.key({ modkey }, "c", function () os.execute("xsel -p -o | xsel -i -b") end),
  498.  
  499.     -- User programs
  500.     awful.key({ modkey }, "q", function () awful.util.spawn(browser) end),
  501.     awful.key({ modkey }, "s", function () awful.util.spawn(gui_editor) end),
  502.     awful.key({ modkey }, "g", function () awful.util.spawn(graphics) end),
  503.     awful.key({ }, "#148", function () awful.util.spawn("speedcrunch", false) end),
  504.     awful.key({ modkey }, "e", function () awful.util.spawn(explorer) end),
  505.    
  506.     --shutdown
  507.     awful.key({}, "#150", function () awful.util.spawn("systemctl suspend", false) end),
  508.     awful.key({ modkey, "Control"  }, "#22", function () awful.util.spawn("systemctl shutdown", false) end),
  509.     awful.key({ modkey, "Control" }, "r", function () awful.util.spawn("systemctl reboot", false) end),
  510.  
  511.     -- Prompt
  512.     awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
  513.     awful.key({ modkey }, "x",
  514.               function ()
  515.                   awful.prompt.run({ prompt = "Run Lua code: " },
  516.                   mypromptbox[mouse.screen].widget,
  517.                   awful.util.eval, nil,
  518.                   awful.util.getdir("cache") .. "/history_eval")
  519.               end)
  520. )
  521.  
  522. clientkeys = awful.util.table.join(
  523.     awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
  524.     awful.key({ altkey   }, "q",      function (c) c:kill()                         end),
  525.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
  526.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
  527.     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
  528.     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
  529.     awful.key({ modkey,           }, "n",
  530.         function (c)
  531.             -- The client currently has the input focus, so it cannot be
  532.             -- minimized, since minimized clients can't have the focus.
  533.             c.minimized = true
  534.         end),
  535.     awful.key({ modkey,           }, "m",
  536.         function (c)
  537.             c.maximized_horizontal = not c.maximized_horizontal
  538.             c.maximized_vertical   = not c.maximized_vertical
  539.         end)
  540. )
  541.  
  542. -- Bind all key numbers to tags.
  543. -- Be careful: we use keycodes to make it works on any keyboard layout.
  544. -- This should map on the top row of your keyboard, usually 1 to 9.
  545. for i = 1, 9 do
  546.     globalkeys = awful.util.table.join(globalkeys,
  547.         awful.key({ modkey }, "#" .. i + 9,
  548.                   function ()
  549.                         local screen = mouse.screen
  550.                         local tag = awful.tag.gettags(screen)[i]
  551.                         if tag then
  552.                            awful.tag.viewonly(tag)
  553.                         end
  554.                   end),
  555.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  556.                   function ()
  557.                       local screen = mouse.screen
  558.                       local tag = awful.tag.gettags(screen)[i]
  559.                       if tag then
  560.                          awful.tag.viewtoggle(tag)
  561.                       end
  562.                   end),
  563.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  564.                   function ()
  565.                       local tag = awful.tag.gettags(client.focus.screen)[i]
  566.                       if client.focus and tag then
  567.                           awful.client.movetotag(tag)
  568.                      end
  569.                   end),
  570.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  571.                   function ()
  572.                       local tag = awful.tag.gettags(client.focus.screen)[i]
  573.                       if client.focus and tag then
  574.                           awful.client.toggletag(tag)
  575.                       end
  576.                   end))
  577. end
  578.  
  579. clientbuttons = awful.util.table.join(
  580.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  581.     awful.button({ modkey }, 1, awful.mouse.client.move),
  582.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  583.  
  584. -- Set keys
  585. root.keys(globalkeys)
  586. -- }}}
  587.  
  588. -- {{{ Rules
  589. awful.rules.rules = {
  590.     -- All clients will match this rule.
  591.     { rule = { },
  592.       properties = { border_width = beautiful.border_width,
  593.                      border_color = beautiful.border_normal,
  594.                      focus = awful.client.focus.filter,
  595.                      keys = clientkeys,
  596.                      buttons = clientbuttons,
  597.                        size_hints_honor = false } },
  598.     { rule = { class = "URxvt" },
  599.           properties = { opacity = 0.99 } },
  600.  
  601.     { rule = { class = "MPlayer" },
  602.           properties = { floating = true } },
  603.  
  604.     { rule = { class = "Dwb" },
  605.           properties = { tag = tags[1][1] } },
  606.  
  607.     { rule = { class = "Iron" },
  608.           properties = { tag = tags[1][1] } },
  609.  
  610.     { rule = { instance = "plugin-container" },
  611.           properties = { tag = tags[1][1] } },
  612.  
  613.       { rule = { class = "Gimp" },
  614.             properties = { tag = tags[1][4] } },
  615.  
  616.     { rule = { class = "Gimp", role = "gimp-image-window" },
  617.           properties = { maximized_horizontal = true,
  618.                          maximized_vertical = true } },
  619. }
  620. -- }}}
  621.  
  622. -- {{{ Signals
  623. -- Signal function to execute when a new client appears.
  624. client.connect_signal("manage", function (c, startup)
  625.     -- Enable sloppy focus
  626.     c:connect_signal("mouse::enter", function(c)
  627.         if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  628.             and awful.client.focus.filter(c) then
  629.             client.focus = c
  630.         end
  631.     end)
  632.  
  633.     if not startup and not c.size_hints.user_position
  634.        and not c.size_hints.program_position then
  635.         awful.placement.no_overlap(c)
  636.         awful.placement.no_offscreen(c)
  637.     end
  638. end)
  639.  
  640. -- No border for maximized clients
  641. client.connect_signal("focus",
  642.     function(c)
  643.         if c.maximized_horizontal == true and c.maximized_vertical == true then
  644.             c.border_width = 0
  645.             c.border_color = beautiful.border_normal
  646.         else
  647.             c.border_width = beautiful.border_width
  648.             c.border_color = beautiful.border_focus
  649.         end
  650.     end)
  651. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  652. -- }}}
  653.  
  654. -- {{{ Arrange signal handler
  655. for s = 1, screen.count() do screen[s]:connect_signal("arrange", function ()
  656.         local clients = awful.client.visible(s)
  657.         local layout  = awful.layout.getname(awful.layout.get(s))
  658.  
  659.         if #clients > 0 then -- Fine grained borders and floaters control
  660.             for _, c in pairs(clients) do -- Floaters always have borders
  661.                 if awful.client.floating.get(c) or layout == "floating" then
  662.                     c.border_width = beautiful.border_width
  663.  
  664.                 -- No borders with only one visible client
  665.                 elseif #clients == 1 or layout == "max" then
  666.                     clients[1].border_width = 0
  667.                     awful.client.moveresize(0, 0, 2, 2, clients[1])
  668.                 else
  669.                     c.border_width = beautiful.border_width
  670.                 end
  671.             end
  672.         end
  673.       end)
  674. end
  675. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement