-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·27 lines (20 loc) · 911 Bytes
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
# credits: https://stackoverflow.com/a/246128/4649594
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
TMP_DIR=$DIR/tmp
SERVICE_DIR=$DIR/systemd
SYSTEMD_SERVICE_PATH=/etc/systemd/system/
mkdir $TMP_DIR
cp $SERVICE_DIR/* $TMP_DIR/
sed -i "8i\Environment=DIR=$DIR" $TMP_DIR/reset-audio@.service
sed -i "8i\Environment=DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS" $TMP_DIR/reset-audio@.service
sudo cp $TMP_DIR/* $SYSTEMD_SERVICE_PATH
sudo systemctl daemon-reload
sudo systemctl enable reset-audio@$USER.service
rm -r $TMP_DIR