changeset 266:1a6a5d3a94cd

dep/animone: make bsd.cc and x11.cc actually work apparently I broke these, and even now the x11 code *still* doesn't want to work correctly (at least on FreeBSD). half of the PID response codes are just 0 or the PID for the X server itself... wtf? maybe dwm just doesn't support the XRes extension, or I'm just stupid. i don't know.
author Paper <paper@paper.us.eu.org>
date Thu, 11 Apr 2024 22:05:41 -0400
parents ff0b2052b234
children 09c5bd74fe93 382b50754fe4
files dep/animone/Makefile.am dep/animone/configure.ac dep/animone/include/animone/fd.h dep/animone/include/animone/fd/bsd.h dep/animone/include/animone/fd/kvm.h dep/animone/src/animone.cc dep/animone/src/fd.cc dep/animone/src/fd/bsd.cc dep/animone/src/fd/kvm.cc dep/animone/src/win.cc dep/animone/src/win/x11.cc src/track/media.cc
diffstat 12 files changed, 290 insertions(+), 218 deletions(-) [+]
line wrap: on
line diff
--- a/dep/animone/Makefile.am	Thu Apr 11 10:22:05 2024 -0400
+++ b/dep/animone/Makefile.am	Thu Apr 11 22:05:41 2024 -0400
@@ -10,7 +10,7 @@
 	include/animone/types.h
 
 noinst_HEADERS = \
-	include/animone/fd/kvm.h \
+	include/animone/fd/bsd.h \
 	include/animone/fd/proc.h \
 	include/animone/fd/win32.h \
 	include/animone/fd/xnu.h \
@@ -39,14 +39,23 @@
 files_linux = src/fd/proc.cc
 endif
 
-# these should be in standard locations anyway
+# BSD stuff
+if BUILD_BSD
+
+files_bsd = src/fd/bsd.cc
+
+endif
+
 if BUILD_LIBUTIL
+
 libs_libutil = -lutil
+
 endif
 
 if BUILD_LIBKVM
-files_libkvm = src/fd/kvm.cc
+
 libs_libkvm = -lkvm
+
 endif
 
 if BUILD_XCB
@@ -68,8 +77,7 @@
 	$(files_win) \
 	$(files_osx) \
 	$(files_linux) \
-	$(files_libutil) \
-	$(files_libkvm) \
+	$(files_bsd) \
 	$(files_x11) \
 	$(files_wayland)
 
--- a/dep/animone/configure.ac	Thu Apr 11 10:22:05 2024 -0400
+++ b/dep/animone/configure.ac	Thu Apr 11 22:05:41 2024 -0400
@@ -19,6 +19,7 @@
 build_linux=no
 build_libutil=no
 build_kvm=no
+build_bsd=no
 
 build_x11=no
 
@@ -40,21 +41,24 @@
 		AC_DEFINE([LINUX])
 		;;
 	*)
-		# FreeBSD
+		dnl BSDs
+		build_bsd=yes
+		AC_DEFINE([BSD])
 		AC_CHECK_LIB([util], [kinfo_getfile], [build_libutil=yes], [build_libutil=no])
-		if test "x$build_libutil" = "xyes"; then
+
+		dnl if we have this function it means kvm_openfiles likely also supports NULL values,
+		dnl i.e., loading the currently running kernel
+		AC_CHECK_LIB([kvm], [kvm_getfiles], [build_kvm=yes], [build_kvm=no])
+
+		if test "x$build_kvm" = "xyes"; then
+			AC_DEFINE([LIBKVM])
+		elif test "x$build_libutil" = "xyes"; then
 			AC_DEFINE([LIBUTIL])
-		else
-			# OpenBSD
-			AC_CHECK_LIB([kvm], [kvm_getfiles], [build_kvm=yes], [build_kvm=no])
-			if test "x$build_kvm" = "xyes"; then
-				AC_DEFINE([LIBKVM])
-			fi
 		fi
 		;;
 esac
 
-if test "x$build_osx" = "xno" && test "x$build_windows" = "xno"; then
+if test "x$build_osx" != "xyes" && test "x$build_windows" != "xyes"; then
 	PKG_CHECK_MODULES(XCB, [xcb xcb-res], [build_x11=yes], [build_x11=no])
 	if test "x$build_x11" = "xyes"; then
 		AC_DEFINE([X11])
@@ -68,6 +72,7 @@
 AM_CONDITIONAL([BUILD_LINUX], [test "x$build_linux" = "xyes"])
 AM_CONDITIONAL([BUILD_LIBUTIL], [test "x$build_libutil" = "xyes"])
 AM_CONDITIONAL([BUILD_LIBKVM], [test "x$build_kvm" = "xyes"])
+AM_CONDITIONAL([BUILD_BSD], [test "x$build_bsd" = "xyes"])
 
 AM_CONDITIONAL([BUILD_XCB], [test "x$build_x11" = "xyes"])
 
--- a/dep/animone/include/animone/fd.h	Thu Apr 11 10:22:05 2024 -0400
+++ b/dep/animone/include/animone/fd.h	Thu Apr 11 22:05:41 2024 -0400
@@ -22,6 +22,7 @@
 
 using open_file_proc_t = std::function<bool(const OpenFile&)>;
 
+bool GetProcessName(pid_t pid, std::string& name);
 bool EnumerateOpenProcesses(process_proc_t process_proc);
 bool EnumerateOpenFiles(const std::set<pid_t>& pids, open_file_proc_t open_file_proc);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dep/animone/include/animone/fd/bsd.h	Thu Apr 11 22:05:41 2024 -0400
@@ -0,0 +1,18 @@
+#ifndef ANIMONE_ANIMONE_FD_BSD_H_
+#define ANIMONE_ANIMONE_FD_BSD_H_
+
+#include <set>
+#include <string>
+
+#include "animone/fd.h"
+#include "animone/types.h"
+
+namespace animone::internal::bsd {
+
+bool GetProcessName(pid_t pid, std::string& name);
+bool EnumerateOpenProcesses(process_proc_t process_proc);
+bool EnumerateOpenFiles(const std::set<pid_t>& pids, open_file_proc_t open_file_proc);
+
+} // namespace animone::internal::kvm
+
+#endif // ANIMONE_ANIMONE_FD_BSD_H_
--- a/dep/animone/include/animone/fd/kvm.h	Thu Apr 11 10:22:05 2024 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-#ifndef ANIMONE_ANIMONE_FD_KVM_H_
-#define ANIMONE_ANIMONE_FD_KVM_H_
-
-#include <set>
-#include <string>
-
-#include "animone/fd.h"
-#include "animone/types.h"
-
-namespace animone::internal::kvm {
-
-bool EnumerateOpenProcesses(process_proc_t process_proc);
-bool EnumerateOpenFiles(const std::set<pid_t>& pids, open_file_proc_t open_file_proc);
-
-} // namespace animone::internal::kvm
-
-#endif // ANIMONE_ANIMONE_FD_KVM_H_
--- a/dep/animone/src/animone.cc	Thu Apr 11 10:22:05 2024 -0400
+++ b/dep/animone/src/animone.cc	Thu Apr 11 22:05:41 2024 -0400
@@ -9,19 +9,15 @@
 #include <string>
 #include <vector>
 
+#include <iostream>
+
 namespace animone {
 
 namespace internal {
 
-static bool IsExecutableInList(const Player& player, const std::string& name) {
-	std::string stem;
-#ifdef WIN32
-	if (!util::Stem(name, stem))
-#endif
-		stem = name;
-
+static bool IsExecutableInList(const Player& player, const Process& proc) {
 	for (const auto& pattern : player.executables)
-		if (util::CheckPattern(pattern, stem))
+		if (util::CheckPattern(pattern, proc.name))
 			return true;
 
 	return false;
@@ -47,28 +43,27 @@
 
 bool GetResults(const std::vector<Player>& players, std::vector<Result>& results) {
 	auto window_proc = [&](const Process& process, const Window& window) -> bool {
-		for (const auto& player : players) {
-			if (internal::IsWindowInList(player, window))
+		for (const auto& player : players)
+			if (internal::IsWindowInList(player, window) && internal::IsExecutableInList(player, process))
 				results.push_back({player, process, window, {}});
-		}
 
 		return true;
 	};
 
-	if (internal::EnumerateWindows(window_proc))
-		return internal::ApplyStrategies(results);
+	if (internal::EnumerateWindows(window_proc) && internal::ApplyStrategies(results))
+		return true;
 
 	/* fallback, enumerate over open processes instead */
 	auto process_proc = [&](const Process& process) -> bool {
 		for (const auto& player : players)
-			if (internal::IsExecutableInList(player, process.name))
+			if (internal::IsExecutableInList(player, process))
 				results.push_back({player, process, {}, {}});
 
 		return true;
 	};
 
-	if (internal::EnumerateOpenProcesses(process_proc))
-		return internal::ApplyStrategies(results);
+	if (internal::EnumerateOpenProcesses(process_proc) && internal::ApplyStrategies(results))
+		return true;
 
 	return false;
 }
--- a/dep/animone/src/fd.cc	Thu Apr 11 10:22:05 2024 -0400
+++ b/dep/animone/src/fd.cc	Thu Apr 11 22:05:41 2024 -0400
@@ -13,8 +13,8 @@
 #	include "animone/util/osx.h"
 #endif
 
-#ifdef LIBKVM
-#	include "animone/fd/kvm.h"
+#ifdef BSD
+#	include "animone/fd/bsd.h"
 #endif
 
 namespace animone::internal {
@@ -34,8 +34,8 @@
 	success ^= xnu::EnumerateOpenFiles(pids, open_file_proc);
 #endif
 
-#ifdef LIBKVM
-	success ^= kvm::EnumerateOpenFiles(pids, open_file_proc);
+#ifdef BSD
+	success ^= bsd::EnumerateOpenFiles(pids, open_file_proc);
 #endif
 
 	return success;
@@ -56,8 +56,8 @@
 	success ^= xnu::EnumerateOpenProcesses(process_proc);
 #endif
 
-#ifdef LIBKVM
-	success ^= kvm::EnumerateOpenProcesses(process_proc);
+#ifdef BSD
+	success ^= bsd::EnumerateOpenProcesses(process_proc);
 #endif
 
 	return success;
@@ -78,8 +78,8 @@
 	success ^= osx::util::GetProcessName(pid, name);
 #endif
 
-#ifdef LIBKVM
-	success ^= kvm::GetProcessName(pid, name);
+#ifdef BSD
+	success ^= bsd::GetProcessName(pid, name);
 #endif
 
 	return success;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dep/animone/src/fd/bsd.cc	Thu Apr 11 22:05:41 2024 -0400
@@ -0,0 +1,201 @@
+#include "animone/fd/bsd.h"
+#include "animone.h"
+#include "animone/fd.h"
+
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/sysctl.h>
+#include <sys/types.h>
+#include <sys/user.h>
+#include <sys/vnode.h>
+
+#ifdef HAVE_KVM_GETFILES
+#	include <kvm.h>
+#elif defined(LIBUTIL)
+#	include <libutil.h>
+#endif
+
+#include <string>
+#include <iostream>
+
+namespace animone::internal::bsd {
+
+static std::string Basename(const std::string& name) {
+	size_t s = name.find_last_of('/');
+
+	if (s == std::string::npos)
+		return name;
+
+	return name.substr(s, name.size());
+}
+
+bool GetProcessName(pid_t pid, std::string& name) {
+#ifdef HAVE_KVM_GETFILES
+	char errbuf[_POSIX2_LINE_MAX];
+	kvm_t* kernel = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
+	if (!kernel)
+		return false;
+
+	int entries = 0;
+	struct kinfo_proc* kinfo = kvm_getprocs(kernel, KERN_PROC_PID, pid, &entries);
+	if (!kinfo) {
+		kvm_close(kernel);
+		return false;
+	}
+
+	if (entries < 1) {
+		kvm_close(kernel);
+		return false;
+	}
+
+	name = Basename(kinfo[0].ki_paddr->p_comm);
+
+	return true;
+#else
+	/* use sysctl as a fallback */
+	static const int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid};
+
+	struct kinfo_proc result;
+
+	size_t length = 1;
+	if (sysctl((int*)mib, (sizeof(mib) / sizeof(*mib)) - 1, &result, &length, NULL, 0) == -1)
+		return false;
+
+	name = Basename(result.ki_comm);
+
+	return true;
+#endif
+}
+
+/* Most of the BSDs share the common kvm library,
+ * so accessing this information can be trivial.
+ */
+bool EnumerateOpenProcesses(process_proc_t process_proc) {
+#ifdef HAVE_KVM_GETFILES
+	char errbuf[_POSIX2_LINE_MAX];
+	kvm_t* kernel = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
+	if (!kernel)
+		return false;
+
+	int entries = 0;
+	struct kinfo_proc* kinfo = kvm_getprocs(kernel, KERN_PROC_ALL, 0, &entries);
+	if (!kinfo) {
+		kvm_close(kernel);
+		return false;
+	}
+
+	for (int i = 0; i < entries; i++) {
+		if (!process_proc({kinfo[i].ki_paddr->p_pid, Basename(kinfo[i].ki_paddr->p_comm)})) {
+			kvm_close(kernel);
+			return false;
+		}
+	}
+
+	kvm_close(kernel);
+
+	return true;
+#else
+	/* use sysctl as a fallback */
+	static const int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_ALL, 0};
+	size_t length = 0;
+
+	sysctl((int*)mib, (sizeof(mib) / sizeof(*mib)) - 1, NULL, &length, NULL, 0);
+
+	std::unique_ptr<struct kinfo_proc[]> result;
+	result.reset(new struct kinfo_proc[length]);
+
+	if (!result.get())
+		return false;
+
+	/* actually get our results */
+	if (sysctl((const int*)mib, (sizeof(mib) / sizeof(*mib)) - 1, result.get(), &length, NULL, 0) == ENOMEM) {
+		result.reset();
+		throw std::bad_alloc();
+	}
+
+	if (length < sizeof(struct kinfo_proc))
+		return false;
+
+	for (int i = 0; i < length / sizeof(result[0]); i++)
+		if (!process_proc({result[i].ki_pid, result[i].ki_comm}))
+			return false;
+
+	return true;
+#endif
+}
+
+bool EnumerateOpenFiles(const std::set<pid_t>& pids, open_file_proc_t open_file_proc) {
+#ifdef HAVE_KVM_GETFILES
+	char errbuf[_POSIX2_LINE_MAX];
+	kvm_t* kernel = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
+	if (!kernel)
+		return false;
+
+	for (const auto& pid : pids) {
+		int cnt;
+		struct kinfo_file* kfile = kvm_getfiles(kernel, KERN_FILE_BYPID, pid, &cnt);
+		if (!kfile) {
+			kvm_close(kernel);
+			return false;
+		}
+
+		for (int i = 0; i < cnt; i++) {
+			if (!open_file_proc({pid, kfile[i].kf_path})) {
+				kvm_close(kernel);
+				return false;
+			}
+		}
+	}
+
+	kvm_close(kernel);
+
+	return true;
+#elif defined(LIBUTIL)
+	/* does this code even work? */
+	for (const auto& pid : pids) {
+		int cnt;
+		std::unique_ptr<struct kinfo_file[]> files(kinfo_getfile(pid, &cnt));
+		if (!files)
+			return false;
+
+		for (int i = 0; i < cnt; i++) {
+			const struct kinfo_file& current = files[i];
+			if (current.kf_vnode_type != KF_VTYPE_VREG)
+				continue;
+
+			if (!open_file_proc({pid, current.kf_path}))
+				return false;
+		}
+	}
+
+	return true;
+#else
+	for (const auto& pid : pids) {
+		int mib[6] = {CTL_KERN, KERN_FILE2, KERN_FILE_BYPID, pid, sizeof(struct kinfo_file), 0};
+
+		size_t len = 0;
+		if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &len, NULL, 0) == -1)
+			return false;
+
+		mib[5] = len / sizeof(struct kinfo_file);
+
+		std::unique_ptr<struct kinfo_file[]> buf(new struct kinfo_file[mib[5]]);
+		if (!buf)
+			return false;
+
+		if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf.get(), &len, NULL, 0) == -1)
+			return false;
+
+		/* TODO: check kfile[i].ki_ofileflags */
+		for (size_t i = 0; i < mib[5]; i++)
+			if (!open_file_proc({pid, kfile[i].kf_path}))
+				return false;
+	}
+
+	return true;
+#endif
+}
+
+} // namespace animone::internal::kvm
--- a/dep/animone/src/fd/kvm.cc	Thu Apr 11 10:22:05 2024 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,151 +0,0 @@
-/* kvm.cc: provides support for *BSD.
- */
-
-#include "animone/fd/kvm.h"
-#include "animone.h"
-#include "animone/fd.h"
-
-#include <sys/file.h>
-#include <sys/filedesc.h>
-#include <sys/param.h>
-#include <sys/queue.h>
-#include <sys/sysctl.h>
-#include <sys/types.h>
-#include <sys/user.h>
-#include <sys/vnode.h>
-
-#include <kvm.h>
-#ifdef LIBUTIL
-#	include <libutil.h>
-#endif
-
-#include <string>
-
-namespace animone::internal::kvm {
-
-bool GetProcessName(pid_t pid, std::string& name) {
-	char errbuf[_POSIX2_LINE_MAX];
-	kvm_t* kernel = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
-	if (!kernel)
-		return false;
-
-	int entries = 0;
-	struct kinfo_proc* kinfo = kvm_getprocs(kernel, KERN_PROC_PID, pid, &entries);
-	if (!kinfo) {
-		kvm_close(kernel);
-		return false;
-	}
-
-	if (entries < 1) {
-		kvm_close(kernel);
-		return false;
-	}
-
-	name = kinfo[0].ki_paddr->p_comm;
-
-	return true;
-}
-
-/* Most of the BSDs share the common kvm library,
- * so accessing this information can be trivial.
- */
-bool EnumerateOpenProcesses(process_proc_t process_proc) {
-	char errbuf[_POSIX2_LINE_MAX];
-	kvm_t* kernel = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
-	if (!kernel)
-		return false;
-
-	int entries = 0;
-	struct kinfo_proc* kinfo = kvm_getprocs(kernel, KERN_PROC_ALL, 0, &entries);
-	if (!kinfo) {
-		kvm_close(kernel);
-		return false;
-	}
-
-	for (int i = 0; i < entries; i++) {
-		if (!process_proc({kinfo[i].ki_paddr->p_pid, kinfo[i].ki_paddr->p_comm})) {
-			kvm_close(kernel);
-			return false;
-		}
-	}
-
-	kvm_close(kernel);
-
-	return true;
-}
-
-bool EnumerateOpenFiles(std::set<pid_t>& pids, open_file_proc_t open_file_proc) {
-#ifdef __OpenBSD__
-	char errbuf[_POSIX2_LINE_MAX];
-	kvm_t* kernel = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
-	if (!kernel)
-		return false;
-
-	for (const auto& pid : pids) {
-		int cnt;
-		struct kinfo_file* kfile = kvm_getfiles(kernel, KERN_FILE_BYPID, pid, &cnt);
-		if (!kfile) {
-			kvm_close(kernel);
-			return false;
-		}
-
-		for (int i = 0; i < cnt; i++) {
-			if (!open_file_proc({pid, kfile[i].kf_path})) {
-				kvm_close(kernel);
-				return false;
-			}
-		}
-	}
-
-	kvm_close(kernel);
-
-	return true;
-#elif defined(LIBUTIL)
-	/* does this code even work? */
-	for (const auto& pid : pids) {
-		int cnt;
-		std::unique_ptr<struct kinfo_file[]> files(kinfo_getfile(pid, &cnt));
-		if (!files)
-			return false;
-
-		for (int i = 0; i < cnt; i++) {
-			const struct kinfo_file& current = files[i];
-			if (current.kf_vnode_type != KF_VTYPE_VREG)
-				continue;
-
-			if (!open_file_proc({pid, current.kf_path}))
-				return false;
-		}
-	}
-
-	return true;
-#elif defined(__NetBSD__)
-	for (const auto& pid : pids) {
-		int mib[6] = {CTL_KERN, KERN_FILE2, KERN_FILE_BYPID, pid, sizeof(struct kinfo_file), 0};
-
-		size_t len = 0;
-		if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &len, NULL, 0) == -1)
-			return false;
-
-		mib[5] = len / sizeof(struct kinfo_file);
-
-		std::unique_ptr<struct kinfo_file[]> buf(new struct kinfo_file[mib[5]]);
-		if (!buf)
-			return false;
-
-		if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf.get(), &len, NULL, 0) == -1)
-			return false;
-
-		/* TODO: check kfile[i].ki_ofileflags */
-		for (size_t i = 0; i < mib[5]; i++)
-			if (!open_file_proc({pid, kfile[i].kf_path}))
-				return false;
-	}
-
-	return true;
-#else
-	return false;
-#endif
-}
-
-} // namespace animone::internal::kvm
--- a/dep/animone/src/win.cc	Thu Apr 11 10:22:05 2024 -0400
+++ b/dep/animone/src/win.cc	Thu Apr 11 22:05:41 2024 -0400
@@ -12,11 +12,15 @@
 #	include "animone/win/x11.h"
 #endif
 
+#include <iostream>
+
 namespace animone::internal {
 
 bool EnumerateWindows(window_proc_t window_proc) {
 	bool success = false;
 
+	std::cout << "enumerating windows" << std::endl;
+
 #ifdef WIN32
 	success |= win32::EnumerateWindows(window_proc);
 #endif
--- a/dep/animone/src/win/x11.cc	Thu Apr 11 10:22:05 2024 -0400
+++ b/dep/animone/src/win/x11.cc	Thu Apr 11 22:05:41 2024 -0400
@@ -53,8 +53,8 @@
 		std::unique_ptr<xcb_get_property_reply_t> reply(::xcb_get_property_reply(connection, cookie, NULL));
 
 		if (reply) {
-			xcb_window_t* value = reinterpret_cast<xcb_window_t*>(::xcb_get_property_value(reply));
-			int len = ::xcb_get_property_value_length(reply);
+			xcb_window_t* value = reinterpret_cast<xcb_window_t*>(::xcb_get_property_value(reply.get()));
+			int len = ::xcb_get_property_value_length(reply.get());
 
 			for (size_t i = 0; i < len; i++)
 				result.insert(value[i]);
@@ -74,7 +74,7 @@
 static bool WalkWindows(xcb_connection_t* connection, int depth, xcb_atom_t Atom_WM_STATE, const xcb_window_t* windows,
                         int windows_len, std::set<xcb_window_t>& result) {
 	/* The depth we should start returning at. */
-	static constexpr int CUTOFF = 2;
+	static constexpr int CUTOFF = 1;
 
 	bool success = false;
 
@@ -87,8 +87,8 @@
 	for (const auto& cookie : cookies) {
 		std::unique_ptr<xcb_query_tree_reply_t> query_tree_reply(::xcb_query_tree_reply(connection, cookie, NULL));
 
-		xcb_window_t* tree_children = ::xcb_query_tree_children(query_tree_reply);
-		int tree_children_len = ::xcb_query_tree_children_length(query_tree_reply);
+		xcb_window_t* tree_children = ::xcb_query_tree_children(query_tree_reply.get());
+		int tree_children_len = ::xcb_query_tree_children_length(query_tree_reply.get());
 
 		std::vector<xcb_get_property_cookie_t> state_property_cookies;
 		state_property_cookies.reserve(tree_children_len);
@@ -163,7 +163,7 @@
 	{
 		std::vector<xcb_window_t> roots;
 		{
-			xcb_screen_iterator_t iter = ::xcb_setup_roots_iterator(xcb_get_setup(connection));
+			xcb_screen_iterator_t iter = ::xcb_setup_roots_iterator(::xcb_get_setup(connection));
 			for (; iter.rem; ::xcb_screen_next(&iter))
 				roots.push_back(iter.data->root);
 		}
@@ -202,7 +202,7 @@
 			    ::xcb_get_property_reply(connection, window_cookie.class_property_cookie, NULL));
 
 			if (reply && reply->format == 8) {
-				const char* data = reinterpret_cast<char*>(::xcb_get_property_value(reply.get()));
+				const char* data = reinterpret_cast<const char*>(::xcb_get_property_value(reply.get()));
 				const int data_len = ::xcb_get_property_value_length(reply.get());
 
 				int instance_len = str_nlen(data, data_len);
@@ -217,7 +217,7 @@
 			    ::xcb_get_property_reply(connection, window_cookie.name_property_cookie, NULL));
 
 			if (reply) {
-				const char* data = reinterpret_cast<char*>(::xcb_get_property_value(reply.get()));
+				const char* data = reinterpret_cast<const char*>(::xcb_get_property_value(reply.get()));
 				int len = ::xcb_get_property_value_length(reply.get());
 
 				win.text = std::string(data, len);
@@ -230,17 +230,23 @@
 			    ::xcb_res_query_client_ids_reply(connection, window_cookie.pid_property_cookie, NULL));
 
 			if (reply) {
-				xcb_res_client_id_value_iterator_t it = ::xcb_res_query_client_ids_ids_iterator(reply);
+				xcb_res_client_id_value_iterator_t it = ::xcb_res_query_client_ids_ids_iterator(reply.get());
 				for (; it.rem; ::xcb_res_client_id_value_next(&it)) {
 					if (it.data->spec.mask & XCB_RES_CLIENT_ID_MASK_LOCAL_CLIENT_PID) {
-						proc.pid = *reinterpret_cast<uint32_t*>(::xcb_res_client_id_value_value(it.data));
-						fd::GetProcessName(proc.pid, proc.name); /* fill this in if we can */
+						proc.pid = *::xcb_res_client_id_value_value(it.data);
+						GetProcessName(proc.pid, proc.name); /* fill this in if we can */
 						break;
 					}
 				}
 			}
 		}
 
+		std::cout << "got window: " << win.id << "\n"
+			<< "class name: " << win.class_name << "\n"
+			<< "title: " << win.text << "\n"
+			<< "PID: " << proc.pid << "\n"
+			<< "executable: " << proc.name << "\n" << std::endl;
+
 		if (!window_proc(proc, win)) {
 			::xcb_disconnect(connection);
 			return false;
--- a/src/track/media.cc	Thu Apr 11 10:22:05 2024 -0400
+++ b/src/track/media.cc	Thu Apr 11 22:05:41 2024 -0400
@@ -33,8 +33,10 @@
 bool GetCurrentlyPlaying(std::vector<std::string>& vec) {
 	std::vector<animone::Result> results;
 
-	if (!GetCurrentlyPlayingResults(results))
+	if (!GetCurrentlyPlayingResults(results)) {
+		std::cout << "whoooops!" << std::endl;
 		return false;
+	}
 
 	bool success = false;