Skip to content

Commit

Permalink
feat: wip screenshots ci
Browse files Browse the repository at this point in the history
  • Loading branch information
aarondill committed Aug 6, 2024
1 parent 9a3f64e commit 5b50875
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions screenshot.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
require("rc")
--- Run with dbus-run-session -- xvfb-run --server-args="-screen 0 1366x768x16. -ac -noreset" awesome -c ./screenshot.lua
local gtimer = require("gears.timer")
local path = require("util.path")
local Gio = require("util.lgi").Gio
local capi = require("capi")
local default = require("configuration.apps.default")
local gfilesystem = require("gears.filesystem")
local open = require("configuration.apps.open")
local spawn = require("util.spawn")

require("naughty").suspend()

local function doscreenshot(file, cb)
file = path.join(gfilesystem.get_configuration_dir(), file)
print("Taking screenshot of " .. file)
Gio.File.new_for_path(file):delete()
return spawn.spawn({ "flameshot", "full", "-p", file }, { exit_callback = cb })
end

local await = require("await")
local sleep = function(t)
await(function(resolve) gtimer.start_new(t, resolve) end)
end
local function screenshot(file)
await(function(resolve) doscreenshot(file, resolve) end)
end

default.terminal = { "xterm", "-bg", "black", "-fg", "white" }
gtimer.start_new(
2,
coroutine.wrap(function()
require("configuration.apps.compositor").spawn()
print("Starting screenshot")
--- Rofi.png
local info = require("configuration.apps.open").rofi()
if not info then error("Failed to open rofi") end
sleep(1)
screenshot("theme/images/rofi.png")
print("Killing rofi")
capi.awesome.kill(info.pid, capi.awesome.unix_signal.SIGTERM)

---Exit-screen.png
print("Showing exit-screen")
require("module.exit-screen").show()
sleep(1)
screenshot("theme/images/exit-screen.png")
print("Hiding exit-screen")
require("module.exit-screen").hide()

--- Fullscreen.png
print("Spawning fullscreen")
local info = open.terminal(nil, { sn_rules = { full_screen = true } })
sleep(5)
if not info then error("Failed to spawn xterm") end
screenshot("theme/images/fullscreen.png")
print("Killing fullscreen")
capi.awesome.kill(info.pid, capi.awesome.unix_signal.SIGTERM)

--- Demo.png
local pids = {
assert(open.terminal(nil)).pid,
assert(open.terminal("htop", { sn_rules = { full_screen = true } })).pid,
assert(open.editor(nil, { sn_rules = { full_screen = true } })).pid,
}
sleep(20)
screenshot("theme/images/demo.png")
for _, pid in ipairs(pids) do
capi.awesome.kill(pid, capi.awesome.unix_signal.SIGTERM)
end

capi.awesome.quit()
end)
)
Binary file modified theme/images/demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified theme/images/exit-screen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified theme/images/fullscreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified theme/images/rofi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5b50875

Please sign in to comment.