Guest User

audio bookmark manager 4

a guest
Mar 25th, 2023
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 19.69 KB | Software | 0 0
  1. ::::::::::::::
  2. escape.bash
  3. ::::::::::::::
  4. #!/bin/bash
  5.  
  6.  
  7. player_title="LosslessCut"
  8.  
  9.  
  10. function block_double_run () {
  11.   pids=($(pidof -x $(basename $0)))
  12.   if [[ ${#pids[@]} -gt 1 ]] ; then
  13.     echo "double run blocked"
  14.     spd-say -t female2 "double run"
  15.     exit
  16.   fi
  17. }
  18.  
  19. function wait_for_window_to_activate() {
  20.   # first parameter  - window title or part of the window title
  21.   window_title="$1"
  22.   time_sec=900
  23.   while [[ 0 -ne $time_sec ]]; do
  24.     echo "$time_sec, waiting... to activate"
  25.     time_sec=$[$time_sec-1]
  26.     xdotool search --onlyvisible --name "$window_title" windowactivate
  27.     window_name=$(xdotool getwindowfocus getwindowname)
  28.     if echo $window_name | grep -q "$window_title" ; then
  29.       echo "window active "$window_name
  30.       break
  31.     fi
  32.     sleep 0.5
  33.   done
  34. }
  35.  
  36. block_double_run
  37. wait_for_window_to_activate "$player_title"
  38. xdotool key Escape
  39. spd-say -t female2 "escape"::::::::::::::
  40. fforward.bash
  41. ::::::::::::::
  42. #!/bin/bash
  43.  
  44.  
  45. player_title="LosslessCut"
  46.  
  47.  
  48. function block_double_run () {
  49.     pids=($(pidof -x $(basename $0)))
  50.     if [[ ${#pids[@]} -gt 1 ]] ; then
  51.         echo "double run blocked"
  52.         spd-say -t female2 "double run"
  53.         exit
  54.     fi
  55. }
  56.  
  57. function wait_for_window_to_activate() {
  58.   # first parameter  - window title or part of the window title
  59.   window_title="$1"
  60.   time_sec=900
  61.   while [[ 0 -ne $time_sec ]]; do
  62.     echo "$time_sec, waiting... to activate"
  63.     time_sec=$[$time_sec-1]
  64.     xdotool search --onlyvisible --name "$window_title" windowactivate
  65.     window_name=$(xdotool getwindowfocus getwindowname)
  66.     if echo $window_name | grep -q "$window_title" ; then
  67.       echo "window active "$window_name
  68.       break
  69.     fi
  70.     sleep 0.5
  71.   done
  72. }
  73.  
  74. function time_add_seconds() {
  75.     # time format 00:58:12.749
  76.     IFS=':' read -ra my_array1 <<< "$1"
  77.     sec_input=$2
  78.     hr=${my_array1[0]}
  79.     min=${my_array1[1]}
  80.     sec=${my_array1[2]%.*}
  81.     msec=${my_array1[2]##*.}
  82.     secs=$(date +%s --date="1970-03-24 $hr:$min:$sec")
  83.     d=$(date '+%d.%b.%Y %T' --date="@$((secs + sec_input))")
  84.     t="${d##* }"".$msec"
  85.     echo $t
  86. }
  87.  
  88. function enter_timecode() {
  89.     seconds=$1
  90.     wait_for_window_to_activate "$player_title"
  91.     echo -n "" | xclip -selection clipboard
  92.     xdotool key Right
  93.     sleep 0.1
  94.     xdotool key g
  95.     sleep 0.5
  96.     xdotool key Ctrl+a
  97.     sleep 0.1
  98.     xdotool key Ctrl+c
  99.     sleep 0.1
  100.     clip_read=$(xsel -b)
  101.     mod_t=$(time_add_seconds "$clip_read" $seconds)
  102.     echo -n "$mod_t" | xclip -selection clipboard
  103.     xdotool key Ctrl+v
  104.     xdotool key Return
  105.     echo $clip_read
  106. }
  107.  
  108. block_double_run
  109. enter_timecode 30
  110. spd-say -t female2 n::::::::::::::
  111. fforward_s.bash
  112. ::::::::::::::
  113. #!/bin/bash
  114.  
  115.  
  116. player_title="LosslessCut"
  117.  
  118.  
  119. function block_double_run () {
  120.     pids=($(pidof -x $(basename $0)))
  121.     if [[ ${#pids[@]} -gt 1 ]] ; then
  122.         echo "double run blocked"
  123.         spd-say -t female2 "double run"
  124.         exit
  125.     fi
  126. }
  127.  
  128. function wait_for_window_to_activate() {
  129.   # first parameter  - window title or part of the window title
  130.   window_title="$1"
  131.   time_sec=900
  132.   while [[ 0 -ne $time_sec ]]; do
  133.     echo "$time_sec, waiting... to activate"
  134.     time_sec=$[$time_sec-1]
  135.     xdotool search --onlyvisible --name "$window_title" windowactivate
  136.     window_name=$(xdotool getwindowfocus getwindowname)
  137.     if echo $window_name | grep -q "$window_title" ; then
  138.       echo "window active "$window_name
  139.       break
  140.     fi
  141.     sleep 0.5
  142.   done
  143. }
  144.  
  145. function time_add_seconds() {
  146.     # time format 00:58:12.749
  147.     IFS=':' read -ra my_array1 <<< "$1"
  148.     sec_input=$2
  149.     hr=${my_array1[0]}
  150.     min=${my_array1[1]}
  151.     sec=${my_array1[2]%.*}
  152.     msec=${my_array1[2]##*.}
  153.     secs=$(date +%s --date="1970-03-24 $hr:$min:$sec")
  154.     d=$(date '+%d.%b.%Y %T' --date="@$((secs + sec_input))")
  155.     t="${d##* }"".$msec"
  156.     echo $t
  157. }
  158.  
  159. function enter_timecode() {
  160.     seconds=$1
  161.     wait_for_window_to_activate "$player_title"
  162.     echo -n "" | xclip -selection clipboard
  163.     xdotool key Right
  164.     sleep 0.1
  165.     xdotool key g
  166.     sleep 0.5
  167.     xdotool key Ctrl+a
  168.     sleep 0.1
  169.     xdotool key Ctrl+c
  170.     clip_read=$(xsel -b)
  171.     mod_t=$(time_add_seconds "$clip_read" $seconds)
  172.     echo -n "$mod_t" | xclip -selection clipboard
  173.     xdotool key Ctrl+v
  174.     xdotool key Return
  175.     echo $clip_read
  176. }
  177.  
  178. block_double_run
  179. enter_timecode 3
  180. spd-say -t female2 n::::::::::::::
  181. load_file.bash
  182. ::::::::::::::
  183. #!/bin/bash
  184.  
  185.  
  186. recordings_dir="/media/$(whoami)/extsd/recordings/"
  187. music_dir="/media/$(whoami)/extsd/Music/"
  188. clips_dir="$music_dir"clips/""
  189. player_full_path="$music_dir"LosslessCut-linux-x86_64.AppImage""
  190. player_title="LosslessCut"
  191.  
  192.  
  193. function block_double_run () {
  194.     pids=($(pidof -x $(basename $0)))
  195.     if [[ ${#pids[@]} -gt 1 ]] ; then
  196.         echo "double run blocked"
  197.         spd-say -t female2 "double run"
  198.         exit
  199.     fi
  200. }
  201.  
  202. function wait_for_window() {
  203.   # first parameter  - window title or part of the window title
  204.   window_title="$1"
  205.   time_sec=900
  206.   while [[ 0 -ne $time_sec ]]; do
  207.     echo "$time_sec, waiting... to appear"
  208.     sleep 1
  209.     time_sec=$[$time_sec-1]
  210.     xdotool search --onlyvisible --name "$window_title" windowactivate
  211.     if [[ $? == 0 ]]; then
  212.         xdotool getactivewindow windowmove 1 30
  213.       echo "window found"
  214.       break
  215.     fi
  216.   done
  217. }
  218.  
  219. function repeat_send_key() {
  220.   window_title="$1"
  221.   key="$2"
  222.   repeat="${3:-1}"
  223.   xdotool search --onlyvisible --name "$window_title" windowactivate
  224.   if [[ $? == 0 ]]; then
  225.       for (( i=1; i <= repeat; i++ ))
  226.       do
  227.        xdotool key $key
  228.        sleep 0.1
  229.       done
  230.     fi
  231. }
  232.  
  233. function make_it_exec() {
  234.     file_full_path="$1"
  235.     if [[ -x "$file_full_path" ]]; then
  236.         echo "File is executable"
  237.     else
  238.         chmod +x "$file_full_path"
  239.         echo "File is executable now"
  240.     fi
  241. }
  242.  
  243. function check_out_loc() {
  244.   w_dir="$1"
  245.   if [ -d "$w_dir" ]; then
  246.     echo direcotry exists
  247.   else
  248.     mkdir "$w_dir"
  249.     echo direcotry created
  250.   fi
  251. }
  252.  
  253. function check_audio_playback() {
  254.   time_sec=60
  255.   while [[ 0 -ne $time_sec ]]; do
  256.     repeat_send_key "$player_title" space
  257.     echo "$time_sec, waiting... to play"
  258.     sleep 1
  259.     time_sec=$[$time_sec-1]
  260.     status=$(pacmd list-sink-inputs | grep -c 'state: RUNNING')
  261.     if [[ $status -gt 0 ]]; then
  262.       echo "sound is playing"
  263.       break
  264.     fi
  265.   done
  266. }
  267.  
  268. function load_file() {
  269.     check_out_loc "$clips_dir"
  270.     cd $recordings_dir
  271.     readarray -t files < <(find ./ -maxdepth 1 -type f -regex '.*\.\(mp3\|flac\)$' | sed "s/.*\///" | sort)
  272.     if [ ${#files[@]} -gt 0 ]; then
  273.         file_name=$(basename "${files[0]}" | cut -d. -f1)
  274.         file_extension=$(basename "${files[0]}" | cut -d. -f2)
  275.         out_dir="$music_dir"
  276.         mv "$file_name.$file_extension" "$out_dir"
  277.         make_it_exec "$player_full_path"
  278.         echo "$out_dir$file_name.$file_extension"
  279.         killall losslesscut
  280.         "$player_full_path" --settings-json '{customOutDir:"'"${clips_dir::-1}"'", "autoMerge":"true"}' "$out_dir$file_name.$file_extension" &
  281.         wait_for_window "$player_title"
  282.         check_audio_playback
  283.     fi
  284. }
  285.  
  286. function move_previous() {
  287.     cd $music_dir
  288.     readarray -t files < <(find ./ -maxdepth 1 -type f -regex '.*\.\(mp3\|flac\)$' | sed "s/.*\///" | sort)
  289.     if [ ${#files[@]} -gt 0 ]; then
  290.         file_name=$(basename "${files[0]}" | cut -d. -f1)
  291.         file_extension=$(basename "${files[0]}" | cut -d. -f2)
  292.         date_str=$(date +%s)
  293.         check_out_loc "$clips_dir"
  294.         out_dir="$clips_dir"
  295.         echo "file to move: ""$file_name.$file_extension"
  296.         mv "$file_name.$file_extension" "$out_dir"$date_str"_$file_name.$file_extension"
  297.     fi
  298. }
  299.  
  300. block_double_run
  301. move_previous
  302. load_file
  303. spd-say -t female2 "file loaded"::::::::::::::
  304. mark_in_out.bash
  305. ::::::::::::::
  306. #!/bin/bash
  307.  
  308.  
  309. recordings_dir="/media/$(whoami)/extsd/recordings/"
  310. player_title="LosslessCut"
  311. markin_loc="$recordings_dir"markin.txt""
  312.  
  313.  
  314. function block_double_run () {
  315.   pids=($(pidof -x $(basename $0)))
  316.   if [[ ${#pids[@]} -gt 1 ]] ; then
  317.     echo "double run blocked"
  318.     spd-say -t female2 "double run"
  319.     exit
  320.   fi
  321. }
  322.  
  323. function wait_for_window_to_activate() {
  324.   # first parameter  - window title or part of the window title
  325.   window_title="$1"
  326.   time_sec=900
  327.   while [[ 0 -ne $time_sec ]]; do
  328.     echo "$time_sec, waiting... to activate"
  329.     time_sec=$[$time_sec-1]
  330.     xdotool search --onlyvisible --name "$window_title" windowactivate
  331.     window_name=$(xdotool getwindowfocus getwindowname)
  332.     if echo $window_name | grep -q "$window_title" ; then
  333.       echo "window active "$window_name
  334.       break
  335.     fi
  336.     sleep 0.5
  337.   done
  338. }
  339.  
  340. function repeat_send_key() {
  341.   window_title="$1"
  342.   key="$2"
  343.   repeat="${3:-1}"
  344.   xdotool search --onlyvisible --name "$window_title" windowactivate
  345.   if [[ $? == 0 ]]; then
  346.       for (( i=1; i <= repeat; i++ ))
  347.       do
  348.         xdotool key $key
  349.         sleep 0.1
  350.       done
  351.     fi
  352. }
  353.  
  354. function mark_in_out() {
  355.     if [[ -f $markin_loc ]]; then
  356.         repeat_send_key "$player_title" "o"
  357.         rm $markin_loc
  358.     else
  359.         repeat_send_key "$player_title" "i"
  360.         echo "mark in" > $markin_loc
  361.     fi
  362. }
  363.  
  364. block_double_run
  365. wait_for_window_to_activate "$player_title"
  366. mark_in_out
  367. spd-say -t female2 m::::::::::::::
  368. move_files.bash
  369. ::::::::::::::
  370. #!/bin/bash
  371.  
  372.  
  373. # GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)
  374.  
  375.  
  376. overwrite_files="yes"
  377. copying_mode="move"
  378. check_period_in_seconds=60
  379. # server PC:
  380. folder_to_monitor="/media/ramdisk/"
  381. # client PC, label of external sd card:
  382. monitor_skip_strings=(extsd)
  383. # my computer location:
  384. backup_root_folder="/media/$(whoami)/"
  385. search_for_folder_to_backup_to="recordings"
  386. file_extensions_to_include="mp3\|flac\|mp4"
  387. file_extensions_to_exclude="aria2"
  388.  
  389.  
  390. function countdown_timer() {
  391.     time_sec=$1
  392.     while [[ 0 -ne $time_sec ]]; do
  393.         echo "$time_sec, waiting... to start"
  394.         time_sec=$[$time_sec-1]
  395.         sleep 1
  396.     done
  397. }
  398.  
  399. function download_wait_to_finish() {
  400.     src_dir="$1"
  401.     search_dext="$2"
  402.     readarray -t arr_fd < <(find "$src_dir" -maxdepth 1 -type f -regex '.*\.\('$search_dext'\)$' | sed "s/.*\///" | sort)
  403.     if [[ ${#arr_fd[@]} > 0 ]]; then
  404.         echo "waiting for download to finish..."
  405.         while [[ ${#arr_fd[@]} > 0 ]]; do
  406.             sleep 1
  407.             readarray -t arr_fd < <(find "$src_dir" -maxdepth 1 -type f -regex '.*\.\('$search_dext'\)$' | sed "s/.*\///" | sort)
  408.         done
  409.         echo "download finished at: "$(date +"%H:%M:%S")
  410.     fi
  411. }
  412.  
  413. function find_copy_files() {
  414.     src_dir="$1"
  415.     out_dir_root="$2"
  416.     backup_dir="$3"
  417.     search_ext="$4"
  418.     copy_detection=0
  419.     client_detection=0
  420.     out_dir=""
  421.     readarray -t arr_d < <(find "$out_dir_root" -mindepth 1 -maxdepth 1 -type d | sed "s/.*\///" | sort)
  422.     # detect server or client
  423.     for i in "${arr_d[@]}"
  424.     do
  425.         out_dir_loc="$out_dir_root$i/$backup_dir/"
  426.         if [[ -d "$out_dir_loc" ]]; then
  427.             # client detection:
  428.             if [[ $client_detection -eq 0 ]]; then
  429.                 for j in "${monitor_skip_strings[@]}"
  430.                 do
  431.                     if echo $out_dir_loc | grep -q "$j" ; then
  432.                         client_detection=1
  433.                         break
  434.                     fi
  435.                 done
  436.             fi
  437.             if [[ $client_detection -eq 1 ]]; then
  438.                 # only one input:
  439.                 for j in "${monitor_skip_strings[@]}"
  440.                 do
  441.                     if echo $out_dir_loc | grep -q "$j" ; then
  442.                         echo "skipping" > /dev/null
  443.                     else
  444.                         src_dir=$out_dir_loc
  445.                         break
  446.                     fi
  447.                 done
  448.                 # only one output:
  449.                 for j in "${monitor_skip_strings[@]}"
  450.                 do
  451.                     if echo $out_dir_loc | grep -q "$j" ; then
  452.                         out_dir=$out_dir_loc
  453.                         break
  454.                     fi
  455.                 done
  456.             elif [[ $client_detection -eq 0 ]]; then
  457.                 # only one output, first one found:
  458.                 for j in "${monitor_skip_strings[@]}"
  459.                 do
  460.                     if echo $out_dir_loc | grep -q "$j" ; then
  461.                         echo "skipping" > /dev/null
  462.                     else
  463.                         out_dir=$out_dir_loc
  464.                         break
  465.                     fi
  466.                 done
  467.                 # input is original, unchanged
  468.             fi
  469.         fi
  470.     done
  471.  
  472.     echo "source directory: $src_dir"
  473.     echo "backup directory: $out_dir"
  474.     download_wait_to_finish "$src_dir" "$file_extensions_to_exclude"
  475.     if [[ ! $out_dir == "" ]]; then
  476.         readarray -t arr_f < <(find "$src_dir" -maxdepth 1 -type f -regex '.*\.\('$search_ext'\)$' | sed "s/.*\///" | sort)
  477.         for i in "${arr_f[@]}"
  478.         do
  479.             file_src_loc=$src_dir$i
  480.             file_out_loc=$out_dir$i
  481.             if [[ "$copying_mode" == "copy" ]]; then
  482.                 if [[ ! -f "$file_out_loc" ]]; then
  483.                     echo "coping file: $file_src_loc"
  484.                     cp "$file_src_loc" "$out_dir"
  485.                     copy_detection=1
  486.                 elif [[ "$overwrite_files" == "yes" && $file_src_loc -nt $file_out_loc ]]; then
  487.                     echo "overwriting file: $file_src_loc"
  488.                     cp "$file_src_loc" "$out_dir"
  489.                     copy_detection=1
  490.                 else
  491.                     echo "file exists, skipping: $file_out_loc"
  492.                 fi
  493.             elif [[ "$copying_mode" == "move" ]]; then
  494.                 if [[ ! -f "$file_out_loc" ]]; then
  495.                     echo "moving file: $file_src_loc"
  496.                     mv -n "$file_src_loc" "$file_out_loc"
  497.                     copy_detection=1
  498.                 elif [[ "$overwrite_files" == "yes" && $file_src_loc -nt $file_out_loc ]]; then
  499.                     echo "moving and overwriting file: $file_src_loc"
  500.                     mv -f "$file_src_loc" "$file_out_loc"
  501.                     copy_detection=1
  502.                 else
  503.                     echo "file exists, skipping: $file_out_loc"
  504.                 fi
  505.             fi
  506.         done
  507.     fi
  508. }
  509.  
  510. while :
  511. do
  512.     countdown_timer $check_period_in_seconds
  513.     find_copy_files "$folder_to_monitor" "$backup_root_folder" "$search_for_folder_to_backup_to" "$file_extensions_to_include"
  514.     if [[ copy_detection -eq 1 ]]; then
  515.         # sudo apt install speech-dispatcher
  516.         spd-say -t female2 "your grace, backup is done, please praise me..."
  517.     fi
  518. done::::::::::::::
  519. play_pause.bash
  520. ::::::::::::::
  521. #!/bin/bash
  522.  
  523.  
  524. player_title="LosslessCut"
  525.  
  526.  
  527. function block_double_run () {
  528.   pids=($(pidof -x $(basename $0)))
  529.   if [[ ${#pids[@]} -gt 1 ]] ; then
  530.     echo "double run blocked"
  531.     spd-say -t female2 "double run"
  532.     exit
  533.   fi
  534. }
  535.  
  536. function wait_for_window_to_activate() {
  537.   # first parameter  - window title or part of the window title
  538.   window_title="$1"
  539.   time_sec=900
  540.   while [[ 0 -ne $time_sec ]]; do
  541.     echo "$time_sec, waiting... to close"
  542.     time_sec=$[$time_sec-1]
  543.     xdotool search --onlyvisible --name "$window_title" windowactivate
  544.     window_name=$(xdotool getwindowfocus getwindowname)
  545.     if echo $window_name | grep -q "$window_title" ; then
  546.       echo "window active "$window_name
  547.       break
  548.     fi
  549.     sleep 0.5
  550.   done
  551. }
  552.  
  553. function repeat_send_key() {
  554.   window_title="$1"
  555.   key="$2"
  556.   repeat="${3:-1}"
  557.   xdotool search --onlyvisible --name "$window_title" windowactivate
  558.   if [[ $? == 0 ]]; then
  559.       for (( i=1; i <= repeat; i++ ))
  560.       do
  561.         xdotool key $key
  562.         sleep 0.1
  563.       done
  564.     fi
  565. }
  566.  
  567. block_double_run
  568. spd-say -t female2 s
  569. wait_for_window_to_activate "$player_title"
  570. repeat_send_key "$player_title" space::::::::::::::
  571. redshift.bash
  572. ::::::::::::::
  573. #!/bin/bash
  574.  
  575. redshift -O 3700
  576. spd-say -t female2 "redshift"::::::::::::::
  577. rewind.bash
  578. ::::::::::::::
  579. #!/bin/bash
  580.  
  581.  
  582. player_title="LosslessCut"
  583.  
  584.  
  585. function block_double_run () {
  586.   pids=($(pidof -x $(basename $0)))
  587.   if [[ ${#pids[@]} -gt 1 ]] ; then
  588.     echo "double run blocked"
  589.     spd-say -t female2 "double run"
  590.     exit
  591.   fi
  592. }
  593.  
  594. function wait_for_window_to_activate() {
  595.   # first parameter  - window title or part of the window title
  596.   window_title="$1"
  597.   time_sec=900
  598.   while [[ 0 -ne $time_sec ]]; do
  599.     echo "$time_sec, waiting... to activate"
  600.     time_sec=$[$time_sec-1]
  601.     xdotool search --onlyvisible --name "$window_title" windowactivate
  602.     window_name=$(xdotool getwindowfocus getwindowname)
  603.     if echo $window_name | grep -q "$window_title" ; then
  604.       echo "window active "$window_name
  605.       break
  606.     fi
  607.     sleep 0.5
  608.   done
  609. }
  610.  
  611. function time_minus_seconds() {
  612.   # time format 00:58:12.749
  613.   IFS=':' read -ra my_array1 <<< "$1"
  614.   sec_input=$2
  615.   hr=${my_array1[0]}
  616.   min=${my_array1[1]}
  617.   sec=${my_array1[2]%.*}
  618.   msec=${my_array1[2]##*.}
  619.   secs=$(date +%s --date="1970-03-24 $hr:$min:$sec")
  620.   d=$(date '+%d.%b.%Y %T' --date="@$((secs - sec_input))")
  621.   t="${d##* }"".$msec"
  622.   echo $t
  623. }
  624.  
  625. function enter_timecode() {
  626.   seconds=$1
  627.   wait_for_window_to_activate "$player_title"
  628.   echo -n "" | xclip -selection clipboard
  629.   xdotool key Left
  630.   sleep 0.1
  631.   xdotool key g
  632.   sleep 0.5
  633.   xdotool key Ctrl+a
  634.   sleep 0.1
  635.   xdotool key Ctrl+c
  636.   clip_read=$(xsel -b)
  637.   mod_t=$(time_minus_seconds "$clip_read" $seconds)
  638.   echo -n "$mod_t" | xclip -selection clipboard
  639.   xdotool key Ctrl+v
  640.   xdotool key Return
  641.   echo $clip_read
  642. }
  643.  
  644. block_double_run
  645. enter_timecode 10
  646. spd-say -t female2 p::::::::::::::
  647. rewind_s.bash
  648. ::::::::::::::
  649. #!/bin/bash
  650.  
  651.  
  652. player_title="LosslessCut"
  653.  
  654.  
  655. function block_double_run () {
  656.   pids=($(pidof -x $(basename $0)))
  657.   if [[ ${#pids[@]} -gt 1 ]] ; then
  658.     echo "double run blocked"
  659.     spd-say -t female2 "double run"
  660.     exit
  661.   fi
  662. }
  663.  
  664. function wait_for_window_to_activate() {
  665.   # first parameter  - window title or part of the window title
  666.   window_title="$1"
  667.   time_sec=900
  668.   while [[ 0 -ne $time_sec ]]; do
  669.     echo "$time_sec, waiting... to activate"
  670.     time_sec=$[$time_sec-1]
  671.     xdotool search --onlyvisible --name "$window_title" windowactivate
  672.     window_name=$(xdotool getwindowfocus getwindowname)
  673.     if echo $window_name | grep -q "$window_title" ; then
  674.       echo "window active "$window_name
  675.       break
  676.     fi
  677.     sleep 0.5
  678.   done
  679. }
  680.  
  681. function time_minus_seconds() {
  682.   # time format 00:58:12.749
  683.   IFS=':' read -ra my_array1 <<< "$1"
  684.   sec_input=$2
  685.   hr=${my_array1[0]}
  686.   min=${my_array1[1]}
  687.   sec=${my_array1[2]%.*}
  688.   msec=${my_array1[2]##*.}
  689.   secs=$(date +%s --date="1970-03-24 $hr:$min:$sec")
  690.   d=$(date '+%d.%b.%Y %T' --date="@$((secs - sec_input))")
  691.   t="${d##* }"".$msec"
  692.   echo $t
  693. }
  694.  
  695. function enter_timecode() {
  696.   seconds=$1
  697.   wait_for_window_to_activate "$player_title"
  698.   echo -n "" | xclip -selection clipboard
  699.   xdotool key Left
  700.   sleep 0.1
  701.   xdotool key g
  702.   sleep 0.5
  703.   xdotool key Ctrl+a
  704.   sleep 0.1
  705.   xdotool key Ctrl+c
  706.   clip_read=$(xsel -b)
  707.   mod_t=$(time_minus_seconds "$clip_read" $seconds)
  708.   echo -n "$mod_t" | xclip -selection clipboard
  709.   xdotool key Ctrl+v
  710.   xdotool key Return
  711.   echo $clip_read
  712. }
  713.  
  714. block_double_run
  715. enter_timecode 3
  716. spd-say -t female2 p::::::::::::::
  717. screen_off.bash
  718. ::::::::::::::
  719. #!/bin/bash
  720.  
  721. spd-say -t female2 "screen off"
  722. xrandr --output DSI-1 --brightness 0.20
  723. xset dpms force off::::::::::::::
  724. split_audio.bash
  725. ::::::::::::::
  726. #!/bin/bash
  727.  
  728.  
  729. player_title="LosslessCut"
  730.  
  731.  
  732. function block_double_run () {
  733.   pids=($(pidof -x $(basename $0)))
  734.   if [[ ${#pids[@]} -gt 1 ]] ; then
  735.     echo "double run blocked"
  736.     spd-say -t female2 "double run"
  737.     exit
  738.   fi
  739. }
  740.  
  741. function wait_for_window_to_activate() {
  742.   # first parameter  - window title or part of the window title
  743.   window_title="$1"
  744.   time_sec=900
  745.   while [[ 0 -ne $time_sec ]]; do
  746.     echo "$time_sec, waiting... to activate"
  747.     time_sec=$[$time_sec-1]
  748.     xdotool search --onlyvisible --name "$window_title" windowactivate
  749.     window_name=$(xdotool getwindowfocus getwindowname)
  750.     if echo $window_name | grep -q "$window_title" ; then
  751.       echo "window active "$window_name
  752.       break
  753.     fi
  754.     sleep 0.5
  755.   done
  756. }
  757.  
  758. function cut_audio() {
  759.   xdotool key e
  760.   sleep 0.5
  761.   xdotool key e
  762.   sleep 0.5
  763. }
  764.  
  765. block_double_run
  766. wait_for_window_to_activate "$player_title"
  767. cut_audio
  768. spd-say -t female2 "split audio"::::::::::::::
  769. volume_down.bash
  770. ::::::::::::::
  771. #!/bin/bash
  772.  
  773. pactl -- set-sink-volume 0 -1%::::::::::::::
  774. volume_up.bash
  775. ::::::::::::::
  776. #!/bin/bash
  777.  
  778. pactl -- set-sink-volume 0 +1%::::::::::::::
  779. .xbindkeysrc
  780. ::::::::::::::
  781. "/media/$(whoami)/extsd/Music/rewind.bash"
  782. c:87
  783.  
  784. "/media/$(whoami)/extsd/Music/fforward.bash"
  785. c:88
  786.  
  787. "/media/$(whoami)/extsd/Music/play_pause.bash"
  788. c:89
  789.  
  790. "/media/$(whoami)/extsd/Music/mark_in_out.bash"
  791. c:104
  792.  
  793. "/media/$(whoami)/extsd/Music/split_audio.bash"
  794. c:83
  795.  
  796. "/media/$(whoami)/extsd/Music/volume_up.bash"
  797. c:86
  798.  
  799. "/media/$(whoami)/extsd/Music/volume_down.bash"
  800. c:82
  801.  
  802. "/media/$(whoami)/extsd/Music/load_file.bash"
  803. c:90
  804.  
  805. "/media/$(whoami)/extsd/Music/screen_off.bash"
  806. c:91
  807.  
  808. "/media/$(whoami)/extsd/Music/redshift.bash"
  809. c:85
  810.  
  811. "/media/$(whoami)/extsd/Music/rewind_s.bash"
  812. c:79
  813.  
  814. "/media/$(whoami)/extsd/Music/fforward_s.bash"
  815. c:80
  816.  
  817. "/media/$(whoami)/extsd/Music/escape.bash"
  818. c:106
Advertisement
Add Comment
Please, Sign In to add comment