mkv

audacious + shit

mkv
Nov 13th, 2017
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.31 KB | None | 0 0
  1. # install dependencies:
  2. apt install psmisc ezstream npv sox lame
  3.  
  4. # open audacious;
  5. # file -> settings -> plugins -> [X] Song Change -> [Settings]
  6.  
  7. # Command to run when starting a new song:
  8. # /home/ed/audacious-callback.sh "%a" "%T"
  9.  
  10.  
  11.  
  12. # contents of that file:
  13. #!/bin/bash
  14. printf '%s\n' "$1" > /dev/shm/audacious-artist-tmp
  15. printf '%s\n' "$2" > /dev/shm/audacious-title-tmp
  16. mv /dev/shm/audacious-artist-tmp /dev/shm/audacious-artist
  17. mv /dev/shm/audacious-title-tmp /dev/shm/audacious-title
  18.  
  19.  
  20.  
  21. # contents of patched meta.sh:
  22. #!/bin/bash
  23. #
  24. # part of shit-pulse
  25. # Shellscript Icecast Tools for PulseAudio
  26. # BSD-Licensed, 2015-08-31, ed <irc.rizon.net>
  27. # https://github.com/9001/shit
  28. #
  29.  
  30. set -o pipefail
  31. user=$(id -un)
  32. arg="$1"
  33.  
  34. # checks if a media player is running
  35. function have()
  36. {
  37.     pgrep -ou $user "$1" 2>/dev/null
  38. }
  39.  
  40. # check if there's a supported media player running,
  41. # and store its pid in the var for black magic later
  42. is_db=$(have deadbeef) ||
  43. is_cl=$(have clementine) ||
  44. is_au=$(have audacious) ||
  45. {
  46.     [ "x$arg" == "xtitle" ] &&
  47.         echo -n 'media player 404' ||
  48.         echo -n 'ayy'
  49.    
  50.     exit 0
  51. }
  52.  
  53. # fix corrupted text
  54. function dec()
  55. {
  56.     orig="$(cat)"
  57.    
  58.     # try to decode weeaboo shit
  59.     sjis="$(IFS= echo "$orig" | iconv -t latin1 2>/dev/null | iconv -f sjis 2>/dev/null)"
  60.    
  61.     # decode ok? if yes, keep it
  62.     [ $? -eq 0 ] &&
  63.         printf "%s" "$sjis" ||
  64.         printf "%s" "$orig"
  65.    
  66.     [ -z "$orig" ] && echo 2>/dev/null
  67. }
  68.  
  69. # get artist or title (first argument to function)
  70. function get()
  71. {
  72.     # check if we deadbeef
  73.     [ $is_db ] &&
  74.     {
  75.         [ "x$1" == "xartist" ] &&
  76.             type=a ||
  77.             type=t
  78.        
  79.         "/proc/$is_db/exe" --nowplaying %$type 2>/dev/null |
  80.             dec
  81.        
  82.         true
  83.     } ||
  84.    
  85.     # check if we clementine
  86.     [ $is_cl ] &&
  87.     {
  88.         [ "x$1" == "xartist" ] &&
  89.             mask='^artist: ' ||
  90.             mask='^title: '
  91.        
  92.         qdbus org.mpris.clementine /Player \
  93.         org.freedesktop.MediaPlayer.GetMetadata 2>/dev/null |
  94.             grep -E "$mask" |
  95.             head -n 1 |
  96.             sed 's/^[^:]*: //' |
  97.             dec
  98.        
  99.         true
  100.     }
  101.  
  102.     # check if we audacious
  103.     [ $is_au ] &&
  104.     {
  105.         [ "x$1" == "xartist" ] &&
  106.             cat /dev/shm/audacious-artist ||
  107.             cat /dev/shm/audacious-title   
  108.     }
  109. }
  110.  
  111. #echo "$(date +%s.%N) start $1" >> /dev/shm/meta.log; sleep 1
  112.  
  113. [ -z "$1" ] && echo "no data" || get "$1"
  114.  
  115. #echo "$(date +%s.%N) end   $1" >> /dev/shm/meta.log
Advertisement
Add Comment
Please, Sign In to add comment