Authentication-Results: mail-b.sr.ht; dkim=pass header.d=craftyguy.net header.i=@craftyguy.net Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by mail-b.sr.ht (Postfix) with ESMTPS id 3626F11F055 for <~mil/sxmo-devel@lists.sr.ht>; Fri, 23 Apr 2021 17:45:26 +0000 (UTC) Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4FRhX52J7NzQk3G; Fri, 23 Apr 2021 19:45:25 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=craftyguy.net; s=MBO0001; t=1619199923; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iUE/dFIZDyDWNt8f0lkdz+w3oDNc7WFQqCjaDKUBpAs=; b=tDmLI9Kgg9Lq3RVnZ9ZkXCovWklV1VWs7Vs+/e1kySLECMS/slqvs7t7PVgk+ZwJPMFKcn 9IUjk/giwqRSX5kDkh71x35mYeBtgW96PSZ/gjipw19Q6QVi4615CcdF5KKBBDsoHiXKHt 76tU29c8DHoLCaD14ZIkqtXnpova+Zp3jcoZPMtjW47Q6xr8HG88ALXOdTL+2gLzkjIMDO bVUPLYS7OqCPiM7BgHeh3x2u+gUWXx9Buy3wzzvzak6OgOBzLdw8Wn02bwqmDL8mJHL/sT 6p87vyhGU4uHrQC+J114wufjqDSDooxBLIohlj1bF7n5xIBoB6+fp2Tf0NgsMA== Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter05.heinlein-hosting.de (spamfilter05.heinlein-hosting.de [80.241.56.123]) (amavisd-new, port 10030) with ESMTP id ZRcIrTvXsPzr; Fri, 23 Apr 2021 19:45:22 +0200 (CEST) From: Clayton Craft To: ~mil/sxmo-devel@lists.sr.ht Subject: [PATCH sxmo-utils 1/4] sxmo_xinit: add support for overriding vars with device-specific profiles Date: Fri, 23 Apr 2021 10:45:12 -0700 Message-Id: <20210423174515.3697034-2-clayton@craftyguy.net> In-Reply-To: <20210423174515.3697034-1-clayton@craftyguy.net> References: <20210423174515.3697034-1-clayton@craftyguy.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-MBO-SPAM-Probability: X-Rspamd-Score: -4.76 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6A94815F8 X-Rspamd-UID: 5ffd22 This reads base/compatible from the devicetree to get the device name, and sources a script in /bin with a filename in the format 'sxmo_deviceprofile_NAME.sh'. The purpose of this is to allow setting/overriding variables in other sxmo scripts with device-specific values. For example, some audio devices on one phone may have different names on another. --- scripts/core/sxmo_xinit.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/core/sxmo_xinit.sh b/scripts/core/sxmo_xinit.sh index 148905a..22b3ab8 100755 --- a/scripts/core/sxmo_xinit.sh +++ b/scripts/core/sxmo_xinit.sh @@ -20,6 +20,13 @@ envvars() { [ -z "$XDG_PICTURES_DIR" ] && export XDG_PICTURES_DIR=~/Pictures } +device_envvars() { + device="$(cut -d ',' -f 2 < /sys/firmware/devicetree/base/compatible)" + deviceprofile="$(which "sxmo_deviceprofile_$device.sh")" + # shellcheck disable=SC1090 + [ -f "$deviceprofile" ] && . "$deviceprofile" +} + setupxdgdir() { mkdir -p $XDG_RUNTIME_DIR chmod 700 $XDG_RUNTIME_DIR @@ -117,6 +124,8 @@ xinit() { . "$(dirname "$0")/sxmo_common.sh" envvars + # set device env vars here to allow potentially overriding envvars + device_envvars setupxdgdir xdefaults daemons -- 2.31.1