cmus 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. #
  3. # Copyright (c) 2021 Jesús E. <heckyel@hyperbola.info>
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. INFO_CMUS=$(cmus-remote -Q 2>/dev/null)
  18. if cmus-remote -Q >/dev/null 2>&1; then
  19. INFO_TITLE=$(echo "${INFO_CMUS}" | sed -n -e 's/^.*title//p' | head -n 1)
  20. INFO_ALBUM=$(echo "${INFO_CMUS}" | sed -n -e 's/^.*album//p' | head -n 1)
  21. INFO_ARTIST=$(echo "${INFO_CMUS}" | sed -n -e 's/^.*artist//p' | head -n 1)
  22. else
  23. exit
  24. fi
  25. if [[ "${INFO_ARTIST}" ]] && [[ "${INFO_TITLE}" ]] && [[ "${INFO_ALBUM}" ]]; then
  26. OUT_TEXT="${INFO_ARTIST} - ${INFO_TITLE} - ${INFO_ALBUM}"
  27. elif [[ "${INFO_ARTIST}" ]] && [[ "${INFO_TITLE}" ]]; then
  28. OUT_TEXT="${INFO_ARTIST} - ${INFO_TITLE}"
  29. elif [[ "${INFO_TITLE}" ]]; then
  30. OUT_TEXT="${INFO_TITLE}"
  31. fi
  32. echo "${OUT_TEXT}"
  33. echo "${OUT_TEXT}"
  34. exit