From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Wed, 21 Jun 2023 16:18:28 +0200 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qByfG-00FkMf-1E for lore@lore.pengutronix.de; Wed, 21 Jun 2023 16:18:28 +0200 Received: from localhost ([127.0.0.1] helo=metis.ext.pengutronix.de) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1qByf3-0008GA-R6; Wed, 21 Jun 2023 16:18:17 +0200 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qByf1-0008EY-Me; Wed, 21 Jun 2023 16:18:15 +0200 Received: from [2a0a:edc0:0:1101:1d::39] (helo=dude03.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1qByf1-0093ya-26; Wed, 21 Jun 2023 16:18:15 +0200 Received: from uol by dude03.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1qByf0-00DBjB-08; Wed, 21 Jun 2023 16:18:14 +0200 From: =?UTF-8?q?Ulrich=20=C3=96lmann?= To: oss-tools@pengutronix.de Date: Wed, 21 Jun 2023 16:17:52 +0200 Message-Id: <20230621141754.3143325-3-u.oelmann@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230621141754.3143325-1-u.oelmann@pengutronix.de> References: <20230621141754.3143325-1-u.oelmann@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [OSS-Tools] [PATCH platsch 3/5] allow directory/basename selection via environment X-BeenThere: oss-tools@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: Pengutronix Public Open-Source-Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "OSS-Tools" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: oss-tools-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false 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 --- 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__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