diff --git a/nix/checks.ulu.nix b/nix/checks.ulu.nix index aedd066..c5829be 100644 --- a/nix/checks.ulu.nix +++ b/nix/checks.ulu.nix @@ -32,6 +32,8 @@ { nativeBuildInputs = [ pkgs.file + pkgs.grim + pkgs.imagemagick pkgs.sway-unwrapped valw ]; @@ -63,6 +65,34 @@ file shot.png | tee file.txt grep -q 'PNG image data, 1280 x 720' file.txt + # Preview. The background is solid black, so a thumbnail in the + # bottom-right corner shows up as more than one colour there. + mkdir -p $HOME/.config/valw + printf '[preview]\ntimeout_secs = 2\n' > $HOME/.config/valw/config.toml + socket=$XDG_RUNTIME_DIR/valw.sock + corner() { magick "$1" -crop 300x200+980+520 +repage -format '%k' info:; } + wait_for() { # $1: test expression, $2: tenths of a second + for _ in $(seq "$2"); do eval "$1" && return 0; sleep 0.1; done + echo "timed out waiting for: $1" + exit 1 + } + + valw screen > /dev/null + wait_for '[ -S $socket ]' 10 + sleep 0.5 + grim with-thumbnail.png + [ "$(corner with-thumbnail.png)" -gt 1 ] || { echo "thumbnail not visible"; exit 1; } + valw screen --no-preview -o hidden.png > /dev/null + [ "$(corner hidden.png)" -eq 1 ] || { echo "thumbnail ended up in a screenshot"; exit 1; } + wait_for '[ ! -S $socket ]' 40 + + valw screen --no-preview > /dev/null + sleep 1 + if [ -S $socket ]; then + echo "--no-preview started a host" + exit 1 + fi + touch $out ''; }; diff --git a/nix/package.ulu.nix b/nix/package.ulu.nix index af1db0a..ef5754b 100644 --- a/nix/package.ulu.nix +++ b/nix/package.ulu.nix @@ -21,7 +21,10 @@ cargoLock.lockFile = ../Cargo.lock; - nativeBuildInputs = [ pkgs.pkg-config ]; + nativeBuildInputs = [ + pkgs.makeWrapper + pkgs.pkg-config + ]; buildInputs = [ pkgs.libxkbcommon pkgs.wayland @@ -30,6 +33,11 @@ # Tests run through `nix flake check` instead. doCheck = false; + # Clicking a preview opens Satty. --suffix keeps a user's own Satty first. + postInstall = '' + wrapProgram $out/bin/valw --suffix PATH : ${lib.makeBinPath [ pkgs.satty ]} + ''; + meta = { description = "macOS-style screenshots for niri"; mainProgram = "valw";