Internet DJ Console Homepage IDJC

pipewire-appname.patch
Writen by Stephen Fairchld (s-fairchild@users.sourceforge.net) <- ignored email.

There is a python module called setproctitle that works for some use cases but
not this one so here is a patch to fix an issue where some programs such as idjc
appear as python within pipewire and also not surprisingly, wireplumber.

The application name comes from the /proc/self/exe symbolic link and therefore
the modification of pipewire's source code appears to be the only recourse.

On the client side simply set the PIPEWIRE_APPLICATION_NAME_HINT environment
variable to what the application name ought to be or perhaps better still set
PIPEWIRE_USE_PR_GET_NAME_HINT and also set the process name using prctl.

Hints containing leading whitespace will be rejected.
diff --git a/src/pipewire/pipewire.c b/src/pipewire/pipewire.c
index 4451fa525..1e7378d1a 100644
--- a/src/pipewire/pipewire.c
+++ b/src/pipewire/pipewire.c
@@ -654,6 +654,24 @@ static void init_prgname(void)
 	static char name[PATH_MAX];
 
 	spa_memzero(name, sizeof(name));
+	{
+		char *ev;
+
+		if ((ev = getenv("PIPEWIRE_USE_PR_GET_NAME_HINT")) && ev[0] > ' ' &&
+				prctl(PR_GET_NAME, (unsigned long) name, 0, 0, 0) == 0) {
+			if (name[0] > ' ') {
+				prgname = name;
+				return;
+			} else {
+				memset(name, '\0', sizeof(name));
+			}
+		}
+		if ((ev = getenv("PIPEWIRE_APPLICATION_NAME_HINT")) && ev[0] > ' ') {
+			strncpy(name, ev, sizeof(name)-1);
+			prgname = name;
+			return;
+		}
+	}
 #if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__MidnightBSD_kernel__) || defined(__GNU__)
 	{
 		if (readlink("/proc/self/exe", name, sizeof(name)-1) > 0) {