sxmo_xinit: add support for overriding vars with device-specific profiles

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.

Signed-off-by: Anjandev Momi <anjan@momi.ca>
master
Clayton Craft 4 years ago committed by Anjandev Momi
parent b5e5387121
commit 42b9f482a9
  1. 9
      scripts/core/sxmo_xinit.sh

@ -20,6 +20,13 @@ envvars() {
[ -z "$XDG_PICTURES_DIR" ] && export XDG_PICTURES_DIR=~/Pictures [ -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() { setupxdgdir() {
mkdir -p $XDG_RUNTIME_DIR mkdir -p $XDG_RUNTIME_DIR
chmod 700 $XDG_RUNTIME_DIR chmod 700 $XDG_RUNTIME_DIR
@ -117,6 +124,8 @@ xinit() {
. "$(dirname "$0")/sxmo_common.sh" . "$(dirname "$0")/sxmo_common.sh"
envvars envvars
# set device env vars here to allow potentially overriding envvars
device_envvars
setupxdgdir setupxdgdir
xdefaults xdefaults
daemons daemons

Loading…
Cancel
Save