Skip to content

Commit

Permalink
Fix tray icon name
Browse files Browse the repository at this point in the history
  • Loading branch information
TingPing committed Oct 24, 2023
1 parent c17a712 commit 65d48cf
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
14 changes: 14 additions & 0 deletions com.spotify.Client.json
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,20 @@
}
]
},
{
"name": "spotify-preload",
"buildsystem": "simple",
"build-commands": [
"cc spotify-preload.c -o spotify-preload.so -fPIC -shared -ldl",
"install -Dm644 spotify-preload.so /app/lib/spotify-preload.so"
],
"sources": [
{
"type": "file",
"path": "spotify-preload.c"
}
]
},
{
"name": "spotify",
"buildsystem": "simple",
Expand Down
2 changes: 1 addition & 1 deletion spotify-bin
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ if [ $URI_HANDLED -eq 0 ]; then
exit 0
fi

env PULSE_PROP_application.icon_name="com.spotify.Client" LD_PRELOAD=/app/lib/spotifywm.so /app/extra/bin/spotify --force-device-scale-factor=$SCALE_FACTOR "$@" &
env PULSE_PROP_application.icon_name="com.spotify.Client" LD_PRELOAD=/app/lib/spotifywm.so:/app/lib/spotify-preload.so /app/extra/bin/spotify --force-device-scale-factor=$SCALE_FACTOR "$@" &
`set-dark-theme-variant.py` &

if [ $URI_HANDLED -eq 1 ]; then
Expand Down
46 changes: 46 additions & 0 deletions spotify-preload.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-License: BSD-3-Clause

#define _GNU_SOURCE
#include <stdlib.h>
#include <dlfcn.h>

static const char *ICON_NAME_OVERRIDE = "com.spotify.Client-symbolic";

/* Electron currently uses app_indicator_set_icon_full() but this covers all options in-case. */

static void (*original_set_icon_full) (void *, const char *, const char *);
static void (*original_set_icon) (void *, const char *);
static void* (*original_indicator_new) (const char *, const char *, int);
static void* (*original_indicator_new_with_path) (const char *, const char *, int, const char*);

void *app_indicator_new (const char *id, const char *icon_name, int category)
{
if (!original_indicator_new)
original_indicator_new = dlsym (RTLD_NEXT, "app_indicator_new");

return original_indicator_new (id, ICON_NAME_OVERRIDE, category);
}

void *app_indicator_new_with_path (const char *id, const char *icon_name, int category, const char *icon_theme_path)
{
if (!original_indicator_new_with_path)
original_indicator_new_with_path = dlsym (RTLD_NEXT, "app_indicator_new_with_path");

return original_indicator_new_with_path (id, ICON_NAME_OVERRIDE, category, NULL);
}

void app_indicator_set_icon (void *indicator, const char *icon_name)
{
if (!original_set_icon)
original_set_icon = dlsym (RTLD_NEXT, "app_indicator_set_icon");

original_set_icon (indicator, ICON_NAME_OVERRIDE);
}

void app_indicator_set_icon_full (void *indicator, const char *icon_name, const char *icon_desc)
{
if (!original_set_icon_full)
original_set_icon_full = dlsym (RTLD_NEXT, "app_indicator_set_icon_full");

original_set_icon_full (indicator, ICON_NAME_OVERRIDE, icon_desc);
}

0 comments on commit 65d48cf

Please sign in to comment.