Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 20.49 KB | None | 0 0
  1. -- Modules
  2.  
  3. -- Standard modules
  4. gears = require("gears")
  5. awful = require("awful")
  6. awful.rules = require("awful.rules")
  7. awful.autofocus = require("awful.autofocus")
  8. -- Widget box
  9. wibox = require("wibox")
  10. -- Theming
  11. beautiful = require("beautiful")
  12. -- Notification
  13. naughty = require("naughty")
  14. -- Menubar: dmenu-like launcher
  15. --menubar = require("menubar")
  16.  
  17. -- Handle runtime errors after startup
  18. do
  19.     local in_error = false
  20.     awesome.connect_signal("debug::error",
  21.         function (err)
  22.             -- Make sure we don't go into an endless error loop
  23.             if in_error then return end
  24.             in_error = true
  25.             naughty.notify({ preset = naughty.config.presets.critical,
  26.                     title = "An error happened!",
  27.                     text = tostring(err) })
  28.             in_error = false
  29.         end)
  30. end
  31.  
  32. -- Third-party modules
  33. -- Additional widgets and layouts
  34. lain = require("lain")
  35. -- Widget displaying volume information
  36. volume = require("volume")
  37.  
  38. -- Variables
  39. -- $HOME/
  40. home_path = os.getenv('HOME') .. '/'
  41. -- Terminal emulator
  42. terminal = "xfce4-terminal"
  43. -- Set terminal for applications which require it (menubar)
  44. --menubar.utils.terminal = terminal
  45. -- Editor, graphical
  46. --editor = "geany"
  47. -- Editor, terminal (man sensible-editor)
  48. editor = terminal .. ' -e "sensible-editor \\"%s\\""'
  49. -- Meta/Win/Super
  50. modkey = "Mod4"
  51. -- Alt
  52. modkey_alt = "Mod1"
  53.  
  54. -- Appearance
  55. -- Set default theme
  56. beautiful.init(awful.util.getdir("config") .. "/themes/default_white/theme.lua")
  57. -- If beautiful.wallpaper variable is set (in theme.lua) then
  58. if beautiful.wallpaper then
  59.     -- for each screen
  60.     for s = 1, screen.count() do
  61.         -- set this wallpaper
  62.         gears.wallpaper.maximized(beautiful.wallpaper, s, true)
  63.     end
  64. end
  65.  
  66. -- Functions
  67.  
  68. -- "Match" function
  69. -- Returns true if all pairs in table1 are present in table2 (for use by "Run or raise")
  70. function match (table1, table2)
  71.     for k, v in pairs(table1) do
  72.         if table2[k] ~= v and not table2[k]:find(v) then
  73.             return false
  74.         end
  75.     end
  76.     return true
  77. end
  78.  
  79. -- "Run or raise" function
  80. -- Jump to client, which matches PROPERTIES, otherwise run CMD
  81. function run_or_raise(cmd, properties)
  82.     local clients = client.get()
  83.     local focused = awful.client.next(0)
  84.     local findex = 0
  85.     local matched_clients = {}
  86.     local n = 0
  87.     -- Check all clients
  88.     for i, c in pairs(clients) do
  89.         -- Make an array of matched clients
  90.         -- If client matches properties
  91.         if match(properties, c) then
  92.             n = n + 1
  93.             -- Add it to an array of matching clients
  94.             matched_clients[n] = c
  95.             if c == focused then
  96.                 findex = n
  97.             end
  98.         end
  99.     end
  100.     -- If there is a client, which matches properties
  101.     if n > 0 then
  102.         -- Choose first client, which matched properties
  103.         local c = matched_clients[1]
  104.         -- If the focused client matches, switch to next matching client in list
  105.         if 0 < findex and findex < n then
  106.             c = matched_clients[findex+1]
  107.         end
  108.         -- List of tags, on which this client is visible
  109.         local ctags = c:tags()
  110.         -- If client is visible on 0 tags, move it to current tag
  111.         if #ctags == 0 then
  112.             local curtag = awful.tag.selected()
  113.             awful.client.movetotag(curtag, c)
  114.         -- Otherwise, jump to first tag client is visible on
  115.         else
  116.             awful.tag.viewonly(ctags[1])
  117.         end
  118.         -- Focus and raise the client
  119.         client.focus = c
  120.         c:raise()
  121.         return
  122.     end
  123.     -- If no client matches, just run this program
  124.     awful.util.spawn(cmd)
  125. end
  126.  
  127. -- "Run once" function
  128. -- Run PRG once with command-line ARGuments, expecting PNAME as process name on SCREEN
  129. function run_once(prg,arg_string,pname,screen)
  130.     -- Check if program name is passed to function
  131.     if not prg then
  132.         do return nil end
  133.     end
  134.     -- If process name is not set, expect that process name = program name
  135.     if not pname then
  136.         pname = prg
  137.     end
  138.     -- If no arguments are specified
  139.     if not arg_string then
  140.         -- Look for process with such name, if nothing found - run program on screen
  141.         awful.util.spawn_with_shell("pgrep -f -u $USER -x '" .. pname .. "' || (" .. prg .. ")",screen)
  142.     -- If arguments are specified
  143.     else
  144.         awful.util.spawn_with_shell("pgrep -f -u $USER -x '" .. pname .. " ".. arg_string .."' || (" .. prg .. " " .. arg_string .. ")",screen)
  145.     end
  146. end
  147.  
  148. -- Autostart (start only once, to prevent having multiple instances of one program running, if we restart Awesome, but not the session)
  149.  
  150. -- Set X server keymap and its settings (doesn't remain as a process, so it can be run multiple times)
  151. awful.util.spawn("setxkbmap")
  152. -- Switch/restore keyboard layout on per-client basis
  153. run_once("kbdd")
  154. -- Compton (composite manager) for less tearing
  155. run_once("compton","--vsync opengl-swc --backend glx --glx-no-stencil")
  156. -- Automatically lock session after 5 minutes of idleness
  157. run_once("xautolock",'-locker "i3lock -i .wallpaper -e" -time 5')
  158. -- XSettings daemon from Xfce4
  159. run_once("xfsettingsd")
  160. -- Clipboard manager
  161. run_once("clipit")
  162. -- Pcmanfm (daemon) for faster Pcmanfm startup
  163. run_once("pcmanfm","--daemon-mode")
  164. -- Gnome policykit agent (prompts for password when policykit authentication is required)
  165. run_once("/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1")
  166.  
  167. -- Key bindings
  168.  
  169. -- Global
  170. globalkeys = awful.util.table.join(
  171.  
  172.     -- Switch tags (relatively)
  173.     awful.key({ modkey, }, "Left", awful.tag.viewprev),
  174.     awful.key({ modkey, }, "Right", awful.tag.viewnext),
  175.     awful.key({ modkey, }, "`", function () awful.client.urgent.jumpto() end),
  176.     awful.key({ modkey, }, "Escape", awful.tag.history.restore),
  177.  
  178.     -- Clients: focus
  179.     awful.key({ modkey, }, "j",
  180.         function ()
  181.             awful.client.focus.byidx(-1)
  182.             if client.focus then client.focus:raise() end
  183.         end),
  184.     awful.key({ modkey, }, "k",
  185.         function ()
  186.             awful.client.focus.byidx(1)
  187.             if client.focus then client.focus:raise() end
  188.         end),
  189.     awful.key({ modkey_alt, }, "Tab",
  190.         function ()
  191.             awful.client.focus.byidx(1)
  192.             if client.focus then client.focus:raise() end
  193.         end),
  194.     awful.key({ modkey, }, "Tab",
  195.         function ()
  196.             awful.client.focus.history.previous()
  197.             if client.focus then client.focus:raise() end
  198.         end),
  199.  
  200.     -- Clients: placement
  201.     awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx(-1) end),
  202.     awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx(1) end),
  203.     awful.key({ modkey_alt, "Shift" }, "Tab", function () awful.client.swap.byidx(1) end),
  204.     awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
  205.     awful.key({ modkey, }, "l", function () awful.tag.incmwfact(0.05) end),
  206.     awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(-1) end),
  207.     awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(1) end),
  208.     awful.key({ modkey, }, "space", function () awful.layout.inc(1) end),
  209.     awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(-1) end),
  210.  
  211.     -- Restart Awesome
  212.     awful.key({ modkey, "Shift" }, "r", awesome.restart),
  213.  
  214.     -- Awesome launchers
  215.     awful.key({ modkey, }, "p", function () awful.util.spawn(terminal .. " -T mylauncher --geometry 100x5 --hide-menubar --hide-toolbar --hide-borders -e 'env ZDOTDIR=.zsh zsh'") end),
  216.     awful.key({ modkey, }, "x",
  217.         function ()
  218.             awful.prompt.run({ prompt = " Run Lua code: " },
  219.                 mypromptbox[mouse.screen].widget,
  220.                 awful.util.eval, nil,
  221.                 awful.util.getdir("cache") .. "/history_eval")
  222.         end),
  223.     awful.key({ modkey, }, "F3", function () mymainmenu:toggle() end),
  224.  
  225.     -- Program launchers
  226.     awful.key({ modkey, }, "w", function () run_or_raise("iceweasel", { class = "Iceweasel" }) end),
  227.     awful.key({ modkey, }, "e", function () run_or_raise("icedove", { class = "Icedove" }) end),
  228.     awful.key({ modkey, }, "o", function () awful.util.spawn("xautolock -locknow") end),
  229.     awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
  230.     awful.key({ modkey, }, "F1", function () awful.util.spawn(terminal) end),
  231.     awful.key({ modkey, }, "f", function () awful.util.spawn("pcmanfm") end),
  232.     awful.key({ modkey, }, "q", function () awful.util.spawn("tkscreen") end),
  233.     awful.key({ modkey, }, "t", function () run_or_raise("transmission-remote-gtk", { class = "transmission-remote-gtk" }) end),
  234.     awful.key({ modkey, }, "a", function () run_or_raise(terminal .. " -T Ncmpcpp -e ncmpcpp ", { name = "Ncmpcpp" }) end),
  235.     awful.key({ modkey, }, "F2", function () run_or_raise(terminal .. " -T Htop -e 'sudo htop' ", { name = "Htop" }) end),
  236.  
  237.     -- Multimedia
  238.     awful.key({}, "XF86Calculator", function () awful.util.spawn("qalculate") end),
  239.     awful.key({}, "XF86AudioPlay", function () awful.util.spawn("mpc toggle") end),
  240.     awful.key({}, "XF86AudioNext", function () awful.util.spawn("mpc next") end),
  241.     awful.key({}, "XF86AudioPrev", function () awful.util.spawn("mpc prev") end),
  242.     awful.key({}, "XF86AudioStop", function () awful.util.spawn("mpc stop") end),
  243.     -- We should update volume_widget every time volume changes
  244.     -- Unlike os.execute() or io.popen(), awful.util.spawn() and awful.util.spawn_with_shell() don't lock an application (os.execute() and io.popen() normally should not be used)
  245.     -- Thus awful.util.spawn_with_shell is used here, and "update_volume" command is passed to Awesome via awesome-client
  246.     -- Such approach guarantees, that "update_volume" is executed after volume change
  247.     -- If we change volume, also turn "Master" channel ON prior to volume change. More convenient
  248.     awful.key({}, "XF86AudioRaiseVolume", function () awful.util.spawn_with_shell('amixer set Master on 4%+ && echo "update_volume(volume_widget)" | awesome-client') end),
  249.     awful.key({}, "XF86AudioLowerVolume", function () awful.util.spawn_with_shell('amixer set Master on 4%- && echo "update_volume(volume_widget)" | awesome-client') end),
  250.     awful.key({}, "XF86AudioMute", function () awful.util.spawn_with_shell('amixer set Master toggle && echo "update_volume(volume_widget)" | awesome-client') end)
  251. )
  252.  
  253. -- Switch tags
  254. for i = 1, 9 do
  255.     globalkeys = awful.util.table.join(globalkeys,
  256.         awful.key({ modkey }, "#" .. i + 9,
  257.             function ()
  258.                 local screen = mouse.screen
  259.                 local tag = awful.tag.gettags(screen)[i]
  260.                 if tag then
  261.                     awful.tag.viewonly(tag)
  262.                 end
  263.             end),
  264.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  265.             function ()
  266.                 local screen = mouse.screen
  267.                 local tag = awful.tag.gettags(screen)[i]
  268.                 if tag then
  269.                     awful.tag.viewtoggle(tag)
  270.                 end
  271.             end),
  272.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  273.             function ()
  274.                 if client.focus then
  275.                     local tag = awful.tag.gettags(client.focus.screen)[i]
  276.                     if tag then
  277.                         awful.client.movetotag(tag)
  278.                     end
  279.                 end
  280.             end),
  281.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  282.             function ()
  283.                 if client.focus then
  284.                     local tag = awful.tag.gettags(client.focus.screen)[i]
  285.                     if tag then
  286.                         awful.client.toggletag(tag)
  287.                     end
  288.                 end
  289.             end))
  290. end
  291.  
  292. -- Local (per-client)
  293. clientkeys = awful.util.table.join(
  294.     awful.key({ modkey_alt, }, "F1", function (c) c.fullscreen = not c.fullscreen end),
  295.     awful.key({ modkey_alt, }, "F2",
  296.         function (c)
  297.             c:raise()
  298.             c.maximized_horizontal = not c.maximized_horizontal
  299.             c.maximized_vertical = not c.maximized_vertical
  300.         end),
  301.     awful.key({ modkey_alt, }, "F3", awful.client.floating.toggle),
  302.     awful.key({ modkey_alt, }, "F4", function (c) c:kill() end),
  303.     awful.key({ modkey_alt, }, "F5", function (c) c:swap(awful.client.getmaster()) end),
  304.     awful.key({ modkey_alt, }, "F6", function (c) c.ontop = not c.ontop end)
  305. )
  306.  
  307. -- Mouse bindings
  308.  
  309. -- On desktop
  310. root.buttons(awful.util.table.join(
  311.         -- Open/close main menu on right-click
  312.         awful.button({ }, 3, function () mymainmenu:toggle() end),
  313.         -- Scroll through tags
  314.         awful.button({ }, 4, awful.tag.viewnext),
  315.         awful.button({ }, 5, awful.tag.viewprev)
  316. ))
  317. -- On window
  318. clientbuttons = awful.util.table.join(
  319.     -- Left-click to give client focus and raise it
  320.     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
  321.     -- Meta+left-click and drag to move window
  322.     awful.button({ modkey }, 1, awful.mouse.client.move),
  323.     -- Meta+right-click and drag to resize window
  324.     awful.button({ modkey }, 3, awful.mouse.client.resize))
  325.  
  326. -- Table of layouts
  327. awful.layout.layouts = {
  328.     -- All clients are tiled (masters and slaves)
  329.     awful.layout.suit.tile,
  330.     -- If only one client, it is centered (see themes/default/theme.lua, theme.single_gap and theme.useless_gap variables). If more, tiled (masters and slaves)
  331.     lain.layout.uselesstile,
  332.     -- All clients are tiled fairly (no masters or slaves)
  333.     awful.layout.suit.fair,
  334.     -- All clients float (like in traditional desktop)
  335.     awful.layout.suit.floating
  336. }
  337.  
  338. -- Tags
  339. tags = {
  340.     -- Set names for tags
  341.     names = { "www", "music", "mail", 4, 5, 6, 7, 8, 9 },
  342.     -- Set layouts for tags (layout number in square brackets)
  343.     layout = { awful.layout.layouts[1], awful.layout.layouts[1], awful.layout.layouts[1], awful.layout.layouts[2], awful.layout.layouts[2],
  344.         awful.layout.layouts[2], awful.layout.layouts[3], awful.layout.layouts[3], awful.layout.layouts[3]
  345. }}
  346.  
  347. -- For each screen create tags with corresponding names and layouts
  348. for s = 1, screen.count() do
  349.     tags[s] = awful.tag(tags.names, s, tags.layout)
  350. end
  351.  
  352. -- Rules
  353. awful.rules.rules = {
  354.     { rule = { },
  355.         -- Rules for all the clients: define border appearance, focus settings, remove gaps between windows (see FAQ), and set local key/mouse bindings
  356.         properties = { border_width = beautiful.border_width,
  357.             border_color = beautiful.border_normal,
  358.             focus = awful.client.focus.filter,
  359.             size_hints_honor = false,
  360.             keys = clientkeys,
  361.             buttons = clientbuttons } },
  362.     -- Per-client rules
  363.     { rule = { instance = "pidgin" },
  364.         properties = { floating = true }
  365.     },
  366.     { rule = { instance = "Pidgin" },
  367.         properties = { floating = true }
  368.     },
  369.     { rule = { class = "qemu-system-x86_64" },
  370.         properties = { floating = true }
  371.     },
  372.     { rule = { instance = "qalculate" },
  373.         properties = { floating = true }
  374.     },
  375.     { rule = { name = "mylauncher" },
  376.         properties = { floating = true }
  377.     },
  378.     { rule = { name = "Действия над файлами" },
  379.         properties = { floating = true }
  380.     },
  381.     { rule = { name = "Catfish" },
  382.         properties = { floating = true }
  383.     }
  384. }
  385.  
  386. -- Widgets
  387.  
  388. -- Launcher widget and main menu
  389. myawesomemenu = {
  390.     { "edit config", editor:format(awesome.conffile) },
  391.     { "restart", awesome.restart },
  392. }
  393. mysessionmenu = {
  394.     { "lock session", "xautolock -locknow" },
  395.     { "quit session", awesome.quit },
  396.     { "suspend", "systemctl suspend" },
  397.     { "shutdown", "systemctl poweroff" },
  398.     { "reboot", "systemctl reboot" }
  399. }
  400. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon }, { "session", mysessionmenu } }
  401.     })
  402. mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
  403.         menu = mymainmenu })
  404.  
  405. -- Keyboard layout widget
  406. kbdwidget = wibox.widget.textbox(" Eng ")
  407. kbdwidget:set_font("Liberation Mono 9")
  408. kbdstrings = {[0] = " Eng ",
  409.     [1] = " Рус ",
  410.     -- Workaround for unknown kbdd bug. See dbus-monitor for details
  411.     [2] = " Eng ",
  412.     [3] = " Рус "}
  413. dbus.request_name("session", "ru.gentoo.kbdd")
  414. dbus.add_match("session", "interface='ru.gentoo.kbdd',member='layoutChanged'")
  415. dbus.connect_signal("ru.gentoo.kbdd",
  416.     function(...)
  417.         local data = {...}
  418.         local layout = data[2]
  419.         kbdwidget:set_text(kbdstrings[layout])
  420.     end
  421. )
  422.  
  423. -- Textclock widget
  424. -- See Lua Date and Time format for format details
  425. mytextclock = awful.widget.textclock.new(" %A %d.%m.%y, %H:%M")
  426. -- Attach Lain calendar to clock widget
  427. lain.widgets.calendar:attach(mytextclock, {font_size = 9, font = "DejaVu Sans Mono"})
  428.  
  429. -- Wibox (panel)
  430.  
  431. mywibox = {}
  432. mypromptbox = {}
  433. mylayoutbox = {}
  434. mytaglist = {}
  435. -- Mouse bindings for taglist widget
  436. mytaglist.buttons = awful.util.table.join(
  437.     -- Left-click on tag to switch to this tag
  438.     awful.button({ }, 1, awful.tag.viewonly),
  439.     -- Meta+left-click on tag to move focused client to this tag
  440.     awful.button({ modkey }, 1, awful.client.movetotag),
  441.     -- Right-click on tag to toggle it's view (make clients on this tag visible)
  442.     awful.button({ }, 3, awful.tag.viewtoggle),
  443.     -- Meta+right-click on tag to make focused client visible on this tag
  444.     awful.button({ modkey }, 3, awful.client.toggletag),
  445.     -- Scroll through tags
  446.     awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end),
  447.     awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end)
  448. )
  449. mytasklist = {}
  450. -- Mouse bindings for tasklist widget
  451. mytasklist.buttons = awful.util.table.join(
  452.     -- If client is focused, minimize it on left-click
  453.     -- If client is not focused, go to the first tag, where client is visible, unminimize it and give focus
  454.     awful.button({ }, 1,
  455.         function (c)
  456.             if c == client.focus then
  457.                 c.minimized = true
  458.             else
  459.                 c.minimized = false
  460.                 if not c:isvisible() then
  461.                     awful.tag.viewonly(c:tags()[1])
  462.                 end
  463.                 client.focus = c
  464.                 c:raise()
  465.             end
  466.         end),
  467.     -- Right-click for client list
  468.     awful.button({ }, 3,
  469.         function ()
  470.             if instance then
  471.                 instance:hide()
  472.                 instance = nil
  473.             else
  474.                 instance = awful.menu.clients({
  475.                         theme = { width = 250 }
  476.                     })
  477.             end
  478.         end),
  479.     -- Scroll through clients
  480.     awful.button({ }, 4,
  481.         function ()
  482.             awful.client.focus.byidx(1)
  483.             if client.focus then client.focus:raise() end
  484.         end),
  485.     awful.button({ }, 5,
  486.         function ()
  487.             awful.client.focus.byidx(-1)
  488.             if client.focus then client.focus:raise() end
  489.         end))
  490.  
  491. -- For each screen:
  492. for s = 1, screen.count() do
  493.     -- Create a promptbox
  494.     mypromptbox[s] = awful.widget.prompt()
  495.     -- Create an layoutbox widget which will contain an icon indicating which layout we're using
  496.     mylayoutbox[s] = awful.widget.layoutbox(s)
  497.     -- Mouse bindings for layoutbox widget
  498.     mylayoutbox[s]:buttons(awful.util.table.join(
  499.             -- Scroll through layouts
  500.             awful.button({ }, 1, function () awful.layout.inc(1) end),
  501.             awful.button({ }, 3, function () awful.layout.inc(-1) end),
  502.             awful.button({ }, 4, function () awful.layout.inc(1) end),
  503.             awful.button({ }, 5, function () awful.layout.inc(-1) end)))
  504.     -- Create a taglist widget
  505.     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
  506.     -- Create a tasklist widget
  507.     mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
  508.     -- Create the wibox on top of the screen
  509.     mywibox[s] = awful.wibox({ position = "top", screen = s })
  510.     -- Widgets that are aligned to the left
  511.     local left_layout = wibox.layout.fixed.horizontal()
  512.     left_layout:add(mylauncher)
  513.     left_layout:add(mytaglist[s])
  514.     left_layout:add(mypromptbox[s])
  515.     -- Widgets that are aligned to the right
  516.     local right_layout = wibox.layout.fixed.horizontal()
  517.     -- Tray should only be on one screen
  518.     if s == 1 then right_layout:add(wibox.widget.systray()) end
  519.     right_layout:add(volume_widget)
  520.     right_layout:add(mytextclock)
  521.     right_layout:add(kbdwidget)
  522.     right_layout:add(mylayoutbox[s])
  523.     -- Now bring it all together (with the tasklist in the middle)
  524.     local layout = wibox.layout.align.horizontal()
  525.     layout:set_left(left_layout)
  526.     layout:set_middle(mytasklist[s])
  527.     layout:set_right(right_layout)
  528.     mywibox[s]:set_widget(layout)
  529. end
  530.  
  531. -- Enable global keybindings (after adding all the widgets, because widgets may contain their own global keybindings)
  532. root.keys(globalkeys)
  533.  
  534. -- Signals
  535.  
  536. -- When client appears
  537. client.connect_signal("manage",
  538.     function (c)
  539.         -- When Awesome is already started
  540.         if not awesome.startup then
  541.             -- Set new clients as slaves (put them in the end of the list)
  542.             awful.client.setslave(c)
  543.             -- When floating, prevent windows from overlapping or appearing outside the screen and make them appear in the center of the screen by default, if their position is not predefined
  544.             if not c.size_hints.user_position and not c.size_hints.program_position then
  545.                 awful.placement.no_overlap(c)
  546.                 awful.placement.no_offscreen(c)
  547.                 awful.placement.centered(c,nil)
  548.             end
  549.         -- On Awesome startup
  550.         -- Prevent windows from appearing outside the screen, if their position is not predefined
  551.         elseif not c.size_hints.user_position and not c.size_hints.program_position then
  552.             awful.placement.no_offscreen(c)
  553.         end
  554.         -- Disable titlebars
  555.         local titlebars_enabled = false
  556.     end)
  557. -- Enable sloppy focus (focus follows the mouse)
  558. client.connect_signal("mouse::enter",
  559.     function(c)
  560.         if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  561.         and awful.client.focus.filter(c) then
  562.             client.focus = c
  563.         end
  564.     end)
  565. -- If client gets focus
  566. client.connect_signal("focus",
  567.     function(c)
  568.         -- Change it's border color
  569.         c.border_color = beautiful.border_focus
  570.         -- And if it is not visible - jump to it
  571.         if not c:isvisible() then
  572.             awful.client.jumpto(c)
  573.         end
  574.     end)
  575. -- If client loses focus, change it's border color back to normal
  576. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement