License date update
[clfswm.git] / contrib / moc.lisp
blob71ee7211b8c9d37b8102a4e75daa462ef94a206b
1 ;;; --------------------------------------------------------------------------
2 ;;; CLFSWM - FullScreen Window Manager
3 ;;;
4 ;;; --------------------------------------------------------------------------
5 ;;; Documentation: MOC - Console audio player - interface
6 ;;; --------------------------------------------------------------------------
7 ;;;
8 ;;; (C) 2015 Philippe Brochard <pbrochard@common-lisp.net>
9 ;;;
10 ;;; This program is free software; you can redistribute it and/or modify
11 ;;; it under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or
13 ;;; (at your option) any later version.
14 ;;;
15 ;;; This program is distributed in the hope that it will be useful,
16 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
19 ;;;
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with this program; if not, write to the Free Software
22 ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 ;;;
24 ;;; Documentation: If you want to use this file, just add this line in
25 ;;; your configuration file:
26 ;;;
27 ;;; (load-contrib "moc.lisp")
28 ;;;
29 ;;; --------------------------------------------------------------------------
31 (in-package :clfswm)
33 (format t "Loading MOC code... ")
36 (defun moc-menu ()
37 "Open the MOC menu"
38 (open-menu (find-menu 'moc-menu)))
41 (defun start-mocp ()
42 "Start mocp"
43 (do-shell "xterm -e 'mocp 2> /dev/null'"))
46 (defun show-moc-info ()
47 "Show MOC informations"
48 (info-on-shell "MOC informations:" "mocp --info")
49 (moc-menu))
51 (defun moc-previous (&optional (in-menu t))
52 "Play the previous song in the current playlist"
53 (do-shell "mocp --previous" nil t)
54 (when in-menu
55 (moc-menu)))
57 (defun moc-next (&optional (in-menu t))
58 "Play the next song in the current playlist"
59 (do-shell "mocp --next" nil t)
60 (when in-menu
61 (moc-menu)))
63 (defun moc-toggle ()
64 "Toggles Play/Pause, plays if stopped"
65 (do-shell "mocp --toggle-pause"))
67 (defun moc-play ()
68 "Start playing"
69 (do-shell "mocp --play"))
71 (defun moc-stop ()
72 "Stop the currently playing playlists"
73 (do-shell "mocp --stop"))
76 (defun moc-seek-+5s (&optional (in-menu t))
77 "Seeks to +5s"
78 (if in-menu
79 (progn
80 (do-shell "mocp --seek +5")
81 (moc-menu))
82 (do-shell "mocp --seek +5" nil t)))
84 (defun moc-seek--5s (&optional (in-menu t))
85 "Seeks to -5s"
86 (if in-menu
87 (progn
88 (do-shell "mocp --seek -5")
89 (moc-menu))
90 (do-shell "mocp --seek -5" nil t)))
92 (unless (find-menu 'moc-menu)
93 (add-sub-menu 'help-menu "F3" 'moc-menu "MOC - Console audio player - menu")
95 (add-menu-key 'moc-menu "i" 'show-moc-info)
96 (add-menu-key 'moc-menu "p" 'moc-previous)
97 (add-menu-key 'moc-menu "n" 'moc-next)
98 (add-menu-key 'moc-menu "t" 'moc-toggle)
99 (add-menu-key 'moc-menu "y" 'moc-play)
100 (add-menu-key 'moc-menu "k" 'moc-stop)
101 (add-menu-key 'moc-menu "x" 'moc-seek-+5s)
102 (add-menu-key 'moc-menu "w" 'moc-seek--5s)
103 (add-menu-key 'moc-menu "m" 'start-mocp))
106 (defun moc-binding ()
107 (define-main-key ("F3" :alt) 'moc-menu))
109 (add-hook *binding-hook* 'moc-binding)
111 (format t "done~%")