Guest User

Untitled

a guest
Oct 13th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 25.67 KB | None | 0 0
  1. -- If LuaRocks is installed, make sure that packages installed through it are
  2. -- found (e.g. lgi). If LuaRocks is not installed, do nothing.
  3. pcall(require, "luarocks.loader")
  4.  
  5. -- Standard awesome library
  6. local gears = require("gears")
  7. local awful = require("awful")
  8. require("awful.autofocus")
  9. -- Widget and layout library
  10. local wibox = require("wibox")
  11. -- Theme handling library
  12. local beautiful = require("beautiful")
  13. -- Notification library
  14. local naughty = require("naughty")
  15. local menubar = require("menubar")
  16. local hotkeys_popup = require("awful.hotkeys_popup")
  17. -- Enable hotkeys help widget for VIM and other apps
  18. -- when client with a matching name is opened:
  19. require("awful.hotkeys_popup.keys")
  20.  
  21. -- {{{ Error handling
  22. -- Check if awesome encountered an error during startup and fell back to
  23. -- another config (This code will only ever execute for the fallback config)
  24. if awesome.startup_errors then
  25.     naughty.notify({ preset = naughty.config.presets.critical,
  26.                      title = "Oops, there were errors during startup!",
  27.                      text = awesome.startup_errors })
  28. end
  29.  
  30. -- Handle runtime errors after startup
  31. do
  32.     local in_error = false
  33.     awesome.connect_signal("debug::error", function (err)
  34.         -- Make sure we don't go into an endless error loop
  35.         if in_error then return end
  36.         in_error = true
  37.  
  38.         naughty.notify({ preset = naughty.config.presets.critical,
  39.                          title = "Oops, an error happened!",
  40.                          text = tostring(err) })
  41.         in_error = false
  42.     end)
  43. end
  44. -- }}}
  45.  
  46. -- {{{ Variable definitions
  47. -- Themes define colours, icons, font and wallpapers.
  48. beautiful.init("/home/benjamin/.config/awesome/theme.lua")
  49.  
  50. -- This is used later as the default terminal and editor to run.
  51. terminal = "termite"
  52. editor = os.getenv("EDITOR") or "nvim"
  53. editor_cmd = terminal .. " -e " .. editor
  54.  
  55. -- Default modkey.
  56. -- Usually, Mod4 is the key with a logo between Control and Alt.
  57. -- If you do not like this or do not have such a key,
  58. -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
  59. -- However, you can use another modifier like Mod1, but it may interact with others.
  60. modkey = "Mod4"
  61.  
  62. -- Table of layouts to cover with awful.layout.inc, order matters.
  63. awful.layout.layouts = {
  64.     awful.layout.suit.floating,
  65.     awful.layout.suit.tile,
  66.     -- awful.layout.suit.tile.left,
  67.     -- awful.layout.suit.tile.bottom,
  68.     -- awful.layout.suit.tile.top,
  69.     -- awful.layout.suit.fair,
  70.     -- awful.layout.suit.fair.horizontal,
  71.     -- awful.layout.suit.spiral,
  72.     -- awful.layout.suit.spiral.dwindle,
  73.     -- awful.layout.suit.max,
  74.     -- awful.layout.suit.max.fullscreen,
  75.     -- awful.layout.suit.magnifier,
  76.     -- awful.layout.suit.corner.nw,
  77.     -- awful.layout.suit.corner.ne,
  78.     -- awful.layout.suit.corner.sw,
  79.     -- awful.layout.suit.corner.se,
  80. }
  81. -- }}}
  82.  
  83. -- {{{ Menu
  84. -- Create a launcher widget and a main menu
  85. myawesomemenu = {
  86.    { "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end },
  87.    { "manual", terminal .. " -e man awesome" },
  88.    { "edit config", editor_cmd .. " " .. awesome.conffile },
  89.    { "restart", awesome.restart },
  90.    { "quit", "xfce4-session-logout"},
  91. }
  92.  
  93. mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
  94.                                     { "open terminal", terminal }
  95.                                   }
  96.                         })
  97.  
  98. mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
  99.                                      menu = mymainmenu })
  100. -- Menubar configuration
  101. menubar.utils.terminal = terminal -- Set the terminal for applications that require it
  102. -- }}}
  103.  
  104. -- Keyboard map indicator and switcher
  105. -- mykeyboardlayout = awful.widget.keyboardlayout()
  106. mysystray = wibox.widget.systray()
  107.  
  108. -- {{{ Wibar
  109. -- Create a textclock widget
  110. mytextclock = wibox.widget.textclock()
  111.  
  112. myweather = awful.widget.watch("curl 'wttr.in/Heidelberg?format=1'", 900)
  113.  
  114. -- Create a wibox for each screen and add it
  115. local taglist_buttons = gears.table.join(
  116.                     awful.button({ }, 1, function(t) t:view_only() end),
  117.                     awful.button({ modkey }, 1, function(t)
  118.                                               if client.focus then
  119.                                                   client.focus:move_to_tag(t)
  120.                                               end
  121.                                           end),
  122.                     awful.button({ }, 3, awful.tag.viewtoggle),
  123.                     awful.button({ modkey }, 3, function(t)
  124.                                               if client.focus then
  125.                                                   client.focus:toggle_tag(t)
  126.                                               end
  127.                                           end),
  128.                     awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end),
  129.                     awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end)
  130.                 )
  131.  
  132. local tasklist_buttons = gears.table.join(
  133.                      awful.button({ }, 1, function (c)
  134.                                               if c == client.focus then
  135.                                                   c.minimized = true
  136.                                               else
  137.                                                   c:emit_signal(
  138.                                                       "request::activate",
  139.                                                       "tasklist",
  140.                                                       {raise = true}
  141.                                                   )
  142.                                               end
  143.                                           end),
  144.                      awful.button({ }, 3, function()
  145.                                               awful.menu.client_list({ theme = { width = 250 } })
  146.                                           end),
  147.                      awful.button({ }, 4, function ()
  148.                                               awful.client.focus.byidx(1)
  149.                                           end),
  150.                      awful.button({ }, 5, function ()
  151.                                               awful.client.focus.byidx(-1)
  152.                                           end))
  153.  
  154. local function set_wallpaper(s)
  155.     -- Wallpaper
  156.     if beautiful.wallpaper then
  157.         local wallpaper = beautiful.wallpaper
  158.         -- If wallpaper is a function, call it with the screen
  159.         if type(wallpaper) == "function" then
  160.             wallpaper = wallpaper(s)
  161.         end
  162.         gears.wallpaper.maximized(wallpaper, s, true)
  163.     end
  164. end
  165.  
  166. -- Re-set wallpaper when a screen's geometry changes (e.g. different resolution)
  167. screen.connect_signal("property::geometry", set_wallpaper)
  168.  
  169. awful.screen.connect_for_each_screen(function(s)
  170.     -- Wallpaper
  171.     set_wallpaper(s)
  172.  
  173.     -- Each screen has its own tag table.
  174.     awful.tag({ "Ⅰ", "Ⅱ", "Ⅲ", "Ⅳ", "Ⅴ", "Ⅵ", "Ⅶ", "Ⅷ", "Ⅸ" }, s, awful.layout.layouts[1])
  175.  
  176.     -- Create a promptbox for each screen
  177.     s.mypromptbox = awful.widget.prompt()
  178.     -- Create an imagebox widget which will contain an icon indicating which layout we're using.
  179.     -- We need one layoutbox per screen.
  180.     s.mylayoutbox = awful.widget.layoutbox(s)
  181.     s.mylayoutbox:buttons(gears.table.join(
  182.                            awful.button({ }, 1, function () awful.layout.inc( 1) end),
  183.                            awful.button({ }, 3, function () awful.layout.inc(-1) end),
  184.                            awful.button({ }, 4, function () awful.layout.inc( 1) end),
  185.                            awful.button({ }, 5, function () awful.layout.inc(-1) end)))
  186.     -- Create a taglist widget
  187.     s.mytaglist = awful.widget.taglist {
  188.         screen  = s,
  189.         filter  = awful.widget.taglist.filter.all,
  190.         buttons = taglist_buttons
  191.     }
  192.  
  193.     -- Create a tasklist widget
  194.     s.mytasklist = awful.widget.tasklist {
  195.         screen  = s,
  196.         filter  = awful.widget.tasklist.filter.currenttags,
  197.         buttons = tasklist_buttons
  198.     }
  199.  
  200.     -- Create the wibox
  201.     s.mywibox = awful.wibar({ position = "top", screen = s , visible = true})
  202.  
  203.     -- Add widgets to the wibox
  204.     s.mywibox:setup {
  205.         layout = wibox.layout.align.horizontal,
  206.         { -- Left widgets
  207.             layout = wibox.layout.fixed.horizontal,
  208.             mylauncher,
  209.             s.mytaglist,
  210.             s.mypromptbox,
  211.         },
  212.         s.mytasklist, -- Middle widget
  213.         { -- Right widgets
  214.             layout = wibox.layout.fixed.horizontal,
  215.             mysystray,
  216.             mykeyboardlayout,
  217.             -- wibox.widget.systray(),
  218.             mytextclock,
  219.             myweather,
  220.             s.mylayoutbox,
  221.         },
  222.     }
  223. end)
  224. -- }}}
  225.  
  226. -- {{{ Mouse bindings
  227. root.buttons(gears.table.join(
  228.     awful.button({ }, 3, function () mymainmenu:toggle() end),
  229.     awful.button({ }, 4, awful.tag.viewnext),
  230.     awful.button({ }, 5, awful.tag.viewprev)
  231. ))
  232. -- }}}
  233.  
  234. -- {{{ Key bindings
  235. globalkeys = gears.table.join(
  236.     -- Programm shortcuts
  237.     awful.key({ modkey,           }, "b", function () awful.spawn("brave") end,
  238.               {description = "openst the brave browser", group = "launcher"}),
  239.     awful.key({ modkey, }, "r", function () awful.spawn("rofi -show drun  -theme-str 'element-icon { size: 2ch;}'") end,
  240.               {description = "opens the rofi",  group = "launcher"}),
  241.     awful.key({ modkey, }, "w", function () awful.spawn("rofi -show window") end,
  242.               {description = "open window switcher",  group = "client"}),
  243.     awful.key({ modkey, }, "e", function () awful.spawn("thunar") end,
  244.               {description = "opens the thunar file manager",  group = "launcher"}),
  245.  
  246.     awful.key({ modkey,           }, "s",      hotkeys_popup.show_help,
  247.               {description="show help", group="awesome"}),
  248.     awful.key({ modkey,           }, "Left",   awful.tag.viewprev,
  249.               {description = "view previous", group = "tag"}),
  250.     awful.key({ modkey,           }, "Right",  awful.tag.viewnext,
  251.               {description = "view next", group = "tag"}),
  252.     awful.key({ modkey,           }, "Escape", awful.tag.history.restore,
  253.               {description = "go back", group = "tag"}),
  254.  
  255.     awful.key({ modkey,           }, "j",
  256.         function ()
  257.             awful.client.focus.byidx( 1)
  258.         end,
  259.         {description = "focus next by index", group = "client"}
  260.     ),
  261.     awful.key({ modkey,           }, "k",
  262.         function ()
  263.             awful.client.focus.byidx(-1)
  264.         end,
  265.         {description = "focus previous by index", group = "client"}
  266.     ),
  267.     -- awful.key({ modkey,           }, "w", function () mymainmenu:show() end,
  268.     --          {description = "show main menu", group = "awesome"}),
  269.  
  270.     -- Layout manipulation
  271.     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end,
  272.               {description = "swap with next client by index", group = "client"}),
  273.     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end,
  274.               {description = "swap with previous client by index", group = "client"}),
  275.     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end,
  276.               {description = "focus the next screen", group = "screen"}),
  277.     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end,
  278.               {description = "focus the previous screen", group = "screen"}),
  279.     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto,
  280.               {description = "jump to urgent client", group = "client"}),
  281.     awful.key({ modkey,           }, "Tab",
  282.         function ()
  283.             awful.client.focus.history.previous()
  284.             if client.focus then
  285.                 client.focus:raise()
  286.             end
  287.         end,
  288.         {description = "go back", group = "client"}),
  289.  
  290.     -- Standard program
  291.     awful.key({ modkey,           }, "Return", function () awful.spawn(terminal) end,
  292.               {description = "open a terminal", group = "launcher"}),
  293.     awful.key({ modkey, "Control" }, "r", awesome.restart,
  294.               {description = "reload awesome", group = "awesome"}),
  295.     awful.key({ modkey, "Shift"   }, "q", function () awful.spawn("xfce4-session-logout") end,
  296.               {description = "quit awesome", group = "awesome"}),
  297.  
  298.     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)          end,
  299.               {description = "increase master width factor", group = "layout"}),
  300.     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)          end,
  301.               {description = "decrease master width factor", group = "layout"}),
  302.     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1, nil, true) end,
  303.               {description = "increase the number of master clients", group = "layout"}),
  304.     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1, nil, true) end,
  305.               {description = "decrease the number of master clients", group = "layout"}),
  306.     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1, nil, true)    end,
  307.               {description = "increase the number of columns", group = "layout"}),
  308.     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1, nil, true)    end,
  309.               {description = "decrease the number of columns", group = "layout"}),
  310.     awful.key({ modkey,           }, "space", function () awful.layout.inc( 1)                end,
  311.               {description = "select next", group = "layout"}),
  312.     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(-1)                end,
  313.               {description = "select previous", group = "layout"}),
  314.  
  315.     awful.key({ modkey, "Control" }, "n",
  316.               function ()
  317.                   local c = awful.client.restore()
  318.                   -- Focus restored client
  319.                   if c then
  320.                     c:emit_signal(
  321.                         "request::activate", "key.unminimize", {raise = true}
  322.                     )
  323.                   end
  324.               end,
  325.               {description = "restore minimized", group = "client"}),
  326.  
  327.     -- Prompt
  328. --    awful.key({ modkey },            "r",     function () awful.screen.focused().mypromptbox:run() end,
  329. --              {description = "run prompt", group = "launcher"}),
  330.  
  331.     awful.key({ modkey }, "x",
  332.               function ()
  333.                   awful.prompt.run {
  334.                     prompt       = "Run Lua code: ",
  335.                     textbox      = awful.screen.focused().mypromptbox.widget,
  336.                     exe_callback = awful.util.eval,
  337.                     history_path = awful.util.get_cache_dir() .. "/history_eval"
  338.                   }
  339.               end,
  340.               {description = "lua execute prompt", group = "awesome"}),
  341.     -- Menubar
  342.     awful.key({ modkey }, "p", function() menubar.show() end,
  343.               {description = "show the menubar", group = "launcher"})
  344. )
  345.  
  346. clientkeys = gears.table.join(
  347.     awful.key({ modkey,           }, "f",
  348.         function (c)
  349.             c.fullscreen = not c.fullscreen
  350.             c:raise()
  351.         end,
  352.         {description = "toggle fullscreen", group = "client"}),
  353.     awful.key({ modkey,           }, "q",      function (c) c:kill()                         end,
  354.               {description = "close", group = "client"}),
  355.     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ,
  356.               {description = "toggle floating", group = "client"}),
  357.     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
  358.               {description = "move to master", group = "client"}),
  359.     awful.key({ modkey,           }, "o",      function (c) c:move_to_screen()               end,
  360.               {description = "move to screen", group = "client"}),
  361.     awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end,
  362.               {description = "toggle keep on top", group = "client"}),
  363.     awful.key({ modkey,           }, "n",
  364.         function (c)
  365.             -- The client currently has the input focus, so it cannot be
  366.             -- minimized, since minimized clients can't have the focus.
  367.             c.minimized = true
  368.         end ,
  369.         {description = "minimize", group = "client"}),
  370.     awful.key({ modkey,           }, "m",
  371.         function (c)
  372.             c.maximized = not c.maximized
  373.             c:raise()
  374.         end ,
  375.         {description = "(un)maximize", group = "client"}),
  376.     awful.key({ modkey, "Control" }, "m",
  377.         function (c)
  378.             c.maximized_vertical = not c.maximized_vertical
  379.             c:raise()
  380.         end ,
  381.         {description = "(un)maximize vertically", group = "client"}),
  382.     awful.key({ modkey, "Shift"   }, "m",
  383.         function (c)
  384.             c.maximized_horizontal = not c.maximized_horizontal
  385.             c:raise()
  386.         end ,
  387.         {description = "(un)maximize horizontally", group = "client"})
  388. )
  389.  
  390. -- Bind all key numbers to tags.
  391. -- Be careful: we use keycodes to make it work on any keyboard layout.
  392. -- This should map on the top row of your keyboard, usually 1 to 9.
  393. for i = 1, 9 do
  394.     globalkeys = gears.table.join(globalkeys,
  395.         -- View tag only.
  396.         awful.key({ modkey }, "#" .. i + 9,
  397.                   function ()
  398.                         local screen = awful.screen.focused()
  399.                         local tag = screen.tags[i]
  400.                         if tag then
  401.                            tag:view_only()
  402.                         end
  403.                   end,
  404.                   {description = "view tag #"..i, group = "tag"}),
  405.         -- Toggle tag display.
  406.         awful.key({ modkey, "Control" }, "#" .. i + 9,
  407.                   function ()
  408.                       local screen = awful.screen.focused()
  409.                       local tag = screen.tags[i]
  410.                       if tag then
  411.                          awful.tag.viewtoggle(tag)
  412.                       end
  413.                   end,
  414.                   {description = "toggle tag #" .. i, group = "tag"}),
  415.         -- Move client to tag.
  416.         awful.key({ modkey, "Shift" }, "#" .. i + 9,
  417.                   function ()
  418.                       if client.focus then
  419.                           local tag = client.focus.screen.tags[i]
  420.                           if tag then
  421.                               client.focus:move_to_tag(tag)
  422.                           end
  423.                      end
  424.                   end,
  425.                   {description = "move focused client to tag #"..i, group = "tag"}),
  426.         -- Toggle tag on focused client.
  427.         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
  428.                   function ()
  429.                       if client.focus then
  430.                           local tag = client.focus.screen.tags[i]
  431.                           if tag then
  432.                               client.focus:toggle_tag(tag)
  433.                           end
  434.                       end
  435.                   end,
  436.                   {description = "toggle focused client on tag #" .. i, group = "tag"})
  437.     )
  438. end
  439.  
  440. clientbuttons = gears.table.join(
  441.     awful.button({ }, 1, function (c)
  442.         c:emit_signal("request::activate", "mouse_click", {raise = true})
  443.     end),
  444.     awful.button({ modkey }, 1, function (c)
  445.         c:emit_signal("request::activate", "mouse_click", {raise = true})
  446.         awful.mouse.client.move(c)
  447.     end),
  448.     awful.button({ modkey }, 3, function (c)
  449.         c:emit_signal("request::activate", "mouse_click", {raise = true})
  450.         awful.mouse.client.resize(c)
  451.     end)
  452. )
  453.  
  454. -- Set keys
  455. root.keys(globalkeys)
  456. -- }}}
  457.  
  458. -- {{{ Rules
  459. -- Rules to apply to new clients (through the "manage" signal).
  460. awful.rules.rules = {
  461.     -- All clients will match this rule.
  462.     { rule = { },
  463.       properties = { border_width = beautiful.border_width,
  464.                      border_color = beautiful.border_normal,
  465.                      focus = awful.client.focus.filter,
  466.                      raise = true,
  467.                      keys = clientkeys,
  468.                      buttons = clientbuttons,
  469.                      screen = awful.screen.preferred,
  470.                      placement = awful.placement.centered+awful.placement.no_offscreen
  471.                    }
  472.  
  473.     },
  474.  
  475.     -- Floating clients.
  476.     { rule_any = {
  477.         instance = {
  478.           "DTA",  -- Firefox addon DownThemAll.
  479.           "copyq",  -- Includes session name in class.
  480.           "pinentry",
  481.         },
  482.         class = {
  483.           "Arandr",
  484.           "Blueman-manager",
  485.           "Gpick",
  486.           "Kruler",
  487.           "MessageWin",  -- kalarm.
  488.           "Sxiv",
  489.           "Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size.
  490.           "Wpa_gui",
  491.           "veromix",
  492.           "xtightvncviewer"},
  493.  
  494.         -- Note that the name property shown in xprop might be set slightly after creation of the client
  495.         -- and the name shown there might not match defined rules here.
  496.         name = {
  497.           "Event Tester",  -- xev.
  498.         },
  499.         role = {
  500.           "AlarmWindow",  -- Thunderbird's calendar.
  501.           "ConfigManager",  -- Thunderbird's about:config.
  502.           "pop-up",       -- e.g. Google Chrome's (detached) Developer Tools.
  503.         }
  504.       }, properties = { floating = true }},
  505.  
  506.     -- Add titlebars to normal clients and dialogs
  507.     { rule_any = {type = { "normal", "dialog" }
  508.       }, properties = { titlebars_enabled = true }
  509.     },
  510.  
  511.     -- Sets the xfdesktop on all tags and puts it in the background
  512.     {rule_any = { type = { "desktop" } },
  513.       callback = function(c)
  514.       c.screen = awful.screen.getbycoord(0, 0)
  515.       end,
  516.       properties = {
  517.         sticky = true,
  518.         border_width = 0,
  519.         skip_taskbar = true,
  520.         titlebars_enabled = false,
  521.         requests_no_titlebar = true,
  522.         keys = {},
  523.         },
  524.     },
  525.  
  526.     { rule_any = { class  = { "Xfce4-panel" } },
  527.     properties = {
  528.         border_width = 0,}
  529.     },
  530.  
  531.     { rule_any = { class  = { "Wrapper-2.0" } },
  532.     properties = {
  533.         floating = true,
  534.         border_width = 0,
  535.         titlebars_enabled = false,}
  536.     },
  537.  
  538.     { rule_any = { class = { "Xfce4-appfinder" } },
  539.     properties = {
  540.         floating = true,
  541.         titlebars_enabled = false,}
  542.     },
  543.  
  544.     -- Set Firefox to always map on the tag named "2" on screen 1.
  545.     -- { rule = { class = "Firefox" },
  546.     --   properties = { screen = 1, tag = "2" } },
  547. }
  548. -- }}}
  549.  
  550. -- {{{ Signals
  551. -- Signal function to execute when a new client appears.
  552. client.connect_signal("manage", function (c)
  553.     -- Set the windows at the slave,
  554.     -- i.e. put it at the end of others instead of setting it master.
  555.     -- if not awesome.startup then awful.client.setslave(c) end
  556.  
  557.     if awesome.startup
  558.       and not c.size_hints.user_position
  559.       and not c.size_hints.program_position then
  560.         -- Prevent clients from being unreachable after screen count changes.
  561.         awful.placement.no_offscreen(c)
  562.     end
  563. end)
  564.  
  565. -- Add a titlebar if titlebars_enabled is set to true in the rules.
  566. client.connect_signal("request::titlebars", function(c)
  567.     -- buttons for the titlebar
  568.     local buttons = gears.table.join(
  569.         awful.button({ }, 1, function()
  570.             c:emit_signal("request::activate", "titlebar", {raise = true})
  571.             awful.mouse.client.move(c)
  572.         end),
  573.         awful.button({ }, 3, function()
  574.             c:emit_signal("request::activate", "titlebar", {raise = true})
  575.             awful.mouse.client.resize(c)
  576.         end)
  577.     )
  578.  
  579.     awful.titlebar(c, { size = 15 }) : setup {
  580.         { -- Left
  581.             awful.titlebar.widget.stickybutton   (c),
  582.             awful.titlebar.widget.ontopbutton    (c),
  583.             -- buttons = buttons,
  584.             layout  = wibox.layout.fixed.horizontal
  585.         },
  586.         { -- Middle
  587.            --[[ { -- Title
  588.                 align  = "center",
  589.                 widget = awful.titlebar.widget.titlewidget(c)
  590.             }, --]]
  591.             buttons = buttons,
  592.             layout  = wibox.layout.flex.horizontal
  593.         },
  594.         { -- Right
  595.             awful.titlebar.widget.floatingbutton (c),
  596.             awful.titlebar.widget.maximizedbutton(c),
  597.             awful.titlebar.widget.closebutton    (c),
  598.             layout = wibox.layout.fixed.horizontal()
  599.         },
  600.         layout = wibox.layout.align.horizontal
  601.     }
  602. end)
  603.  
  604. -- Enable sloppy focus, so that focus follows mouse.
  605. client.connect_signal("mouse::enter", function(c)
  606.     c:emit_signal("request::activate", "mouse_enter", {raise = false})
  607. end)
  608.  
  609. client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  610. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  611.  
  612. -- Titlebars only on floating windows
  613. client.connect_signal("property::floating", function(c)
  614.     if c.floating and c._request_titlebars_called then
  615.         awful.titlebar.show(c)
  616.     else
  617.         awful.titlebar.hide(c)
  618.     end
  619. end)
  620.  
  621. function dynamic_title(c)
  622.     if c.floating or c.first_tag.layout.name == "floating" and c._request_titlebars_called then
  623.         awful.titlebar.show(c)
  624.     else
  625.         awful.titlebar.hide(c)
  626.     end
  627. end
  628.  
  629. tag.connect_signal("property::layout", function(t)
  630.     local clients = t:clients()
  631.     for k,c in pairs(clients) do
  632.         if c.floating or c.first_tag.layout.name == "floating" and c._request_titlebars_called then
  633.             awful.titlebar.show(c)
  634.         else
  635.             awful.titlebar.hide(c)
  636.         end
  637.     end
  638. end)
  639.  
  640. client.connect_signal("manage", dynamic_title)
  641.  
  642. client.connect_signal("tagged", dynamic_title)
  643.  
  644. -- Autostart
  645. -- awful.util.spawn("xfce4-panel --disable-wm-check")
  646. awful.util.spawn("picom")
  647.  
Advertisement
Add Comment
Please, Sign In to add comment