statustty 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env bash
  2. # Copyright ©2017-2023 Jason Trunks
  3. # https://notabug.org/JasKinasis/cmus-scripts
  4. # Another slightly insane usage of nowplay
  5. # Monitor cmus and send a message to ALL pty's
  6. # each time the players state changes
  7. # TODO: Look into using something like mesg or wall to send messages to all ttys.
  8. # wall writes a message to all ttys - to indentify the tty you are in you can use tty
  9. # which usually yields ptyx - where x is a number
  10. # else list /dev and grep for all pty's and then use a for loop to output messages...
  11. # see: https://unix.stackexchange.com/questions/261531/how-to-send-output-from-one-terminal-to-another-without-making-any-new-pipe-or-f
  12. # Temporarily commented out the code to get all pty's and send messages to all.
  13. # For now it just displays the now playing track in cmus in whichever pty it was first ran in.
  14. # It would be better to set up a subscriber/observer pattern
  15. # where we could register the tty's that we want messages sent to
  16. prev=""
  17. #ptys="$(ls /dev | \grep pty)"
  18. while true; do
  19. now=$(nowplay);
  20. if [[ "$now" != "$prev" ]]; then
  21. prev=$now
  22. #for line in `echo -e "$ptys"`
  23. #do
  24. # echo $now > /dev/$line;
  25. #done
  26. #ptyMsg "$now"
  27. #echo "$now"
  28. wall "$now"
  29. fi
  30. sleep 5;
  31. done