Advertisement
emkay443

Audacious Multitool

Aug 9th, 2013
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.62 KB | None | 0 0
  1. #!/bin/bash
  2. # Audacious Multi Tool
  3. #
  4. # Can start and control audacious (play/pause, stop, prev, next, volume)
  5. #
  6. # Dependencies: audacious
  7. #
  8. # Author: Michael Koch (Emkay443) (m<DOT>koch<AT>emkay443<DOT>de)
  9. # Version: 2013-08-31
  10. # License: GNU General Public License v3 (http://www.gnu.de/documents/gpl-3.0.en.html)
  11.  
  12. ###################
  13. ## CONFIGURATION ##
  14. ###################
  15.  
  16. # Command line option names
  17. option_playpause="playpause"
  18. option_stop="stop"
  19. option_prev="prev"
  20. option_next="next"
  21. option_volup="volup"
  22. option_voldown="voldown"
  23. option_mute="mute"
  24.  
  25. # Audacious and audtool commands
  26. audacious_cmd="/usr/bin/audacious"
  27. audtool_cmd="/usr/bin/audtool"
  28.  
  29.  
  30. #########################################################################################
  31. # WARNING: You should be careful when changing any code below. Modify at your own risk! #
  32. #########################################################################################
  33.  
  34. ##################
  35. ## MAIN PROGRAM ##
  36. ##################
  37.  
  38. # Start audacious with file if there's one provided (second parameter)
  39. if [ ! -z "$2" ]; then
  40.     audacious -p "$2" &
  41. else
  42.     # If audacious is not running, start it
  43.     if [ ! "$(pidof audacious)" ]; then
  44.         $audacious_cmd -p &
  45.     else
  46.         case "$1" in
  47.             "$option_playpause")
  48.                 $audtool_cmd --playback-playpause
  49.                 ;;
  50.             "$option_stop")
  51.                 $audtool_cmd --playback-stop
  52.                 ;;
  53.             "$option_prev")
  54.                 $audtool_cmd --playlist-reverse
  55.                 ;;
  56.             "$option_next")
  57.                 $audtool_cmd --playlist-advance
  58.                 ;;
  59.             "$option_voldown")
  60.                 if [ -e "/tmp/audmultitool_lastvol" ]; then
  61.                         $audtool_cmd --set-volume $(cat /tmp/audmultitool_lastvol)
  62.                         rm /tmp/audmultitool_lastvol
  63.                 else
  64.                     $audtool_cmd --set-volume $(echo $($audtool_cmd --get-volume)-5 | bc)
  65.                 fi
  66.                 ;;
  67.             "$option_volup")
  68.                 if [ -e "/tmp/audmultitool_lastvol" ]; then
  69.                         $audtool_cmd --set-volume $(cat /tmp/audmultitool_lastvol)
  70.                         rm /tmp/audmultitool_lastvol
  71.                 else
  72.                     $audtool_cmd --set-volume $(echo $($audtool_cmd --get-volume)+5 | bc)
  73.                 fi
  74.                 ;;
  75.             "$option_mute")
  76.                 if [ -e "/tmp/audmultitool_lastvol" ]; then
  77.                     $audtool_cmd --set-volume $(cat /tmp/audmultitool_lastvol)
  78.                     rm /tmp/audmultitool_lastvol
  79.                 else
  80.                     $audtool_cmd --get-volume > /tmp/audmultitool_lastvol
  81.                     $audtool_cmd --set-volume 0
  82.                 fi
  83.                 ;;
  84.             *)
  85.                 echo "Available options are:"
  86.                 echo "$option_playpause, $option_stop, $option_prev, $option_next,"
  87.                 echo "$option_voldown, $option_volup, $option_mute"
  88.                 exit 1
  89.                 ;;
  90.         esac
  91.     fi
  92. fi
  93. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement