Last active
August 29, 2015 14:10
-
-
Save dvapelnik/ab057326e4c086552587 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Allowed commndline arguments: | |
# --prev Previous track | |
# --next Next track | |
# --pause Toggle pause | |
# --show Show info about current track (only for NuvolaPlayer3) | |
# empty argumetns | |
if [[ $# -eq 0 ]]; then exit 1; fi | |
isRunNuvola=0 | |
isRunDeadBeef=0 | |
# check is NuvolaPlayer is launched | |
if [[ ! -z `ps aux | grep nuvolaplayer3 | grep -v 'grep nuvolaplayer3'` ]]; then | |
isRunNuvola=1 | |
fi | |
# check is DeadBeef player is launched | |
if [[ ! -z `ps aux | grep deadbeef | grep -v 'grep deadbeef'` ]]; then | |
isRunDeadBeef=1 | |
fi | |
# exit with error when both players are launched | |
if [[ $isRunNuvola -eq 1 && $isRunDeadBeef -eq 1 ]]; then exit 1; fi | |
# proxy action to NuvolPlayer | |
if [[ $isRunNuvola -eq 1 ]]; then | |
case $1 in | |
'--prev') | |
nuvolaplayer3ctl action prev-song &> /dev/null | |
;; | |
'--next') | |
nuvolaplayer3ctl action next-song &> /dev/null | |
;; | |
'--pause') | |
nuvolaplayer3ctl action toggle-play &> /dev/null | |
;; | |
'--show') | |
nuvolaplayer3ctl action playback-notification &> /dev/null | |
;; | |
*) | |
;; | |
esac | |
fi | |
# proxy action to DeadBeef player | |
if [[ $isRunDeadBeef -eq 1 ]]; then | |
case $1 in | |
'--prev') | |
deadbeef --prev &> /dev/null | |
;; | |
'--next') | |
deadbeef --next &> /dev/null | |
;; | |
'--pause') | |
deadbeef --toggle-pause &> /dev/null | |
;; | |
*) | |
;; | |
esac | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment