Skip to content

Display and control your Android device

Replace SCRCPY_ICON_PATH with SCRCPY_ICON_DIR

Romain Vimontd6590738becf
diff --git a/app/meson.build b/app/meson.build
index e7ff2626..d47a2d07 100644
--- a/app/meson.build
+++ b/app/meson.build
@@ -288,6 +288,6 @@ endif
if meson.version().version_compare('>= 0.58.0')
devenv = environment()
- devenv.set('SCRCPY_ICON_PATH', meson.current_source_dir() / 'data/scrcpy.png')
+ devenv.set('SCRCPY_ICON_DIR', meson.current_source_dir() / 'data')
meson.add_devenv(devenv)
endif
diff --git a/app/scrcpy.1 b/app/scrcpy.1
index 20b1e142..f0848077 100644
--- a/app/scrcpy.1
+++ b/app/scrcpy.1
@@ -851,8 +851,8 @@ Path to adb.
Device serial to use if no selector (\fB-s\fR, \fB-d\fR, \fB-e\fR or \fB\-\-tcpip=\fIaddr\fR) is specified.
.TP
-.B SCRCPY_ICON_PATH
-Path to the program icon.
+.B SCRCPY_ICON_DIR
+Path to the icon directory.
.TP
.B SCRCPY_SERVER_PATH
diff --git a/app/src/cli.c b/app/src/cli.c
index 9373bdbd..bf7297bb 100644
--- a/app/src/cli.c
+++ b/app/src/cli.c
@@ -1249,8 +1249,8 @@ static const struct sc_envvar envvars[] = {
"--tcpip=<addr>) is specified",
},
{
- .name = "SCRCPY_ICON_PATH",
- .text = "Path to the program icon",
+ .name = "SCRCPY_ICON_DIR",
+ .text = "Path to the icon directory",
},
{
.name = "SCRCPY_SERVER_PATH",
diff --git a/app/src/icon.c b/app/src/icon.c
index 33d51e96..f95301fc 100644
--- a/app/src/icon.c
+++ b/app/src/icon.c
@@ -14,33 +14,39 @@
#include "config.h"
#include "util/env.h"
-#ifdef PORTABLE
-# include "util/file.h"
-#endif
+#include "util/file.h"
#include "util/log.h"
-#define SCRCPY_PORTABLE_ICON_FILENAME "scrcpy.png"
-#define SCRCPY_DEFAULT_ICON_PATH \
- PREFIX "/share/icons/hicolor/256x256/apps/scrcpy.png"
+#define SCRCPY_ICON_FILENAME "scrcpy.png"
+#define SCRCPY_DEFAULT_ICON_DIR PREFIX "/share/icons/hicolor/256x256/apps"
static char *
get_icon_path(void) {
- char *icon_path = sc_get_env("SCRCPY_ICON_PATH");
- if (icon_path) {
+ char *icon_path;
+
+ char *icon_dir = sc_get_env("SCRCPY_ICON_DIR");
+ if (icon_dir) {
// if the envvar is set, use it
- LOGD("Using SCRCPY_ICON_PATH: %s", icon_path);
+ icon_path = sc_file_build_path(icon_dir, SCRCPY_ICON_FILENAME);
+ free(icon_dir);
+ if (!icon_path) {
+ LOG_OOM();
+ return NULL;
+ }
+ LOGD("Using icon from SCRCPY_ICON_DIR: %s", icon_path);
return icon_path;
}
#ifndef PORTABLE
- LOGD("Using icon: " SCRCPY_DEFAULT_ICON_PATH);
- icon_path = strdup(SCRCPY_DEFAULT_ICON_PATH);
+ icon_path =
+ sc_file_build_path(SCRCPY_DEFAULT_ICON_DIR, SCRCPY_ICON_FILENAME);
if (!icon_path) {
LOG_OOM();
return NULL;
}
+ LOGD("Using icon: %s", icon_path);
#else
- icon_path = sc_file_get_local_path(SCRCPY_PORTABLE_ICON_FILENAME);
+ icon_path = sc_file_get_local_path(SCRCPY_ICON_FILENAME);
if (!icon_path) {
LOGE("Could not get icon path");
return NULL;
diff --git a/run b/run
index d652260d..abc4c9a0 100755
--- a/run
+++ b/run
@@ -20,6 +20,6 @@ then
exit 1
fi
-SCRCPY_ICON_PATH="app/data/scrcpy.png" \
+SCRCPY_ICON_DIR="app/data" \
SCRCPY_SERVER_PATH="$BUILDDIR/server/scrcpy-server" \
"$BUILDDIR/app/scrcpy" "$@"