--- a/m4/_gxine.m4
+++ b/m4/_gxine.m4
@@ -109,3 +109,22 @@
     fi
     AM_CONDITIONAL([WITH_XCB], [test x"$with_xcb" != xno])
     ])
+
+dnl Screensaver binaries
+dnl Args: config variable, #define variable prefix, binary name,
+dnl       extra commands if found (optional)
+AC_DEFUN([GXINE_SCREENSAVER_CMD],
+   [if test "$$1" = yes; then
+      $1=
+    fi
+    if test "$$1" != no; then
+      AC_PATH_PROG([$1], [$3])
+      if test -n "$$1"; then
+        AC_DEFINE_UNQUOTED([$2_SCREENSAVER_COMMAND], ["$$1"], [location of the $3 binary])
+	m4_default([$4], [])
+      fi
+    else
+      AC_MSG_CHECKING([for $3])
+      AC_MSG_RESULT([no])
+    fi
+    ])