mailarchive of the pengutronix oss-tools mailing list
 help / color / mirror / Atom feed
From: "Ulrich Ölmann" <u.oelmann@pengutronix.de>
To: oss-tools@pengutronix.de
Subject: [OSS-Tools] [PATCH platsch 3/5] allow directory/basename selection via environment
Date: Wed, 21 Jun 2023 16:17:52 +0200	[thread overview]
Message-ID: <20230621141754.3143325-3-u.oelmann@pengutronix.de> (raw)
In-Reply-To: <20230621141754.3143325-1-u.oelmann@pengutronix.de>

Introduce the possibility to choose the directory searched for the splash-
images, as well as the images' basename via the process' environment

  platsch_directory=/usr/share/plitschplatsch
  platsch_basename=splosh

with the corresponding commandline parameters still having higher priority
compared to the environment.

The Kernel passes unrecognized key-value parameters not containing dots into
init’s environment [1]. So the above environment variable can be supplied via
the kernel commandline. This also allows dynamic use cases where the bootloader
decides which resolution to use on which connector.

[1] https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html

Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
---
 README.rst | 12 ++++++++----
 platsch.c  |  9 +++++++++
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/README.rst b/README.rst
index 07f60177b510..96337bfd49f2 100644
--- a/README.rst
+++ b/README.rst
@@ -74,6 +74,12 @@ file::
 Configuration
 -------------
 
+The directory searched for the splash images (default: ``/usr/share/platsch``),
+as well as the image files' basename (default: ``splash``) can be controlled via
+the environment variables ``platsch_directory`` and ``platsch_basename`` (which
+in the case of PID != 1 would be overridden by the corresponding commandline
+parameters, see further downwards).
+
 For each connector a corresponding environment variable is looked up::
 
   platsch_<connector-type-name><connector-type-id>_mode
@@ -105,11 +111,9 @@ Debugging
 
 For debugging purposes, platsch recognizes a couple of command line arguments:
 
-``--directory`` or ``-d`` sets the directory containing the splash screens
-(default: ``/usr/share/platsch``).
+``--directory`` or ``-d`` sets the directory containing the splash screens.
 
-``--basename`` or ``-b`` sets the prefix of the splash screen file names
-(default: ``splash``).
+``--basename`` or ``-b`` sets the prefix of the splash screen file names.
 
 Contributing
 ------------
diff --git a/platsch.c b/platsch.c
index 8228b2f8a886..535b589a659a 100644
--- a/platsch.c
+++ b/platsch.c
@@ -567,8 +567,17 @@ int main(int argc, char *argv[])
 	bool pid1 = getpid() == 1;
 	const char *dir = "/usr/share/platsch";
 	const char *base = "splash";
+	const char *env;
 	int ret = 0, c, i;
 
+	env = getenv("platsch_directory");
+	if (env)
+		dir = env;
+
+	env = getenv("platsch_basename");
+	if (env)
+		base = env;
+
 	if (!pid1) {
 		while ((c = getopt_long(argc, argv, "hd:b:", longopts, NULL)) != EOF) {
 			switch(c) {
-- 
2.39.2




  parent reply	other threads:[~2023-06-21 14:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-21 14:17 [OSS-Tools] [PATCH platsch 1/5] avoid unnecessary indirections Ulrich Ölmann
2023-06-21 14:17 ` [OSS-Tools] [PATCH platsch 2/5] use pointers to immutable strings for cmdline options Ulrich Ölmann
2023-06-21 14:17 ` Ulrich Ölmann [this message]
2023-06-21 14:17 ` [OSS-Tools] [PATCH platsch 4/5] README.rst: fix typos Ulrich Ölmann
2023-06-21 14:17 ` [OSS-Tools] [PATCH platsch 5/5] README.rst: fix documented purpose of commandline arguments Ulrich Ölmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230621141754.3143325-3-u.oelmann@pengutronix.de \
    --to=u.oelmann@pengutronix.de \
    --cc=oss-tools@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox