Merge branch 'canoe' into vlock-2
[vlock.git] / scripts / mplayer.sh
blob27623aec16693951f5517b22238f7d042180d038
1 #!/bin/sh
2 # mplayer.sh -- mplayer pausing script for vlock,
3 # the VT locking program for linux
5 # To use this script do run the following command
6 # $ mkfifo ~/.mplayer/control
7 # and add
8 # input=file=/home/<user>/.mplayer/control
9 # to your ~/.mplayer/config.
11 # This program is copyright (C) 2007 Frank Benkstein, and is free software. It
12 # comes without any warranty, to the extent permitted by applicable law. You
13 # can redistribute it and/or modify it under the terms of the Do What The Fuck
14 # You Want To Public License, Version 2, as published by Sam Hocevar. See
15 # http://sam.zoy.org/wtfpl/COPYING for more details.
17 set -e
19 DEPENDS="all"
21 hooks() {
22 while read hook_name ; do
23 case "${hook_name}" in
24 vlock_start)
25 if fuser "${HOME}/.mplayer/control" > /dev/null 2>&1 ; then
26 echo "pausing seek -4" > "${HOME}/.mplayer/control"
29 vlock_end)
30 if fuser "${HOME}/.mplayer/control" > /dev/null 2>&1 ; then
31 echo "pause" > "${HOME}/.mplayer/control"
34 esac
35 done
38 if [ $# -ne 1 ] ; then
39 echo >&2 "Usage: $0 <command>"
40 exit 1
43 case "$1" in
44 hooks)
45 hooks
47 preceeds)
48 echo "${PRECEEDS}"
50 succeeds)
51 echo "${SUCCEEDS}"
53 requires)
54 echo "${REQUIRES}"
56 needs)
57 echo "${NEEDS}"
59 depends)
60 echo "${DEPENDS}"
62 conflicts)
63 echo "${CONFLICTS}"
66 echo >&2 "$0: unknown command '$1'"
67 exit 1
69 esac