Advertisement
Guest User

Untitled

a guest
Jan 1st, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. server_log_loc=/media/ramdisk/server.log
  4. pic_folder=~/Documents/CherryTree/slike
  5.  
  6. # delete previous log file
  7. rm $server_log_loc
  8.  
  9. # read last video time position in seconds and convert it to readable format:
  10. video_position=$(cat $server_log_loc | sed s/A:/\\n/g | grep "V:" | sed s/V:.*//g | tail -1 | xargs | awk '{print int($1)}')
  11. video_time=$(printf '%dh-%dm-%ds\n' $(($video_position/3600)) $(($video_position%3600/60)) $(($video_position%60)))
  12. # end of time conversion
  13.  
  14. # count image files and format the result
  15. pic_number=$(ls $pic_folder | wc -l)
  16. pic_number=$(expr $pic_number + 1)
  17. num_len=$(echo $pic_number | wc -L)
  18. if [ "$num_len" -eq 1 ]; then
  19. counter=$(printf '000%s\n' $pic_number)
  20. elif [ "$num_len" -eq 2 ]; then
  21. counter=$(printf '00%s\n' $pic_number)
  22. elif [ "$num_len" -eq 3 ]; then
  23. counter=$(printf '0%s\n' $pic_number)
  24. fi
  25. # end of count image files
  26.  
  27. # get active video title and current date
  28. video_title=$(cat $server_log_loc | grep "Playing " | sed s/"Playing "//g | sed s/.$//g)
  29. date=$(date +'%d-%m-%Y+%H-%M-%S-%3N')
  30. # end of get video title
  31.  
  32. file_loc=$(echo $pic_folder"/"$counter"_"$video_title"_"$video_time"_"$date".png")
  33.  
  34. # take a screenshot
  35. mplayer_Win=$(xdotool search --sync --onlyvisible --name "Mplayer")
  36. xdotool windowactivate --sync $mplayer_Win
  37. # eval $(xdotool getmouselocation --shell)
  38. # mouse_pos=$(echo $X $Y)
  39. shutter -s -e -o "$file_loc"
  40. countdown=10
  41. until [ -f "$file_loc" ] || [ $countdown -lt 0 ]
  42. do
  43. countdown=$(( $countdown - 1 ))
  44. sleep 1
  45. echo "#"
  46. done
  47. if [ countdown -lt 0 ] ; then
  48. exit 1
  49. fi
  50. # end take a screenshot
  51.  
  52. # import to CherryTree
  53. cherryWinId=$(xdotool search --sync --onlyvisible --class "cherrytree")
  54. xdotool windowactivate --sync $cherryWinId
  55. xte 'keydown Control_L' 'keydown Alt_L' 'key i' 'keyup Alt_L' 'keyup Control_L'
  56. cherry_selectFile=$(xdotool search --sync --onlyvisible --name "Select File")
  57. xdotool windowactivate --sync $cherry_selectFile
  58. echo $file_loc | xclip -selection clipboard
  59. xte 'keydown Control_L' 'key a' 'keyup Control_L'
  60. xte 'keydown Control_L' 'key v' 'keyup Control_L'
  61. xte 'key Return'
  62. cherry_imageProperties=$(xdotool search --sync --onlyvisible --name "Image Properties")
  63. xdotool windowactivate --sync $cherry_imageProperties
  64. xte 'key Return'
  65. xdotool windowactivate --sync $cherryWinId
  66. xte 'key Return'
  67. xte 'key Return'
  68. xte 'keydown Control_L' 'key s' 'keyup Control_L'
  69. # end import to CherryTree
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement