All what I'm trying to do is to get VOL variable from /sound.cfg, depended by DEV number.
cat /sound.cfg
VOL1=20%
Systemd startup script includes:
[Service]
Environment="DEV=1"
EnvironmentFile=/sound.cfg
ExecStartPre=-/bin/bash -c "VOL=VOL${DEV} /bin/echo /usr/bin/amixer -c chan.${DEV} sset Mic ${!VOL} dev $DEV"
Unfortunately, echo shows me /usr/bin/amixer -c chan.1 sset Mic dev 1
, without needed VOL1
. Systemd doesn't support arrays, which would be very helpful.
[Service] Environment="DEV=1" EnvironmentFile=/sound.cfg Environment="VOL=VOL${DEV}" ExecStartPre=-/bin/echo /usr/bin/amixer -c chan.${DEV} sset Mic ${!VOL} dev $DEV
Still no VOL1 value.
– ZeLbeT May 31 '19 at 08:51ExecStartPre=-/bin/bash -c 'VOL=VOL$1 DEV=$2; /bin/echo /usr/bin/amixer -c chan.$DEV sset Mic ${!VOL} dev $DEV' _ ${VOL} ${DEV}
. But you might better off putting the commands in a script. – muru May 31 '19 at 09:09$${!VOL}
... – Murray Jensen Jun 01 '19 at 04:30VOL=VOL${DEV}; /bin/echo ...
to avoid the problem mentioned by @muru – Murray Jensen Jun 04 '19 at 14:58