slideshow script for chromecas
  1. #!/bin/bash
  2. #Slideshow casting script for chromecast by freezy.cz
  3. #
  4. #This script using CATT for casting - https://github.com/skorokithakis/catt
  5. #
  6. #WARNING: You need to kill this script before casting anything else!!!
  7.  
  8.  
  9.  
  10. #define slideshow time in seconds!
  11. ####################
  12.      TIME=33s
  13. ####################
  14.  
  15.  
  16.  
  17. echo""
  18. echo "Slideshow casting script for Chromecast by freezy.cz"
  19. echo ""
  20.  
  21.  
  22. #check another instance of this script (for killing bellow)
  23. SCRIPT=${BASH_SOURCE[0]}
  24. for pid in $(pidof -x $SCRIPT)
  25. do
  26. if [ $pid != $$ ]
  27. then
  28. PID=$pid
  29. fi
  30. done
  31.  
  32.  
  33. #function for cast all supported images in given directory
  34. FILE=$1
  35. FUNGUJ(){
  36. #case-sensitive - disable
  37. shopt -s nocaseglob
  38.  
  39. #loop for casting all supported images in directory
  40. for img in "$FILE"/*.{jpg,gif,png,webp,bmp}
  41. do
  42. catt cast $img && sleep $TIME
  43. done
  44. #case-sensitive - enable
  45. shopt -u nocaseglob
  46. }
  47.  
  48.  
  49. #check if $1 is a directory and if is, then start casting slideshow
  50. if [ -d $1 ] && [ "$1" != "" ] && [ "$1" != "stop" ] && [ "$2" != "loop" ]
  51. then
  52. FUNGUJ
  53. catt stop
  54.  
  55.  
  56. #start infinite loop
  57. elif [ -d $1 ] && [ "$1" != "" ] && [ "$1" != "stop" ] && [ "$2" == "loop" ]
  58. then
  59. until (())
  60. do
  61. FUNGUJ
  62. done
  63.  
  64.  
  65. #kill this script
  66. elif [ "$1" == "stop" ]
  67. then
  68. echo "Killing another instances of $0 and stopping casting ..."
  69. echo ""
  70. kill -9 $(pidof -x sleep $TIME)
  71. kill -9 $PID
  72. sleep 2s
  73. catt stop
  74. else
  75. echo ""
  76. echo "Usage:"
  77. echo "$0 /some/images/dir/           cast images slideshow from given directory to Chromecast"
  78. echo "$0 /some/images/dir/ loop      cast slideshow in infinite loop"
  79. echo "$0 stop                        stop casting and kill this script"
  80. echo ""
  81. echo "Supported filetypes: .jpg .gif .png .webp .bmp (.jpeg extension is not supported, please change it to .jpg)"
  82. echo ""
  83. echo ""
  84. fi
Parsed in 0.028 seconds