--- /dev/null
+Default installation in /usr/{bin,share/,share/man}.
+
+Makefile supports both DESTDIR and PREFIX GNU standards.
+
+Just call install target to have mpd-goodies installed within /usr
+
+ make install
+
+If you need to install it somewhere else use PREFIX variable.
+For instance installing in /usr/local directory:
+
+ make PREFIX=/usr install
+
+Run uninstall target to remove.
--- /dev/null
+SHELL = /bin/sh
+PREFIX = /usr
+#DESTDIR = /tmp/mpd-goodies
+LIBDIR = $(DESTDIR)$(PREFIX)/lib
+BIN = $(DESTDIR)$(PREFIX)/bin
+ETC = $(DESTDIR)$(PREFIX)/etc
+DATADIR = $(DESTDIR)$(PREFIX)/share
+LOCALEDIR = $(DATADIR)/locale
+MANDIR = $(DATADIR)/man
+PKGNAME = mpd-goodies
+
+all: man bin
+#clean:
+# rm -f mpd-goodies.1.gz
+
+mpd-goodies.1.gz:
+ cat data/mpd-goodies.1 | gzip > mpd-goodies.1.gz
+
+bash_completion:
+ install -d $(ETC)/bash_completion.d
+ install -m644 data/mpd-goodies.sh $(ETC)/bash_completion.d/
+ mv $(ETC)/bash_completion.d/mpd-goodies.sh $(ETC)/bash_completion.d/$(PKGNAME)
+
+man: mpd-goodies.1.gz
+
+install:
+ install -d $(BIN) $(DATADIR)/$(PKGNAME) #$(MANDIR)/man1
+
+ #install -m644 mpd-goodies.1.gz $(MANDIR)/man1
+
+ # listing all sub folder to install (prevent a remaining .svn directory to be install)
+ for sourcedir in `find src/ -name .svn -prune -o -type d -print | sed 's:src/::g'` ; do \
+ install -d $(DATADIR)/$(PKGNAME)/$$sourcedir; \
+ for sourcefile in `find src/$$sourcedir -maxdepth 1 -name *pyc -o -name .svn -prune -o -print` ; do \
+ install -m644 $$sourcefile $(DATADIR)/$(PKGNAME)/$$sourcedir; \
+ done \
+ done
+ # listing all command in ./src
+ for command in `find src/ -maxdepth 1 -name .svn -prune -o -type f -print` ; do \
+ install -m 755 $$command $(DATADIR)/$(PKGNAME)/ ;\
+ done
+ for command in `find $(DATADIR)/$(PKGNAME)/ -maxdepth 1 -name .svn -prune -o -type f -print` ; do \
+ ln -sf $$command $(BIN) ;\
+ done
+
+uninstall:
+ for command in `find $(DATADIR)/$(PKGNAME)/ -maxdepth 1 -name .svn -prune -o -type f -print` ; do \
+ rm -rf $(BIN)/$$(basename $$command) ;\
+ done
+ rm -f $(MANDIR)/man1/mpd-goodies.1.gz
+ rm -f $(ETC)/bash_completion.d/$(PKGNAME)
+ rm -rf $(DATADIR)/$(PKGNAME)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (c) 2009, 2010 Efrim <efrim@azylum.org> {{{
+# Copyright (c) 2009, 2010 Efrim <efrim@azylum.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-# }}}
-
import sys
VERSION = '0.1'
USAGE = 'USAGE: %prog [--help] | [ <n> ]'
+
class Crop(StartOpt, MPDClass):
"""
"""
print 'Keeping %i tracks' % self.nb_tracks
self.mpdConnect()
current_pos = int(self.client.currentsong().get('pos', 0))
- if current_pos <= self.nb_tracks:
+ if current_pos <= self.nb_tracks:
self.client.disconnect()
sys.exit(0)
while current_pos > self.nb_tracks:
def __init__(self):
self.client = MPDClient()
- def mpdConnect(self):#{{{
+ def mpdConnect(self):
"""
Simple wrapper to connect MPD.
"""
- con_id = dict({'host':self.cli_options.host, 'port':self.cli_options.port})
+ con_id = dict({'host': self.cli_options.host,
+ 'port': self.cli_options.port})
try:
self.client.connect(**con_id)
except SocketError:
return False
- return True#}}}
+ return True
- def mpdAuth(self, secret):#{{{
+ def mpdAuth(self, secret):
""" Authenticate"""
try:
self.client.password(secret)
except CommandError:
return False
- return True#}}}
+ return True
def main():
# VIM MODLINE
# vim: ai ts=4 sw=4 sts=4 expandtab
-
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (c) 2009, 2010 Efrim <efrim@azylum.org> {{{
+# Copyright (c) 2009, 2010 Efrim <efrim@azylum.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-# }}}
"""
DOC:
'usage': USAGE,
})
- def __init__(self):#{{{
+ def __init__(self):
""""""
StartOpt.__init__(self, self.__class__.script_info, [])
MPDClass.__init__(self)
self.tempo = int(10)
self.volum = None
self._consume_args()
- self._run()#}}}
+ self._run()
- def _consume_args(self):#{{{
+ def _consume_args(self):
""""""
if (len(self.cli_args) < 1 or
len(self.cli_args) > 2):
except IndexError:
pass
except ValueError, err:
- self.parser.error('wrong option passed (%s)' % err)#}}}
+ self.parser.error('wrong option passed (%s)' % err)
- def _run(self):#{{{
+ def _run(self):
""""""
self.mpdConnect()
self.mpd_state = str(self.client.status().get('state'))
self.mpd_vol = 0
self.client.play()
self.fade()
- sleep(1)#}}}
+ sleep(1)
- def fade(self):#{{{
+ def fade(self):
""""""
# TODO: handle possible lost connections
span = float(self.volum - self.mpd_vol)
if abs(vol - self.volum) < 1:
self.client.setvol(self.volum)
return True
- sleep(1)#}}}
+ sleep(1)
# Script starts here
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (c) 2009, 2010 Efrim <efrim@azylum.org> {{{
+# Copyright (c) 2009, 2010 Efrim <efrim@azylum.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-# }}}
import sys
VERSION = '0.1'
USAGE = 'USAGE: %prog [--help] | /path/to/the/playlist/file/'
+
class MtoPls(StartOpt, MPDClass):
"""
"""
def _run(self):
""""""
- print 'Connecting %s:%i' % (self.cli_options.host, self.cli_options.port)
+ print 'Connecting %s:%i' % (self.cli_options.host,
+ self.cli_options.port)
self.mpdConnect()
self.current_song = self.client.currentsong()
self.client.disconnect()
MPDClass.__init__(self)
self._run()
- def _fade(self, io='out'):#{{{
+ def _fade(self, io='out'):
"""
end_volum => End volume value
mpd_vol => Start volume value
if abs(mpd_vol - end_volum) < 1:
self.client.setvol(end_volum)
return True
- sleep(0.1)#}}}
+ sleep(0.1)
- def _get_next(self):#{{{
+ def _get_next(self):
"""Retrieve playlist from current song to the end."""
if 'song' not in self.client.status():
print "No current song set in MPD!"
sys.exit(0)
album = self.client.playlistinfo(next_album_pos)[0].get('album', 'TAG MISSING')
print 'Next album appears to be: "%s"' % album
- return next_album_pos#}}}
+ return next_album_pos
def _run(self):
""""""