I need a script like this, for *resume clementine* (after a skype call) *if 
paused*, and no sound (do nothing) if not paused (=*if stopped*). Could you 
help me?
For skype no problem (options - notifications - execute script).

Il giorno venerdì 24 aprile 2015 19:50:21 UTC+2, Matthew Headlee ha scritto:
>
> I wrote this Bash Function (eClementineGetState) as part of a larger 
> script to pause music playback on screen lock, thought others may find it 
> useful.
>
> If anyone here uses XScreenSaver, and Clementine, here's the full script 
> for pausing playback on screen lock and resuming on unlock:
>
>
> #!/bin/bash
> #Written by Matthew Headlee 2015/02/15
> # Updated 2015/04/24 - Added code to detect difference between paused and 
> playing
> #On screen lock, pauses music if playing.
> #On screen unlock, resume music if previously playing.
> #External Dependancies: bash, pgrep, file, find, awk, basename, sleep
>
> #Send all output to null, comment out for debugging.
> exec &> /dev/null
>
> #Function eClementineGetState() checks current state of media playback
> #returns 0 if media is playing, 1 if paused, 2 if stopped, 3 if not running
> eClementineGetState() {
>     iClemPID=$(pgrep -x clementine)
>     if [ ! -z "${iClemPID}" ]; then
>         for sFileDes in $(find /proc/${iClemPID}/fd -type l); do
>             if file -bi "$(readlink -f ${sFileDes})" | awk '!/video|audio/ 
> {exit 1}'; then
>                 #echo "Playing or Paused."
>                 echo "Media File Handle is ${sFileDes}"
>
>                 sFileDesInfo="/proc/${iClemPID}/fdinfo/$(basename 
> ${sFileDes})"
>                 iFilePosA=$(awk '/pos:/ {print $2}' "${sFileDesInfo}")
>                 sleep .1
>                 iFilePosB=$(awk '/pos:/ {print $2}' "${sFileDesInfo}")
>                 if [ "${iFilePosA}" -ne "${iFilePosB}" ]; then
>                     echo "Playing."
>                     return 0
>                 fi
>
>                 echo "Paused."
>                 return 1
>             fi
>         done
>         echo "Stopped."
>         return 2
>     fi
>     echo "Media Player Not Found."
>     return 3
> }
>
> xscreensaver-watch-processor() {
>     #bIsLocked tracks lock state, needed due to xscreensaver generating 
> multiple UNBLANKS for one unblank.
>     bIsLocked=0
>     #bIsMusicPlaying tracks playback state, needed to check if music was 
> paused before locking it doesn't resume on unlock.
>     bIsMusicPlaying=0
>
>     while read sInput; do
>         case "${sInput}" in
>             UNBLANK*)
>                 if [ "${bIsLocked}" -eq 1 -a "${bIsMusicPlaying}" -eq 1 ]; 
> then
>                     #Ensure media is still paused, in case media player 
> was killed from other terminal while screen locked.
>                     eClementineGetState
>                     [ "${?}" -eq 1 ] && clementine --play
>                 fi
>                 bIsMusicPlaying=0
>                 bIsLocked=0
>                 ;;
>             LOCK*)
>                 eClementineGetState && clementine --pause && 
> bIsMusicPlaying=1
>                 bIsLocked=1
>                 ;;
>         esac
>     done
> }
>
> xscreensaver-command -watch | xscreensaver-watch-processor
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Clementine Music Player" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to