#!/bin/bash

service="mpd_oled"
launch_script="mpd_oled_launch"

tmp_file_name="/tmp/$service.service"
tmp_file_contents="[Unit]
Description=MPD OLED Display

[Service]
ExecStart=/usr/bin/$launch_script /usr/bin/$service -o 0 -b 21 -g 1 -f 15

[Install]
WantedBy=multi-user.target
"
echo "$tmp_file_contents" > $tmp_file_name

systemctl is-active --quiet $service && systemctl stop $service
cp -n $tmp_file_name /etc/systemd/system
systemctl daemon-reload
systemctl enable $service
