0

I have a certain picture I want to turn into my titlebar background, but I don't know how to make it strech so it fits the entire titlebar. Any advice?

Oval
  • 37
  • 8
  • 1
    What exactly do you mean with "stretch" here? Do you want it to scale up keeping the aspect ratio? Not keeping the aspect ratio? What should happen if the image is larger than the titlebar? Basically, could you show an example of what the image looks like and what the titlebar background should look like. – Uli Schlachter Mar 20 '19 at 17:48

2 Answers2

1

Here is a patch to the default config which makes titlebars have a background from a file. The file is scaled to the exact size of the titlebar.

diff --git a/awesomerc.lua b/awesomerc.lua
index fa584b8a8..3e3a54c0d 100644
--- a/awesomerc.lua
+++ b/awesomerc.lua
@@ -542,6 +542,14 @@ client.connect_signal("manage", function (c)
     end
 end)

+local tb_bg_image = gears.surface("/tmp/variant_outside.png")
+local bg_width, bg_height = gears.surface.get_size(tb_bg_image)
+local function bg_image_function(_, cr, width, height)
+    cr:scale(width / bg_width, height / bg_height)
+    cr:set_source_surface(tb_bg_image)
+    cr:paint()
+end
+
 -- @DOC_TITLEBARS@
 -- Add a titlebar if titlebars_enabled is set to true in the rules.
 client.connect_signal("request::titlebars", function(c)
@@ -557,7 +565,8 @@ client.connect_signal("request::titlebars", function(c)
         end)
     )

-    awful.titlebar(c) : setup {
+    local args = { bgimage_normal = bg_image_function, bgimage_focus = bg_image_function }
+    awful.titlebar(c, args) : setup {
         { -- Left
             awful.titlebar.widget.iconwidget(c),
             buttons = buttons,
Uli Schlachter
  • 9,337
  • 1
  • 23
  • 39
0

Is something like the following change to the default config what you are after? (Of course, use another file name)

diff --git a/awesomerc.lua b/awesomerc.lua
index fa584b8a8..7e6ccad55 100644
--- a/awesomerc.lua
+++ b/awesomerc.lua
@@ -557,7 +557,9 @@ client.connect_signal("request::titlebars", function(c)
         end)
     )

-    awful.titlebar(c) : setup {
+    local bg = { type = "png", file = "/tmp/variant_outside.png" }
+    local args = { bg_normal = bg, bg_focus = bg }
+    awful.titlebar(c, args) : setup {
         { -- Left
             awful.titlebar.widget.iconwidget(c),
             buttons = buttons,
Uli Schlachter
  • 9,337
  • 1
  • 23
  • 39
  • No, my problem is not giving the titlebar a background image, it's that the background image doesn't stretch properly over the titlebar. – Oval Mar 20 '19 at 09:44
  • 1
    Ah, sorry. I misread. Somehow I thought you wanted it *not* to stretch. – Uli Schlachter Mar 20 '19 at 17:46