ahfail locks the screen itself instead of hooking another locker: Wayland through ext-session-lock-v1 (gtk-session-lock), X11 through an input grab. It authenticates against its own PAM service, /etc/pam.d/ahfail, so a package never has to edit another package's PAM file. One command for every platform: ahfail (lock), ahfail test (the effect without locking) and ahfail doctor (what is missing, with the fix). Enter is handled directly and the entry uses no input method, since the Wayland text-input IM swallowed Return. Sprites avoid the password box in window coordinates, and placement gets 100 tries instead of 10. Claude-Session: https://claude.ai/code/session_012LCTmU2ewo8tnM1dByYAoG
51 lines
2.0 KiB
Rust
51 lines
2.0 KiB
Rust
use std::path::PathBuf;
|
|
use std::process::Command;
|
|
|
|
// Same GResource embedding as ahfail-display: the sprites and the audio clip are
|
|
// compiled into the binary, and ahfail_ui::animation looks them up through the
|
|
// `ahfail_get_resource` symbol that glib-compile-resources generates.
|
|
fn main() {
|
|
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
|
|
let workspace_root = manifest_dir.join("../..").canonicalize().unwrap();
|
|
let assets_dir = workspace_root.join("assets");
|
|
let gresource_xml = assets_dir.join("ahfail.gresource.xml");
|
|
let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap());
|
|
let c_src = out_dir.join("ahfail-resources.c");
|
|
|
|
println!("cargo:rerun-if-changed={}", gresource_xml.display());
|
|
for entry in std::fs::read_dir(&assets_dir).unwrap() {
|
|
println!("cargo:rerun-if-changed={}", entry.unwrap().path().display());
|
|
}
|
|
|
|
let status = Command::new("glib-compile-resources")
|
|
.args([
|
|
"--generate-source",
|
|
"--target",
|
|
c_src.to_str().unwrap(),
|
|
"--sourcedir",
|
|
assets_dir.to_str().unwrap(),
|
|
gresource_xml.to_str().unwrap(),
|
|
])
|
|
.status()
|
|
.expect("glib-compile-resources not found");
|
|
assert!(status.success(), "glib-compile-resources failed");
|
|
|
|
let gio = pkg_config::probe_library("gio-2.0").expect("gio-2.0 not found");
|
|
let mut build = cc::Build::new();
|
|
build.file(&c_src).flag_if_supported("-w");
|
|
for inc in &gio.include_paths {
|
|
build.include(inc);
|
|
}
|
|
build.compile("ahfail_resources");
|
|
|
|
let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default();
|
|
if target_os == "linux" {
|
|
// The Wayland backend drives ext-session-lock-v1 through gtk-session-lock,
|
|
// the same library gtklock uses. The X11 backend and PAM need libpam.
|
|
pkg_config::probe_library("gtk-session-lock-0").expect(
|
|
"gtk-session-lock not found (Arch: pacman -S gtk-session-lock)",
|
|
);
|
|
println!("cargo:rustc-link-lib=pam");
|
|
}
|
|
}
|