Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Multimedia
  • Search

[Solved]How do I start MPD, stopped

Help with creation, editing, or playback of sounds, images, or video. Amarok, audacious, mplayer, grip, cdparanoia and anything else that makes a sound or plays a video.
Post Reply
Advanced search
8 posts • Page 1 of 1
Author
Message
GentlemanFinn
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 85
Joined: Tue Jul 19, 2005 11:06 pm
Location: Denmark

[Solved]How do I start MPD, stopped

  • Quote

Post by GentlemanFinn » Mon May 15, 2006 11:23 pm

Hello

I am starting mpd with an init script, and it works wonderfull, my only problem is that mpd's state often is set to play, so when I turn on my computer it starts to play, this is not something I want, so i'm wondering if there is anyway mpd can be started with its state set to stop og pause?

This is my /etc/init.d/mpd script

Code: Select all

#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/media-sound/mpd-svn/files/mpd.rc6,v 1.4 2005/10/24 13:42:28 ticho Exp $

USER=MicrosoftBob

pidfile="/home/$USER/.mpd/mpd.pid"

depend() {
	need alsasound localmount
	use netmount nfsmount
} 

checkconfig() {
	if ! [ -f /home/$USER/.mpdconf ]; then
		eerror "Configuration file /home/$USER/.mpdconf does not exist."
		return 1
	fi

	return 0
}

start() {
	start mpd now playingcheckconfig || return 1

	ebegin "Starting Music Player Daemon" 
	start-stop-daemon --chuid $USER:users --start --exec /usr/bin/mpd -- --no-create-db /home/$USER/.mpdconf
	eend $?
}

stop() {
	ebegin "Stopping Music Player Daemon"
	start-stop-daemon --chuid $USER:users --stop --pidfile ${pidfile}
	eend $? 
}
Last edited by GentlemanFinn on Tue May 16, 2006 2:04 pm, edited 1 time in total.
Top
Sadako
Advocate
Advocate
User avatar
Posts: 3792
Joined: Thu Aug 05, 2004 5:50 pm
Location: sleeping in the bathtub
Contact:
Contact Sadako
Website

  • Quote

Post by Sadako » Mon May 15, 2006 11:50 pm

What was wrong with the default mpd init script?

Anyway, you can try commenting out the state_file entry from your mpd.conf, should do what you want.
"You have to invite me in"
Top
GentlemanFinn
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 85
Joined: Tue Jul 19, 2005 11:06 pm
Location: Denmark

  • Quote

Post by GentlemanFinn » Tue May 16, 2006 9:55 am

Hopeless wrote:What was wrong with the default mpd init script?

Anyway, you can try commenting out the state_file entry from your mpd.conf, should do what you want.
There's nothing wrong with the default init script, I only changed it to run as a user insteed of root, because I don't like programs running as root when there is no need for them to do so.

I tryed commenting out the state_file, and it worked, the only problem with this is that mpd starts up with no playlist, so I'll have to add all my tracks to the playlist everytime.

I was thinking about maybe doing something with sed in the init scipt to set state: to stop in ~/.mpd/state, but I don't know how to use sed so if someone could tell me to do that, I would be happy 8)
Top
roseZ
n00b
n00b
User avatar
Posts: 31
Joined: Sat Dec 17, 2005 5:23 pm
Location: Finland

  • Quote

Post by roseZ » Tue May 16, 2006 11:06 am

My understanding is that the state is saved on exit. So instead of playing with sed, why not put something like 'mpc stop' in the stop part of the script before the command that terminates mpd?
Top
GentlemanFinn
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 85
Joined: Tue Jul 19, 2005 11:06 pm
Location: Denmark

  • Quote

Post by GentlemanFinn » Tue May 16, 2006 1:48 pm

roseZ wrote:My understanding is that the state is saved on exit. So instead of playing with sed, why not put something like 'mpc stop' in the stop part of the script before the command that terminates mpd?
Okay I can do that, but mpc stop needs to be executed before mpd is killled, and I don't know how to make the init script like that, so if someone could show me, I would really appreciate it.

Edit: Nevermind, I wasn't thinking for a sec ;)
This is how my script looks now, I only added the sed command
If anyone wants it, also save it as /etc/init.d/mpd-user so you don't mess up the original script

Code: Select all

#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

USER=microsoftbob #change microsoftbob to the user you want to start mpd with.

pidfile="/home/$USER/.mpd/mpd.pid"

depend() {
        need alsasound localmount
        use netmount nfsmount
}

checkconfig() {
        if ! [ -f /home/$USER/.mpdconf ]; then
                eerror "Configuration file /home/$USER/.mpdconf does not exist."
                return 1
        fi

        return 0
}

start() {
        checkconfig || return 1

        ebegin "Starting Music Player Daemon"
        sed -si -e 's/^state:.*/state: pause/' /home/$USER/.mpd/state
        start-stop-daemon --chuid $USER:users --start --exec /usr/bin/mpd -- --no-create-db /home/$USER/.mpdconf        eend $?
}

stop() {
        ebegin "Stopping Music Player Daemon"
        start-stop-daemon --chuid $USER:users --stop  --pidfile ${pidfile}
        eend $?
}
Top
kostian
n00b
n00b
Posts: 36
Joined: Sun Nov 28, 2004 5:56 pm

  • Quote

Post by kostian » Tue May 16, 2006 3:30 pm

GentlemanFinn wrote:I only changed it to run as a user insteed of root, because I don't like programs running as root when there is no need for them to do so.
It doesn't run as root, but as a nonprivileged "mpd" user. Read the SECURITY SETTINGS portion of /etc/mpd.conf
Top
GentlemanFinn
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 85
Joined: Tue Jul 19, 2005 11:06 pm
Location: Denmark

  • Quote

Post by GentlemanFinn » Tue May 16, 2006 4:09 pm

kostian wrote:
GentlemanFinn wrote:I only changed it to run as a user insteed of root, because I don't like programs running as root when there is no need for them to do so.
It doesn't run as root, but as a nonprivileged "mpd" user. Read the SECURITY SETTINGS portion of /etc/mpd.conf
I see, thanks for the enlightenment, but my script doesn't harm anything, so I'll proberly not change it until the next time I have to set up mpd :-)
Top
ticho
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 138
Joined: Thu Oct 23, 2003 7:12 am
Location: yes

  • Quote

Post by ticho » Thu Jun 22, 2006 10:11 am

Now this is weird - after a reboot, my mpd always starts playing right where it stopped. I'm using the default init script.
The more you depend on forces outside yourself, the more you are dominated by them.
Top
Post Reply

8 posts • Page 1 of 1

Return to “Multimedia”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic