Permalink
Browse files

Added cnq command to enqueue files/URLs via the pipe.

  • Loading branch information...
1 parent 1167917 commit 44e12e498ed970cbf5ae7df61ec26dcabcf38244 @holizz committed Mar 9, 2009
Showing with 41 additions and 0 deletions.
  1. +1 −0 Makefile
  2. +40 −0 cnq
View
@@ -7,6 +7,7 @@ all: recursive-all
install: recursive-install
install -c -m 755 cplay $(PREFIX)/bin
+ install -c -m 755 cnq $(PREFIX)/bin
install -c -m 644 cplay.1 $(PREFIX)/man/man1
clean: recursive-clean
View
40 cnq
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+# -*- python -*-
+
+"""
+cnq - enqueue files and URLs into cplay
+Copyright (C) 2009 Tom Adams <tom@holizz.com>
+
+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 the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+"""
+
+import os, sys
+
+CONTROL_FIFO = "%s/cplay-control-%s" % (os.environ.get("TMPDIR", "/tmp"), os.environ["USER"])
+
+if __name__ == "__main__":
+ if len(sys.argv) < 2:
+ print('Arguments, please.')
+ sys.exit(1)
+ if os.path.exists(CONTROL_FIFO):
+ fd = open(CONTROL_FIFO, "wb", 0)
+ for a in sys.argv[1:]:
+ if not a.startswith('http'):
+ a = os.path.abspath(os.path.curdir) + '/' + a
+ fd.write('add %s\n' % a)
+ fd.close()
+ else:
+ print('Could not find %s.' % CONTROL_FIFO)
+ sys.exit(2)

0 comments on commit 44e12e4

Please sign in to comment.