normcap: fix on GNOME wayland when used via keybind or alt-f2 (#351763)

This commit is contained in:
Christina Sørensen
2024-12-28 21:13:16 +01:00
committed by GitHub
+23 -1
View File
@@ -61,6 +61,7 @@ ps.buildPythonApplication rec {
dependencies = [
ps.pyside6
ps.jeepney
ps.toml
];
preFixup = ''
@@ -69,6 +70,28 @@ ps.buildPythonApplication rec {
--set QT_QPA_PLATFORM xcb
--prefix PATH : ${lib.makeBinPath wrapperDeps}
)
''
+ lib.optionalString stdenv.hostPlatform.isLinux ''
# cursed fix on GNOME+wayland
# this works because systemd-run runs the command as an ad-hoc service named run-1234567890.service
# FIXME: make something like `--slice=app-com.github.dynobo.normcap.slice`
# work such that the "screenshot screenshot" permission in
# `flatpak permissions` is associated with the xdg app id
# "com.github.dynobo.normcap" and not ""
makeWrapperArgs+=(
--run '
if command -v systemd-run >/dev/null; then
exec -a "$0" systemd-run --wait --user \
--setenv=PATH="$PATH" \
--setenv=PYTHONNOUSERSITE="$PYTHONNOUSERSITE" \
--setenv=QT_QPA_PLATFORM="$QT_QPA_PLATFORM" \
${placeholder "out"}/bin/.normcap-wrapped "$@"
else
exec -a "$0" ${placeholder "out"}/bin/.normcap-wrapped "$@"
fi
exit $?
'
)
'';
postInstall = lib.optionalString stdenv.hostPlatform.isLinux ''
@@ -81,7 +104,6 @@ ps.buildPythonApplication rec {
ps.pytest-cov-stub
ps.pytest-instafail
ps.pytest-qt
ps.toml
] ++ lib.optionals stdenv.hostPlatform.isLinux [
ps.pytest-xvfb
xorg.xvfb