# Mopidy, MusicBox WebClient, autostart

**URL:** <https://discourse.mopidy.com/t/mopidy-musicbox-webclient-autostart/3850>\
**Category:** Misc\
**Created:** [March 14, 2020, 4:06pm UTC](https://discourse.mopidy.com/t/mopidy-musicbox-webclient-autostart/3850 "2020-03-14T16:06:14Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![sapristi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/sapristi/32/1364_2.png) [@sapristi](https://discourse.mopidy.com/u/sapristi)\
**Post date:** [March 23, 2020, 7:57pm UTC](https://discourse.mopidy.com/t/mopidy-musicbox-webclient-autostart/3850/4 "2020-03-23T19:57:27Z")

</div>

Ok so it appears you are running mopidy with a systemd service (you can see that with all the `systemctl`commands in the install script.  
I thing the easiest way to go would be to create a custom service that would sleep for a while, then add a song and trigger playback. For this you need :

1. install mopidy-mpd, and mpc
2. Configure mpc to connect it with mopidy (i guess)
3. Write and save a script like

```bash
#! /bin/bash
sleep 10
mpc add "some song"
mpc play

```

1. Make the script executable: `chmod +x /path/to/script.sh`
2. Write a systemd service file like

```auto
[Service]
Type=simple
RemainAfterExit=no
ExecStart=/path/to/script.sh 

```

1. Save the service file in `/etc/systemd/system/autoplay.service`
2. You can test if the service works using `systemctl start autoplay`, which should trigger the song after 10 seconds (addapt to your needs)
3. To enable the script and run it at each startup, run `systemctl enable autoplay` in a terminal.

I might have forgotten a step or made some mistakes, but that should be the general idea.

---

_[View the full topic](https://discourse.mopidy.com/t/mopidy-musicbox-webclient-autostart/3850)._
