diff --git a/desktop/daemon/src/main.rs b/desktop/daemon/src/main.rs index 879cedf..35bcd73 100644 --- a/desktop/daemon/src/main.rs +++ b/desktop/daemon/src/main.rs @@ -115,16 +115,14 @@ fn main() -> ExitCode { // costs — on a Wayland session, XWayland clients only. let (tx, rx) = std::sync::mpsc::channel(); + let watcher_conn = blocker_platform_linux::watcher::serve(tx.clone()).ok(); + if watcher_conn.is_some() { + println!("owning the D-Bus name {BUS_NAME}"); + } + if let Ok(backend) = blocker_platform_linux::kwin::KwinBackend::connect() { println!("backend: kwin — native Wayland windows are visible"); - let _keep_connection = match blocker_platform_linux::watcher::serve(tx) { - Ok(c) => c, - Err(e) => { - eprintln!("blocker-daemon: cannot own {BUS_NAME}: {e}"); - return ExitCode::FAILURE; - } - }; - println!("owning the D-Bus name; entering the event loop"); + let _keep_connection = watcher_conn; run_loop(&rx, &schedules, &usage, &context, blocker_platform_linux::Enforcement::Freeze); backend.shutdown(); return ExitCode::SUCCESS; diff --git a/desktop/platform-linux/src/kwin.rs b/desktop/platform-linux/src/kwin.rs index fe0cf0f..bc120f5 100644 --- a/desktop/platform-linux/src/kwin.rs +++ b/desktop/platform-linux/src/kwin.rs @@ -126,9 +126,8 @@ workspace.windowActivated.connect(reportFocus); // Report whatever is already focused, so the daemon starts with a correct state // instead of waiting for the user to alt-tab. -for (var i = 0; i < workspace.windowList().length; i++) { - var w = workspace.windowList()[i]; - if (w.active) { reportFocus(w); break; } +if (workspace.activeWindow) { + reportFocus(workspace.activeWindow); } "#; diff --git a/packaging/appimage/bin/runtime-x86_64 b/packaging/appimage/bin/runtime-x86_64 new file mode 100644 index 0000000..5b94975 Binary files /dev/null and b/packaging/appimage/bin/runtime-x86_64 differ diff --git a/scripts/build-appimage.sh b/scripts/build-appimage.sh index bafca64..fec28a9 100755 --- a/scripts/build-appimage.sh +++ b/scripts/build-appimage.sh @@ -26,11 +26,24 @@ cp "$PKG_DIR/blocker.svg" "$APPDIR/blocker.svg" cp "$PKG_DIR/blocker.svg" "$APPDIR/usr/share/icons/hicolor/scalable/apps/" chmod +x "$APPDIR/AppRun" +SQUASHFS_IMG="$DIST_DIR/appdir.squashfs" OUTPUT_APPIMAGE="$DIST_DIR/Blocker-x86_64.AppImage" -rm -f "$OUTPUT_APPIMAGE" +RUNTIME_BIN="$PKG_DIR/bin/runtime-x86_64" + +rm -f "$OUTPUT_APPIMAGE" "$SQUASHFS_IMG" echo "Creating AppImage with mksquashfs..." -mksquashfs "$APPDIR" "$OUTPUT_APPIMAGE" -root-owned -noappend -comp xz +mksquashfs "$APPDIR" "$SQUASHFS_IMG" -root-owned -noappend -comp xz + +if [ -f "$RUNTIME_BIN" ]; then + echo "Embedding AppImage Type 2 ELF runtime..." + cat "$RUNTIME_BIN" "$SQUASHFS_IMG" > "$OUTPUT_APPIMAGE" + printf '\x41\x49\x02' | dd of="$OUTPUT_APPIMAGE" bs=1 seek=8 count=3 conv=notrunc 2>/dev/null + rm -f "$SQUASHFS_IMG" +else + mv "$SQUASHFS_IMG" "$OUTPUT_APPIMAGE" +fi +chmod +x "$OUTPUT_APPIMAGE" echo "Built AppImage: $OUTPUT_APPIMAGE" ls -lh "$OUTPUT_APPIMAGE"