tests: Add awful.wallpaper tests

This commit is contained in:
Emmanuel Lepage Vallee 2021-06-14 01:09:18 -07:00
parent 580f16b7ff
commit 6b7ecc51f8
29 changed files with 1421 additions and 44 deletions

View File

@ -0,0 +1,48 @@
--DOC_GEN_IMAGE --DOC_HIDE_ALL
local awful = { wallpaper = require("awful.wallpaper") }
local wibox = require("wibox")
local gears = {color = require("gears.color") }
screen._track_workarea = true
screen[1]._resize {x = 0, y = 0, width = 160, height = 96}
screen._add_screen {x = 161, y = 0, width = 160, height = 96}
screen._add_screen {x = 322, y = 0, width = 160, height = 96}
require("_default_look")
awful.wallpaper {
screen = screen[1], --DOC_HIDE
bg = "#222222",
widget = wibox.widget {
{
fit = function(_, width, height)
return width, height
end,
draw = function(_, _, cr, width, height)
cr:set_source(gears.color("#0000ff"))
cr:line_to(width, height)
cr:line_to(width, 0)
cr:line_to(0, 0)
cr:close_path()
cr:fill()
cr:set_source(gears.color("#ff00ff"))
cr:move_to(0, 0)
cr:line_to(0, height)
cr:line_to(width, height)
cr:close_path()
cr:fill()
end,
widget = wibox.widget.base.make_widget()
},
{
text = "Center",
valign = "center",
align = "center",
widget = wibox.widget.textbox,
},
widget = wibox.layout.stack
}
}
require("gears.timer").run_delayed_calls_now()

View File

@ -0,0 +1,50 @@
--DOC_GEN_IMAGE --DOC_HIDE_ALL
local awful = { wallpaper = require("awful.wallpaper") }
local wibox = require("wibox")
local gears = {color = require("gears.color") }
screen._track_workarea = true
screen[1]._resize {x = 0, y = 0, width = 160, height = 96}
screen._add_screen {x = 161, y = 0, width = 160, height = 96}
screen._add_screen {x = 322, y = 0, width = 160, height = 96}
require("_default_look")
local wall = awful.wallpaper {
screen = screen[1], --DOC_HIDE
bg = "#222222",
widget = wibox.widget {
{
fit = function(_, width, height)
return width, height
end,
draw = function(_, _, cr, width, height)
cr:set_source(gears.color("#0000ff"))
cr:line_to(width, height)
cr:line_to(width, 0)
cr:line_to(0, 0)
cr:close_path()
cr:fill()
cr:set_source(gears.color("#ff00ff"))
cr:move_to(0, 0)
cr:line_to(0, height)
cr:line_to(width, height)
cr:close_path()
cr:fill()
end,
widget = wibox.widget.base.make_widget()
},
{
text = "Center",
valign = "center",
align = "center",
widget = wibox.widget.textbox,
},
widget = wibox.layout.stack
}
}
wall:add_screen(screen[2])
require("gears.timer").run_delayed_calls_now() --DOC_HIDE

View File

@ -0,0 +1,51 @@
--DOC_GEN_IMAGE
--DOC_HIDE_ALL
local awful = { wallpaper = require("awful.wallpaper") }
local wibox = require("wibox")
local gears = {color = require("gears.color") }
screen._track_workarea = true
screen[1]._resize {x = 0, y = 0, width = 160, height = 96}
screen._add_screen {x = 161, y = 0, width = 160, height = 96}
screen._add_screen {x = 322, y = 0, width = 160, height = 96}
require("_default_look")
local wall = awful.wallpaper {
screen = screen[1], --DOC_HIDE
bg = "#222222",
widget = wibox.widget {
{
fit = function(_, width, height)
return width, height
end,
draw = function(_, _, cr, width, height)
cr:set_source(gears.color("#0000ff"))
cr:line_to(width, height)
cr:line_to(width, 0)
cr:line_to(0, 0)
cr:close_path()
cr:fill()
cr:set_source(gears.color("#ff00ff"))
cr:move_to(0, 0)
cr:line_to(0, height)
cr:line_to(width, height)
cr:close_path()
cr:fill()
end,
widget = wibox.widget.base.make_widget()
},
{
text = "Center",
valign = "center",
align = "center",
widget = wibox.widget.textbox,
},
widget = wibox.layout.stack
}
}
wall:add_screen(screen[3])
require("gears.timer").run_delayed_calls_now()

View File

@ -0,0 +1,30 @@
--DOC_NO_USAGE --DOC_GEN_IMAGE
local awful = { --DOC_HIDE
wallpaper = require("awful.wallpaper"), --DOC_HIDE
placement = require("awful.placement"), --DOC_HIDE
} --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
local beautiful = require("beautiful") --DOC_HIDE
screen[1]._resize {x = 0, y = 0, width = 320, height = 196} --DOC_HIDE
awful.wallpaper {
screen = screen[1], --DOC_HIDE
bg = "#000000",
widget = {
{
{
image = beautiful.awesome_icon,
resize = false,
point = awful.placement.bottom_right,
widget = wibox.widget.imagebox,
},
widget = wibox.layout.manual,
},
margins = 5,
widget = wibox.container.margin
}
}
require("gears.timer").run_delayed_calls_now() --DOC_HIDE

View File

@ -0,0 +1,57 @@
--DOC_GEN_IMAGE
--DOC_HIDE_START
local awful = { wallpaper = require("awful.wallpaper") }
local wibox = require("wibox")
local gears = {color = require("gears.color") }
screen._track_workarea = true
screen[1]._resize {x = 0, y = 0, width = 160, height = 96}
screen._add_screen {x = 161, y = 0, width = 160, height = 96}
screen._add_screen {x = 322, y = 0, width = 160, height = 96}
require("_default_look")
--DOC_HIDE_END
for s in screen do
local dpi = s.index * 100
--DOC_NEWLINE
awful.wallpaper {
screen = s,
dpi = dpi,
widget = wibox.widget {
--DOC_HIDE_START
{
fit = function(_, width, height)
return width, height
end,
draw = function(_, _, cr, width, height)
cr:set_source(gears.color("#0000ff"))
cr:line_to(width, height)
cr:line_to(width, 0)
cr:line_to(0, 0)
cr:close_path()
cr:fill()
cr:set_source(gears.color("#ff00ff"))
cr:move_to(0, 0)
cr:line_to(0, height)
cr:line_to(width, height)
cr:close_path()
cr:fill()
end,
widget = wibox.widget.base.make_widget()
},
{
--DOC_HIDE_END
text = "DPI: " .. dpi,
valign = "center",
align = "center",
widget = wibox.widget.textbox,
}, --DOC_HIDE
widget = wibox.layout.stack --DOC_HIDE
} --DOC_HIDE
}
end
require("gears.timer").run_delayed_calls_now() --DOC_HIDE

View File

@ -0,0 +1,20 @@
--DOC_NO_USAGE --DOC_GEN_IMAGE
local awful = { wallpaper = require("awful.wallpaper") } --DOC_HIDE
screen[1]._resize {x = 0, y = 0, width = 320, height = 196} --DOC_HIDE
awful.wallpaper {
screen = screen[1], --DOC_HIDE
bg = {
type = "linear" ,
from = { 0, 0 },
to = { 0, 240 },
stops = {
{ 0, "#0000ff" },
{ 1, "#ff0000" }
}
}
}
require("gears.timer").run_delayed_calls_now() --DOC_HIDE

View File

@ -0,0 +1,21 @@
--DOC_NO_USAGE --DOC_GEN_IMAGE
local awful = { wallpaper = require("awful.wallpaper") } --DOC_HIDE
screen[1]._resize {x = 0, y = 0, width = 320, height = 196} --DOC_HIDE
awful.wallpaper {
screen = screen[1], --DOC_HIDE
bg = {
type = "radial",
from = { 160, 98, 20 },
to = { 160, 98, 120 },
stops = {
{ 0 , "#ff0000" },
{ 0.5, "#00ff00" },
{ 1 , "#0000ff" },
}
}
}
require("gears.timer").run_delayed_calls_now() --DOC_HIDE

View File

@ -0,0 +1,23 @@
--DOC_NO_USAGE --DOC_GEN_IMAGE
local awful = { wallpaper = require("awful.wallpaper") } --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
local beautiful = require("beautiful") --DOC_HIDE
awful.wallpaper {
screen = screen[1], --DOC_HIDE
widget = {
{
image = beautiful.wallpaper,
resize = true,
widget = wibox.widget.imagebox,
},
valign = "center",
halign = "center",
tiled = false,
widget = wibox.container.tile,
}
}
require("gears.timer").run_delayed_calls_now() --DOC_HIDE

View File

@ -0,0 +1,25 @@
--DOC_NO_USAGE --DOC_GEN_IMAGE
local awful = { wallpaper = require("awful.wallpaper") } --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
local beautiful = require("beautiful") --DOC_HIDE
screen[1]._resize {x = 0, y = 0, width = 320, height = 196} --DOC_HIDE
awful.wallpaper {
screen = screen[1], --DOC_HIDE
bg = "#0000ff",
widget = {
{
image = beautiful.wallpaper,
resize = true,
widget = wibox.widget.imagebox,
},
valign = "center",
halign = "center",
tiled = false,
widget = wibox.container.tile,
}
}
require("gears.timer").run_delayed_calls_now() --DOC_HIDE

View File

@ -0,0 +1,20 @@
--DOC_NO_USAGE --DOC_GEN_IMAGE
local awful = { wallpaper = require("awful.wallpaper") } --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
local beautiful = require("beautiful") --DOC_HIDE
screen[1]._resize {x = 0, y = 0, width = 320, height = 196} --DOC_HIDE
awful.wallpaper {
screen = screen[1], --DOC_HIDE
widget = {
horizontal_fit_policy = "fit",
vertical_fit_policy = "fit",
image = beautiful.wallpaper,
widget = wibox.widget.imagebox,
},
}
require("gears.timer").run_delayed_calls_now() --DOC_HIDE

View File

@ -0,0 +1,58 @@
--DOC_GEN_IMAGE --DOC_GEN_OUTPUT
--DOC_HIDE_START
local awful = { wallpaper = require("awful.wallpaper") }
local wibox = require("wibox")
local gears = {color = require("gears.color") }
screen._track_workarea = true
screen[1]._resize {x = 0, y = 0, width = 320, height = 196}
require("_default_look")
--DOC_HIDE_END
-- Add some padding to the first screen.
screen[1].padding = {
left = 30,
right = 10,
}
--DOC_NEWLINE
local wall = awful.wallpaper {
screen = screen[1],
honor_workarea = true,
honor_padding = true,
bg = "#222222",
uncovered_areas_color = "#ff0000",
widget = wibox.widget {
fit = function(_, width, height)
return width, height
end,
draw = function(_, _, cr, width, height)
local radius = math.min(width, height)/2
cr:arc(width/2, height/2, radius, 0, 2 * math.pi)
cr:set_source(gears.color {
type = "radial",
from = { width/2, radius, 20 },
to = { width/2, radius, 120 },
stops = {
{ 0, "#0000ff" },
{ 1, "#ff0000" },
{ 1, "#000000" },
}
})
cr:fill()
end,
widget = wibox.widget.base.make_widget()
}
}
--DOC_HIDE_START
require("gears.timer").run_delayed_calls_now()
--DOC_HIDE_END
--DOC_NEWLINE
-- Areas due to the padding and the wibar (workarea).
for _, area in ipairs(wall.uncovered_areas) do
print("Uncovered area:", area.x, area.y, area.width, area.height)
end

View File

@ -0,0 +1,3 @@
Uncovered area: 0 0 30 196
Uncovered area: 0 0 320 14
Uncovered area: 310 0 10 196

View File

@ -0,0 +1,86 @@
--DOC_GEN_IMAGE --DOC_GEN_OUTPUT --DOC_NO_USAGE
--DOC_HIDE_START
local awful = { wallpaper = require("awful.wallpaper") }
local wibox = require("wibox")
local gears = {color = require("gears.color") }
screen._track_workarea = true
screen[1]._resize {x = 0, y = 97, width = 96, height = 160}
screen._add_screen {x = 97, y = 129, width = 160, height = 96}
screen._add_screen {x = 258, y = 97,width = 96, height = 160}
screen._add_screen {x = 370, y = 0,width = 160, height = 96}
screen._add_screen {x = 402, y = 97,width = 96, height = 160}
screen._add_screen {x = 370, y = 258,width = 160, height = 96}
require("_default_look")
local walls = {}
--DOC_HIDE_END
local function custom_panning_area(wallpaper)
return {
x = wallpaper.screens[1].geometry.x + 50,
y = wallpaper.screens[2].geometry.y + 50,
width = 96,
height = 96,
}
end
--DOC_HIDE_START
for i=0, 1 do
walls[i+1] = awful.wallpaper {
screens = {
screen[i*3 + 1],
screen[i*3 + 2],
screen[i*3 + 3],
},
bg = "#222222",
panning_area = custom_panning_area,
uncovered_areas_color = "#222222",
widget = wibox.widget {
{
fit = function(_, width, height)
return width, height
end,
draw = function(_, _, cr, width, height)
cr:set_source(gears.color("#0000ff"))
cr:line_to(width, height)
cr:line_to(width, 0)
cr:line_to(0, 0)
cr:close_path()
cr:fill()
cr:set_source(gears.color("#ff00ff"))
cr:move_to(0, 0)
cr:line_to(0, height)
cr:line_to(width, height)
cr:close_path()
cr:fill()
end,
widget = wibox.widget.base.make_widget()
},
{
text = "Center",
valign = "center",
align = "center",
widget = wibox.widget.textbox,
},
widget = wibox.layout.stack
}
}
end
require("gears.timer").run_delayed_calls_now()
--DOC_HIDE_END
--DOC_NEWLINE
-- Areas due to the padding and the wibar (workarea).
for k, wall in ipairs(walls) do
for _, area in ipairs(wall.uncovered_areas) do
print("Uncovered wallpaper #".. k .." area:", area.x, area.y, area.width, area.height)
end
end

View File

@ -0,0 +1,60 @@
--DOC_GEN_IMAGE --DOC_HIDE_ALL --DOC_NO_USAGE
local awful = { wallpaper = require("awful.wallpaper") }
local wibox = require("wibox")
local gears = {color = require("gears.color") }
screen._track_workarea = true
screen[1]._resize {x = 0, y = 97, width = 96, height = 160}
screen._add_screen {x = 97, y = 129, width = 160, height = 96}
screen._add_screen {x = 258, y = 97,width = 96, height = 160}
screen._add_screen {x = 370, y = 0,width = 160, height = 96}
screen._add_screen {x = 402, y = 97,width = 96, height = 160}
screen._add_screen {x = 370, y = 258,width = 160, height = 96}
require("_default_look")
for i=0, 1 do
awful.wallpaper {
screens = {
screen[i*3 + 1],
screen[i*3 + 2],
screen[i*3 + 3],
},
bg = "#222222",
panning_area = "inner",
uncovered_areas_color = "#222222",
widget = wibox.widget {
{
fit = function(_, width, height)
return width, height
end,
draw = function(_, _, cr, width, height)
cr:set_source(gears.color("#0000ff"))
cr:line_to(width, height)
cr:line_to(width, 0)
cr:line_to(0, 0)
cr:close_path()
cr:fill()
cr:set_source(gears.color("#ff00ff"))
cr:move_to(0, 0)
cr:line_to(0, height)
cr:line_to(width, height)
cr:close_path()
cr:fill()
end,
widget = wibox.widget.base.make_widget()
},
{
text = "Center",
valign = "center",
align = "center",
widget = wibox.widget.textbox,
},
widget = wibox.layout.stack
}
}
end
require("gears.timer").run_delayed_calls_now() --DOC_HIDE

View File

@ -0,0 +1,60 @@
--DOC_GEN_IMAGE --DOC_HIDE_ALL --DOC_NO_USAGE
local awful = { wallpaper = require("awful.wallpaper") }
local wibox = require("wibox")
local gears = {color = require("gears.color") }
screen._track_workarea = true
screen[1]._resize {x = 0, y = 97, width = 96, height = 160}
screen._add_screen {x = 97, y = 129, width = 160, height = 96}
screen._add_screen {x = 258, y = 97,width = 96, height = 160}
screen._add_screen {x = 370, y = 0,width = 160, height = 96}
screen._add_screen {x = 402, y = 97,width = 96, height = 160}
screen._add_screen {x = 370, y = 258,width = 160, height = 96}
require("_default_look")
for i=0, 1 do
awful.wallpaper {
screens = {
screen[i*3 + 1],
screen[i*3 + 2],
screen[i*3 + 3],
},
bg = "#222222",
panning_area = "inner_horizontal",
uncovered_areas_color = "#222222",
widget = wibox.widget {
{
fit = function(_, width, height)
return width, height
end,
draw = function(_, _, cr, width, height)
cr:set_source(gears.color("#0000ff"))
cr:line_to(width, height)
cr:line_to(width, 0)
cr:line_to(0, 0)
cr:close_path()
cr:fill()
cr:set_source(gears.color("#ff00ff"))
cr:move_to(0, 0)
cr:line_to(0, height)
cr:line_to(width, height)
cr:close_path()
cr:fill()
end,
widget = wibox.widget.base.make_widget()
},
{
text = "Center",
valign = "center",
align = "center",
widget = wibox.widget.textbox,
},
widget = wibox.layout.stack
}
}
end
require("gears.timer").run_delayed_calls_now() --DOC_HIDE

View File

@ -0,0 +1,60 @@
--DOC_GEN_IMAGE --DOC_HIDE_ALL --DOC_NO_USAGE
local awful = { wallpaper = require("awful.wallpaper") }
local wibox = require("wibox")
local gears = {color = require("gears.color") }
screen._track_workarea = true
screen[1]._resize {x = 0, y = 97, width = 96, height = 160}
screen._add_screen {x = 97, y = 129, width = 160, height = 96}
screen._add_screen {x = 258, y = 97,width = 96, height = 160}
screen._add_screen {x = 370, y = 0,width = 160, height = 96}
screen._add_screen {x = 402, y = 97,width = 96, height = 160}
screen._add_screen {x = 370, y = 258,width = 160, height = 96}
require("_default_look")
for i=0, 1 do
awful.wallpaper {
screens = {
screen[i*3 + 1],
screen[i*3 + 2],
screen[i*3 + 3],
},
bg = "#222222",
panning_area = "inner_vertical",
uncovered_areas_color = "#222222",
widget = wibox.widget {
{
fit = function(_, width, height)
return width, height
end,
draw = function(_, _, cr, width, height)
cr:set_source(gears.color("#0000ff"))
cr:line_to(width, height)
cr:line_to(width, 0)
cr:line_to(0, 0)
cr:close_path()
cr:fill()
cr:set_source(gears.color("#ff00ff"))
cr:move_to(0, 0)
cr:line_to(0, height)
cr:line_to(width, height)
cr:close_path()
cr:fill()
end,
widget = wibox.widget.base.make_widget()
},
{
text = "Center",
valign = "center",
align = "center",
widget = wibox.widget.textbox,
},
widget = wibox.layout.stack
}
}
end
require("gears.timer").run_delayed_calls_now() --DOC_HIDE

View File

@ -0,0 +1,58 @@
--DOC_GEN_IMAGE --DOC_HIDE_ALL --DOC_NO_USAGE
local awful = { wallpaper = require("awful.wallpaper") }
local wibox = require("wibox")
local gears = {color = require("gears.color") }
screen._track_workarea = true
screen[1]._resize {x = 0, y = 97, width = 96, height = 160}
screen._add_screen {x = 97, y = 129, width = 160, height = 96}
screen._add_screen {x = 258, y = 97,width = 96, height = 160}
screen._add_screen {x = 370, y = 0,width = 160, height = 96}
screen._add_screen {x = 402, y = 97,width = 96, height = 160}
screen._add_screen {x = 370, y = 258,width = 160, height = 96}
require("_default_look")
for i=0, 1 do
awful.wallpaper {
screens = {
screen[i*3 + 1],
screen[i*3 + 2],
screen[i*3 + 3],
},
bg = "#222222",
widget = wibox.widget {
{
fit = function(_, width, height)
return width, height
end,
draw = function(_, _, cr, width, height)
cr:set_source(gears.color("#0000ff"))
cr:line_to(width, height)
cr:line_to(width, 0)
cr:line_to(0, 0)
cr:close_path()
cr:fill()
cr:set_source(gears.color("#ff00ff"))
cr:move_to(0, 0)
cr:line_to(0, height)
cr:line_to(width, height)
cr:close_path()
cr:fill()
end,
widget = wibox.widget.base.make_widget()
},
{
text = "Center",
valign = "center",
align = "center",
widget = wibox.widget.textbox,
},
widget = wibox.layout.stack
}
}
end
require("gears.timer").run_delayed_calls_now() --DOC_HIDE

View File

@ -0,0 +1,53 @@
--DOC_GEN_IMAGE --DOC_NO_USAGE
--DOC_HIDE_START
local awful = { wallpaper = require("awful.wallpaper") }
local wibox = require("wibox")
local gears = {color = require("gears.color") }
screen._track_workarea = true
screen[1]._resize {x = 0, y = 0, width = 160, height = 96}
screen._add_screen {x = 161, y = 0, width = 160, height = 96}
screen._add_screen {x = 322, y = 0, width = 160, height = 96}
require("_default_look")
-- There is 3 screens. This will add the wallpaper to the last 2.
local wall = awful.wallpaper {
screens = screen,
bg = "#222222",
widget = wibox.widget {
{
fit = function(_, width, height)
return width, height
end,
draw = function(_, _, cr, width, height)
cr:set_source(gears.color("#0000ff"))
cr:line_to(width, height)
cr:line_to(width, 0)
cr:line_to(0, 0)
cr:close_path()
cr:fill()
cr:set_source(gears.color("#ff00ff"))
cr:move_to(0, 0)
cr:line_to(0, height)
cr:line_to(width, height)
cr:close_path()
cr:fill()
end,
widget = wibox.widget.base.make_widget()
},
{
text = "Center",
valign = "center",
align = "center",
widget = wibox.widget.textbox,
},
widget = wibox.layout.stack
}
}
require("gears.timer").run_delayed_calls_now()
--DOC_HIDE_END
wall:remove_screen(screen[1])
require("gears.timer").run_delayed_calls_now() --DOC_HIDE

View File

@ -0,0 +1,58 @@
--DOC_GEN_IMAGE --DOC_NO_USAGE
--DOC_HIDE_START
local awful = { wallpaper = require("awful.wallpaper") }
local wibox = require("wibox")
local gears = {color = require("gears.color") }
screen._track_workarea = true
screen[1]._resize {x = 0, y = 0, width = 160, height = 96}
screen._add_screen {x = 161, y = 0, width = 160, height = 96}
screen._add_screen {x = 322, y = 0, width = 160, height = 96}
require("_default_look")
-- There is 3 screens. This will add the wallpaper to the last 2.
awful.wallpaper {
screens = screen,
bg = "#222222",
widget = wibox.widget {
{
fit = function(_, width, height)
return width, height
end,
draw = function(_, _, cr, width, height)
cr:set_source(gears.color("#0000ff"))
cr:line_to(width, height)
cr:line_to(width, 0)
cr:line_to(0, 0)
cr:close_path()
cr:fill()
cr:set_source(gears.color("#ff00ff"))
cr:move_to(0, 0)
cr:line_to(0, height)
cr:line_to(width, height)
cr:close_path()
cr:fill()
end,
widget = wibox.widget.base.make_widget()
},
{
text = "Center",
valign = "center",
align = "center",
widget = wibox.widget.textbox,
},
widget = wibox.layout.stack
}
}
require("gears.timer").run_delayed_calls_now()
--DOC_HIDE_END
awful.wallpaper {
screen = screen[1],
bg = "#00ffff",
}
require("gears.timer").run_delayed_calls_now() --DOC_HIDE

View File

@ -0,0 +1,54 @@
--DOC_GEN_IMAGE
--DOC_HIDE_START
local awful = { wallpaper = require("awful.wallpaper") }
local wibox = require("wibox")
local gears = {color = require("gears.color") }
screen._track_workarea = true
screen[1]._resize {x = 0, y = 0, width = 160, height = 96}
screen._add_screen {x = 161, y = 0, width = 160, height = 96}
screen._add_screen {x = 322, y = 0, width = 160, height = 96}
require("_default_look")
--DOC_HIDE_END
-- There is 3 screens. This will add the wallpaper to the last 2.
awful.wallpaper {
screens = {
screen[2],
screen[3],
},
bg = "#222222",
widget = wibox.widget {
{
fit = function(_, width, height)
return width, height
end,
draw = function(_, _, cr, width, height)
cr:set_source(gears.color("#0000ff"))
cr:line_to(width, height)
cr:line_to(width, 0)
cr:line_to(0, 0)
cr:close_path()
cr:fill()
cr:set_source(gears.color("#ff00ff"))
cr:move_to(0, 0)
cr:line_to(0, height)
cr:line_to(width, height)
cr:close_path()
cr:fill()
end,
widget = wibox.widget.base.make_widget()
},
{
text = "Center",
valign = "center",
align = "center",
widget = wibox.widget.textbox,
},
widget = wibox.layout.stack
}
}
require("gears.timer").run_delayed_calls_now() --DOC_HIDE

View File

@ -0,0 +1,45 @@
--DOC_NO_USAGE
local awful = { wallpaper = require("awful.wallpaper") } --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
local gears = {timer = require("gears.timer"), filesystem = require("gears.filesystem")}--DOC_HIDE
screen[1]._resize {x = 0, y = 0, width = 320, height = 196} --DOC_HIDE
-- The "request::wallpaper" section is already in the default
-- `rc.lua`, replace it with this.
screen.connect_signal("request::wallpaper", function(s)
awful.wallpaper {
screen = s,
bg = "#0000ff",
widget = {
{
image = gears.filesystem.get_random_file_from_dir(
"path/to/dir",
{".jpg", ".png", ".svg"},
true
),
resize = true,
widget = wibox.widget.imagebox,
},
valign = "center",
halign = "center",
tiled = false,
widget = wibox.container.tile,
}
}
end)
--DOC_NEWLINE
-- **Somewhere else** in the code, **not** in the `request::wallpaper` handler.
gears.timer {
timeout = 1800,
autostart = true,
callback = function()
for s in screen do
s:emit_signal("request::wallpaper")
end
end,
}
require("gears.timer").run_delayed_calls_now() --DOC_HIDE

View File

@ -0,0 +1,36 @@
--DOC_GEN_IMAGE --DOC_NO_USAGE --DOC_HIDE_START
local awful = { wallpaper = require("awful.wallpaper") }
local wibox = require("wibox")
screen[1]._resize {x = 0, y = 0, width = 320, height = 196}
--DOC_HIDE_END
local image = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'..
'<svg width="190" height="60">'..
'<rect x="10" y="10" width="50" height="50" />'..
'<rect x="70" y="10" width="50" height="50" class="my_class" />'..
'<rect x="130" y="10" width="50" height="50" id="my_id" />'..
'</svg>'
--DOC_NEWLINE
local stylesheet = "" ..
"rect { fill: #ffff00; } "..
".my_class { fill: #00ff00; } "..
"#my_id { fill: #0000ff; }"
--DOC_NEWLINE
awful.wallpaper {
screen = screen[1], --DOC_HIDE
widget = wibox.widget {
forced_height = 60, --DOC_HIDE
forced_width = 190, --DOC_HIDE
stylesheet = stylesheet,
image = image,
widget = wibox.widget.imagebox
}
}
--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,27 @@
--DOC_NO_USAGE --DOC_GEN_IMAGE
local awful = { wallpaper = require("awful.wallpaper") } --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
local beautiful = require("beautiful") --DOC_HIDE
screen[1]._resize {x = 0, y = 0, width = 320, height = 196} --DOC_HIDE
awful.wallpaper {
screen = screen[1], --DOC_HIDE
bg = "#0000ff",
widget = {
{
image = beautiful.awesome_icon,
resize = false,
widget = wibox.widget.imagebox,
},
horizontal_spacing = 5,
vertical_spacing = 5,
valign = "top",
halign = "left",
tiled = true,
widget = wibox.container.tile,
}
}
require("gears.timer").run_delayed_calls_now() --DOC_HIDE

View File

@ -0,0 +1,30 @@
--DOC_NO_USAGE --DOC_GEN_IMAGE
local awful = { wallpaper = require("awful.wallpaper") } --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
local gears = { shape = require("gears.shape") } --DOC_HIDE
screen[1]._resize {x = 0, y = 0, width = 320, height = 196} --DOC_HIDE
awful.wallpaper {
screen = screen[1], --DOC_HIDE
bg = "#0000ff",
widget = {
{
shape = gears.shape.star,
forced_width = 30,
forced_height = 30,
widget = wibox.widget.separator,
},
horizontal_spacing = 5,
vertical_spacing = 5,
vertical_crop = true,
horizontal_crop = true,
valign = "center",
halign = "center",
tiled = true,
widget = wibox.container.tile,
}
}
require("gears.timer").run_delayed_calls_now() --DOC_HIDE

View File

@ -0,0 +1,82 @@
--DOC_NO_USAGE --DOC_GEN_IMAGE
local awful = { wallpaper = require("awful.wallpaper") } --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
local gears = {color = require("gears.color") } --DOC_HIDE
screen[1]._resize {x = 0, y = 0, width = 320, height = 196} --DOC_HIDE
awful.wallpaper {
screen = screen[1], --DOC_HIDE
widget = wibox.widget {
fit = function(_, width, height)
return width, height
end,
draw = function(_, _, cr, width, height)
cr:set_source(gears.color {
type = 'linear',
from = { 0, 0 },
to = { 0, height },
stops = {
{ 0 , '#030d27' },
{ 0.75, '#3a183f' },
{ 0.75, '#000000' },
{ 1 , '#222222' }
}
})
cr:paint()
-- Clip the first 33% of the screen
cr:rectangle(0,0, width, height/3)
--DOC_NEWLINE
-- Clip-out some increasingly large sections of add the sun "bars"
for i=0, 6 do
cr:rectangle(0, height*.28 + i*(height*.055 + i/2), width, height*.055)
end
cr:clip()
--DOC_NEWLINE
-- Draw the sun
cr:set_source(gears.color {
type = 'linear' ,
from = { 0, 0 },
to = { 0, height },
stops = {
{ 0, '#f0d64f' },
{ 1, '#e484c6' }
}
})
cr:arc(width/2, height/2, height*.35, 0, math.pi*2)
cr:fill()
--DOC_NEWLINE
-- Draw the grid
local lines = width/8
cr:reset_clip()
cr:set_line_width(0.5)
cr:set_source(gears.color("#8922a3"))
--DOC_NEWLINE
for i=1, lines do
cr:move_to((-width) + i* math.sin(i * (math.pi/(lines*2)))*30, height)
cr:line_to(width/4 + i*((width/2)/lines), height*0.75 + 2)
cr:stroke()
end
--DOC_NEWLINE
for i=1, 5 do
cr:move_to(0, height*0.75 + i*10 + i*2)
cr:line_to(width, height*0.75 + i*10 + i*2)
cr:stroke()
end
end,
}
}
require("gears.timer").run_delayed_calls_now() --DOC_HIDE

View File

@ -0,0 +1,48 @@
--DOC_NO_USAGE --DOC_GEN_IMAGE
local awful = { wallpaper = require("awful.wallpaper") } --DOC_HIDE
local wibox = require("wibox") --DOC_HIDE
math.randomseed(1) --DOC_HIDE
screen[1]._resize {x = 0, y = 0, width = 320, height = 196} --DOC_HIDE
local function binary()
local ret = {}
for _=1, 15 do
for _=1, 57 do
table.insert(ret, math.random() > 0.5 and 1 or 0)
end
table.insert(ret, "\n")
end
return table.concat(ret)
end
--DOC_NEWLINE
awful.wallpaper {
screen = screen[1], --DOC_HIDE
bg = "#000000",
fg = "#55ff5577",
widget = wibox.widget {
{
{
markup = "<tt><b>[SYSTEM FAILURE]</b></tt>",
valign = "center",
align = "center",
widget = wibox.widget.textbox
},
fg = "#00ff00",
widget = wibox.container.background
},
{
wrap = "word",
text = binary(),
widget = wibox.widget.textbox,
},
widget = wibox.layout.stack
},
}
require("gears.timer").run_delayed_calls_now() --DOC_HIDE

View File

@ -0,0 +1,56 @@
--DOC_GEN_IMAGE --DOC_HIDE_ALL
local awful = { wallpaper = require("awful.wallpaper") }
local wibox = require("wibox")
local gears = {color = require("gears.color") }
screen._track_workarea = true
screen[1]._resize {x = 0, y = 0, width = 320, height = 196}
screen._add_screen {x = 330, y = 0, width = 320, height = 196}
require("_default_look")
screen.connect_signal("request::wallpaper", function(s)
awful.wallpaper {
screen = s,
honor_workarea = s.index == 2,
bg = "#222222",
widget = wibox.widget {
{
fit = function(_, width, height)
return width, height
end,
draw = function(_, _, cr, width, height)
local radius = math.min(width, height)/2
cr:arc(width/2, height/2, radius, 0, 2 * math.pi)
cr:set_source(gears.color {
type = "radial",
from = { width/2, radius, 20 },
to = { width/2, radius, 120 },
stops = {
{ 0, "#0000ff" },
{ 1, "#ff0000" },
{ 1, "#000000" },
}
})
cr:fill()
end,
widget = wibox.widget.base.make_widget()
},
{
text = "honor_workarea = " .. (s.index == 2 and "true" or "false"),
valign = "center",
align = "center",
widget = wibox.widget.textbox,
},
widget = wibox.layout.stack
}
}
end)
require("gears.timer").run_delayed_calls_now()
for s in screen do
s:emit_signal("request::wallpaper", s)
end
require("gears.timer").run_delayed_calls_now()

View File

@ -0,0 +1,13 @@
--DOC_NO_USAGE
local awful = { wallpaper = require("awful.wallpaper") } --DOC_HIDE
local global_wallpaper = awful.wallpaper {
-- [...] your content
}
--DOC_NEWLINE
screen.connect_signal("request::wallpaper", function()
-- `screen` is the global screen module. It is also a list of all screens.
global_wallpaper.screens = screen
end)

View File

@ -5,6 +5,9 @@ local wp = require("gears.wallpaper")
local color = require("gears.color")
local cairo = require( "lgi" ).cairo
local surface = require("gears.surface")
local awall = require("awful.wallpaper")
local beautiful = require("beautiful")
local wibox = require("wibox")
local steps = {}
@ -54,94 +57,236 @@ table.insert(steps, function()
end)
table.insert(steps, function()
wp.fit(img, screen[1], "#00ff00")
wp.fit(img, screen[1], "#00ff00")
-- There is a delayed call for the last call, let it be processed before
-- adding more
return true
-- There is a delayed call for the last call, let it be processed before
-- adding more
return true
end)
table.insert(steps, function()
wp.centered(img, nil, nil)
wp.centered(img, screen[1], nil)
wp.centered(img, nil, nil)
wp.centered(img, screen[1], nil)
-- There is a delayed call for the last call, let it be processed before
-- adding more
return true
-- There is a delayed call for the last call, let it be processed before
-- adding more
return true
end)
table.insert(steps, function()
wp.centered(img, screen[1], "#00ff00")
wp.centered(img, screen[1], "#00ff00")
return true
return true
end)
table.insert(steps, function()
wp.maximized(img, nil, nil, nil)
wp.maximized(img, nil, nil, nil)
-- There is a delayed call for the last call, let it be processed before
-- adding more
return true
-- There is a delayed call for the last call, let it be processed before
-- adding more
return true
end)
table.insert(steps, function()
wp.maximized(img, screen[1], nil, nil)
wp.maximized(img, screen[1], nil, nil)
-- There is a delayed call for the last call, let it be processed before
-- adding more
return true
-- There is a delayed call for the last call, let it be processed before
-- adding more
return true
end)
table.insert(steps, function()
wp.maximized(img, screen[1], false, nil)
wp.maximized(img, screen[1], true, nil)
wp.maximized(img, screen[1], false, nil)
wp.maximized(img, screen[1], true, nil)
-- There is a delayed call for the last call, let it be processed before
-- adding more
return true
-- There is a delayed call for the last call, let it be processed before
-- adding more
return true
end)
table.insert(steps, function()
wp.maximized(img, screen[1], false, {x=10, y= 10})
wp.maximized(img, screen[1], true, {x=10, y= 10})
wp.maximized(img, screen[1], false, {x=10, y= 10})
wp.maximized(img, screen[1], true, {x=10, y= 10})
return true
return true
end)
table.insert(steps, function()
wp.tiled(img, nil, nil)
wp.tiled(img, screen[1], nil)
wp.tiled(img, nil, nil)
wp.tiled(img, screen[1], nil)
-- There is a delayed call for the last call, let it be processed before
-- adding more
return true
-- There is a delayed call for the last call, let it be processed before
-- adding more
return true
end)
table.insert(steps, function()
wp.tiled(img, screen[1], {x=10, y= 10})
wp.tiled(img, screen[1], {x=10, y= 10})
return true
return true
end)
table.insert(steps, function()
for _, c in ipairs(colors) do
wp.set(c)
end
for _, c in ipairs(colors) do
wp.set(c)
end
return true
return true
end)
-- Make sure passing `nil` doesn't crash Awesome.
table.insert(steps, function()
root._wallpaper(nil)
root.wallpaper(nil)
root._wallpaper(nil)
root.wallpaper(nil)
return true
return true
end)
local walls = setmetatable({}, {__mode = "v"})
-- Test awful.wallpaper garbage collection.
table.insert(steps, function()
walls["first"] = awall {
screen = screen[1],
widget = {
{
image = beautiful.wallpaper,
upscale = true,
downscale = true,
widget = wibox.widget.imagebox,
},
valign = "center",
halign = "center",
tiled = false,
widget = wibox.container.tile,
}
}
collectgarbage("collect")
return true
end)
table.insert(steps, function(count)
if count < 3 then
collectgarbage("collect")
return
end
assert(walls["first"])
walls["second"] = awall {
screen = screen[1],
widget = {
{
image = beautiful.wallpaper,
upscale = true,
downscale = true,
widget = wibox.widget.imagebox,
},
valign = "center",
halign = "center",
tiled = false,
widget = wibox.container.tile,
}
}
return true
end)
local repaint_called, paint_width, paint_height = false, nil, nil
-- Test setting "after the fact"
table.insert(steps, function(count)
if count < 3 then
collectgarbage("collect")
return
end
assert(walls["second"])
assert(not walls["first"])
local real_repaint = walls["second"].repaint
walls["second"].repaint = function(self)
repaint_called = true
real_repaint(self)
end
walls["second"].widget = wibox.widget {
fit = function(_, w, h)
return w, h
end,
draw = function(self, ctx, cr2, width, height)
cr2:set_source_rgba(1, 0, 0, 0.5)
cr2:rectangle(0, 0, width/2, height/2)
cr2:fill()
paint_width, paint_height = width, height
assert((not self.dpi) and ctx.dpi)
end
}
walls["second"].bg = "#0000ff"
walls["second"].fg = "#00ff00"
assert(repaint_called)
-- This needs to happen after this event loop to avoid
-- painting the wallpaper many time in a row.
assert(not paint_width)
return true
end)
table.insert(steps, function()
assert(walls["second"])
assert(paint_width == screen[1].geometry.width)
assert(paint_height == screen[1].geometry.height)
repaint_called = false
paint_width, paint_height = nil, nil
-- Disable new wallpaper creation to prevent request::wallpaper from
-- replacing the wall.
local constructor = getmetatable(awall).__call
setmetatable(awall, {__call = function() end})
screen[1]:fake_resize(
10, 10, math.floor(screen[1].geometry.width/2), math.floor(screen[1].geometry.height/2)
)
assert(paint_height ~= screen[1].geometry.height)
assert(repaint_called)
setmetatable(awall, {__call = constructor})
return true
end)
table.insert(steps, function(count)
if count == 1 then return end
print(paint_width, paint_height, screen[1].geometry.width, screen[1].geometry.height)
assert(paint_width == screen[1].geometry.width)
assert(paint_height == screen[1].geometry.height)
walls["second"].dpi = 123
assert(walls["second"].dpi == 123)
walls["second"]:detach()
return true
end)
table.insert(steps, function(count)
if count < 3 then
collectgarbage("collect")
return
end
assert(not walls["second"])
return true
end)
runner.run_steps(steps)