Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- server_log_loc=/media/ramdisk/server.log
- pic_folder=~/Documents/CherryTree/slike
- # delete previous log file
- rm $server_log_loc
- # read last video time position in seconds and convert it to readable format:
- video_position=$(cat $server_log_loc | sed s/A:/\\n/g | grep "V:" | sed s/V:.*//g | tail -1 | xargs | awk '{print int($1)}')
- video_time=$(printf '%dh-%dm-%ds\n' $(($video_position/3600)) $(($video_position%3600/60)) $(($video_position%60)))
- # end of time conversion
- # count image files and format the result
- pic_number=$(ls $pic_folder | wc -l)
- pic_number=$(expr $pic_number + 1)
- num_len=$(echo $pic_number | wc -L)
- if [ "$num_len" -eq 1 ]; then
- counter=$(printf '000%s\n' $pic_number)
- elif [ "$num_len" -eq 2 ]; then
- counter=$(printf '00%s\n' $pic_number)
- elif [ "$num_len" -eq 3 ]; then
- counter=$(printf '0%s\n' $pic_number)
- fi
- # end of count image files
- # get active video title and current date
- video_title=$(cat $server_log_loc | grep "Playing " | sed s/"Playing "//g | sed s/.$//g)
- date=$(date +'%d-%m-%Y+%H-%M-%S-%3N')
- # end of get video title
- file_loc=$(echo $pic_folder"/"$counter"_"$video_title"_"$video_time"_"$date".png")
- # take a screenshot
- mplayer_Win=$(xdotool search --sync --onlyvisible --name "Mplayer")
- xdotool windowactivate --sync $mplayer_Win
- # eval $(xdotool getmouselocation --shell)
- # mouse_pos=$(echo $X $Y)
- shutter -s -e -o "$file_loc"
- countdown=10
- until [ -f "$file_loc" ] || [ $countdown -lt 0 ]
- do
- countdown=$(( $countdown - 1 ))
- sleep 1
- echo "#"
- done
- if [ countdown -lt 0 ] ; then
- exit 1
- fi
- # end take a screenshot
- # import to CherryTree
- cherryWinId=$(xdotool search --sync --onlyvisible --class "cherrytree")
- xdotool windowactivate --sync $cherryWinId
- xte 'keydown Control_L' 'keydown Alt_L' 'key i' 'keyup Alt_L' 'keyup Control_L'
- cherry_selectFile=$(xdotool search --sync --onlyvisible --name "Select File")
- xdotool windowactivate --sync $cherry_selectFile
- echo $file_loc | xclip -selection clipboard
- xte 'keydown Control_L' 'key a' 'keyup Control_L'
- xte 'keydown Control_L' 'key v' 'keyup Control_L'
- xte 'key Return'
- cherry_imageProperties=$(xdotool search --sync --onlyvisible --name "Image Properties")
- xdotool windowactivate --sync $cherry_imageProperties
- xte 'key Return'
- xdotool windowactivate --sync $cherryWinId
- xte 'key Return'
- xte 'key Return'
- xte 'keydown Control_L' 'key s' 'keyup Control_L'
- # end import to CherryTree
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement