Sponsored Content
Top Forums Shell Programming and Scripting Need a script to autopause clementine on skype call Post 302991312 by duns on Thursday 9th of February 2017 02:05:27 AM
Old 02-09-2017
Linux solved perfectly

This script solved all:
Code:
#!/bin/bash
#Written by Matthew Headlee 20170208

#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
}

eClementineGetState
[ "${?}" -eq 1 ] && clementine --play

Clementine resume the music only if before paused.
This User Gave Thanks to duns For This Post:
 

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to run script? call other script? su to another user? make a cron?

Good morning. I am searching for "how-to"'s for some particular questions: 1. How to write a script in HP-UX 11. 2. How to schedule a script. 3. How to "call" scripts from the original script. 4. How to su to another user from within a script. This is the basics of what the... (15 Replies)
Discussion started by: instant000
15 Replies

2. Slackware

Skype on Slackware 64

Hi! I've downloaded the static version (skype_static-2.1.0.81.tar.bz2) and extracted it. Then I tried to start the Skype executable file (./skype) via the terminal but nothing happens. root@xxx:~# ls skype_static-2.1.0.81/ skype_static-2.1.0.81.tar.bz2 root@xxx:~# cd skype_static-2.1.0.81... (2 Replies)
Discussion started by: intelfan
2 Replies

3. Shell Programming and Scripting

Script to call a menu script and redirect each option to a text file

Hello, I want to design a script that will call an existing menu script and select options one by one and redirict the out put to a file. For example;- In the script MENU.sh there are 10 options i want to design a script MENU2.sh that will select option 2 3 4 6 7 10 and redirict the output... (4 Replies)
Discussion started by: spradha
4 Replies

4. Shell Programming and Scripting

Shell script to call Oracle archive backup script when file system reaches threshold value

Hello All, I need immediate help in creating shell script to call archivebkup.ksh script when archive file system capacity reaches threshold value or 60% Need to identify the unique file system that reaches threshold value. ex: capacity ... (4 Replies)
Discussion started by: sasikanthdba
4 Replies

5. Shell Programming and Scripting

Call a Perl script within a bash script and store the ouput in a .txt file

I'm attempting to write a bash script that will create a network between virtual machines. It accepts three arguments: an RSpec that describes the network topology, and two list of machines (servers and clients). I have a (working) Perl script that I want to call. This Perl script takes an RSpec... (6 Replies)
Discussion started by: mecaka
6 Replies

6. Ubuntu

Webcam and Skype not working properly

I recently bought a new HP Spectre x360 laptop and installed Ubuntu 15.10. (I originally went with a later version but I was encountering lots of bugs. This version seems to be more stable for my system). Things are mostly working okay, but not my webcam. If I go to a website to test it, it's... (0 Replies)
Discussion started by: twelth_hour
0 Replies
echo(1B)					     SunOS/BSD Compatibility Package Commands						  echo(1B)

NAME
echo - echo arguments to standard output SYNOPSIS
/usr/ucb/echo [-n] [argument] DESCRIPTION
echo writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. echo is useful for producing diagnostics in command files and for sending known data into a pipe, and for displaying the contents of envi- ronment variables. For example, you can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows: o echo your current-working-directory's full pathname o pipe the output through tr to translate the path's embedded slash-characters into space-characters o pipe that output through wc -w for a count of the names in your path. example% /usr/bin/echo "echo $PWD | tr '/' ' ' | wc -w" See tr(1) and wc(1) for their functionality. The shells csh(1), ksh(1), and sh(1), each have an echo built-in command, which, by default, will have precedence, and will be invoked if the user calls echo without a full pathname. /usr/ucb/echo and csh's echo() have an -n option, but do not understand back-slashed escape characters. sh's echo(), ksh's echo(), and /usr/bin/echo, on the other hand, understand the black-slashed escape characters, and ksh's echo() also understands a as the audible bell character; however, these commands do not have an -n option. OPTIONS
-n Do not add the NEWLINE to the output. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscpu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), echo(1), ksh(1), sh(1), tr(1), wc(1), attributes(5) NOTES
The -n option is a transition aid for BSD applications, and may not be supported in future releases. SunOS 5.10 3 Aug 1994 echo(1B)
All times are GMT -4. The time now is 01:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy