]> kaliko git repositories - mpd-goodies.git/commitdiff
* reorganized source folders
authorkaliko <kaliko@azylum.org>
Wed, 26 Jan 2011 16:15:59 +0000 (16:15 +0000)
committerkaliko <kaliko@azylum.org>
Wed, 26 Jan 2011 16:15:59 +0000 (16:15 +0000)
 * added a Makefile

INSTALL [new file with mode: 0644]
Makefile [new file with mode: 0644]
src/crop [moved from crop with 95% similarity]
src/lib/__init__.py [moved from lib/__init__.py with 100% similarity]
src/lib/mpdclass.py [moved from lib/mpdclass.py with 79% similarity]
src/lib/mpdutils.py [moved from lib/mpdutils.py with 100% similarity]
src/lib/startop.py [moved from lib/startop.py with 100% similarity]
src/mfade [moved from mfade with 92% similarity]
src/mtopls [moved from mtopls with 95% similarity]
src/nalbum [moved from nalbum with 96% similarity]
src/wakeup [moved from wakeup with 100% similarity]

diff --git a/INSTALL b/INSTALL
new file mode 100644 (file)
index 0000000..824da57
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,14 @@
+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.
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..6bf3dfc
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,52 @@
+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)
diff --git a/crop b/src/crop
similarity index 95%
rename from crop
rename to src/crop
index 944241a1c4bcf35723a2a0bdb0a6d70cd737f050..5f7dde568d1ec3ccc42510cb0fd084253aa61097 100755 (executable)
--- a/crop
+++ b/src/crop
@@ -1,7 +1,7 @@
 #!/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
@@ -16,8 +16,6 @@
 #   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
 
@@ -28,6 +26,7 @@ NAME = 'crop'
 VERSION = '0.1'
 USAGE = 'USAGE:  %prog [--help] | [ <n> ]'
 
+
 class Crop(StartOpt, MPDClass):
     """
     """
@@ -61,7 +60,7 @@ 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:
similarity index 100%
rename from lib/__init__.py
rename to src/lib/__init__.py
similarity index 79%
rename from lib/mpdclass.py
rename to src/lib/mpdclass.py
index 63a2f06d3a87355bd59ae63f7b1ab245717f0634..b17943eacc5e045ae94773b2027da6ea6cab5f30 100755 (executable)
@@ -18,24 +18,25 @@ class MPDClass(object):
     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():
@@ -47,4 +48,3 @@ if __name__ == '__main__':
 
 # VIM MODLINE
 # vim: ai ts=4 sw=4 sts=4 expandtab
-
similarity index 100%
rename from lib/mpdutils.py
rename to src/lib/mpdutils.py
similarity index 100%
rename from lib/startop.py
rename to src/lib/startop.py
diff --git a/mfade b/src/mfade
similarity index 92%
rename from mfade
rename to src/mfade
index de84f141dfc21be9cfc252af9bd885b179a2a0e8..0ffd9dfd452184331e720c0ef8aaefc4a943b8ef 100755 (executable)
--- a/mfade
+++ b/src/mfade
@@ -1,7 +1,7 @@
 #!/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
@@ -16,7 +16,6 @@
 #   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:
@@ -49,16 +48,16 @@ class Sleep(StartOpt, MPDClass):
         '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):
@@ -69,9 +68,9 @@ class Sleep(StartOpt, MPDClass):
         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'))
@@ -92,9 +91,9 @@ class Sleep(StartOpt, MPDClass):
             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)
@@ -109,7 +108,7 @@ class Sleep(StartOpt, MPDClass):
             if abs(vol - self.volum) < 1:
                 self.client.setvol(self.volum)
                 return True
-            sleep(1)#}}}
+            sleep(1)
 
 
 # Script starts here
similarity index 95%
rename from mtopls
rename to src/mtopls
index 6d0c6ee7aff2d7b2267886af0b573ed35b79daaf..1210fd67421d039cdc2768cd3913530841ff686e 100755 (executable)
--- a/mtopls
@@ -1,7 +1,7 @@
 #!/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
@@ -16,7 +16,6 @@
 #   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
@@ -31,6 +30,7 @@ NAME = 'mtopls'
 VERSION = '0.1'
 USAGE = 'USAGE:  %prog [--help] | /path/to/the/playlist/file/'
 
+
 class MtoPls(StartOpt, MPDClass):
     """
     """
@@ -82,7 +82,8 @@ 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()
similarity index 96%
rename from nalbum
rename to src/nalbum
index c2e311057a46f2c98c6825306823d50655d17093..e48ad68ed1baf2309ba5873dc80b89bd5279190b 100755 (executable)
--- a/nalbum
@@ -54,7 +54,7 @@ class Nalbum(StartOpt, MPDClass):
         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
@@ -74,9 +74,9 @@ class Nalbum(StartOpt, MPDClass):
             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!"
@@ -96,7 +96,7 @@ class Nalbum(StartOpt, MPDClass):
                 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):
         """"""
similarity index 100%
rename from wakeup
rename to src/wakeup