Guest User

audio bookmark manager 3

a guest
Mar 19th, 2023
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 12.58 KB | Software | 0 0
  1. ::::::::::::::
  2. fforward.bash
  3. ::::::::::::::
  4. #!/bin/bash
  5.  
  6.  
  7. player_title="LosslessCut"
  8.  
  9.  
  10. function wait_for_window_to_activate() {
  11.   # first parameter  - window title or part of the window title
  12.   window_title="$1"
  13.   time_sec=900
  14.   while [[ 0 -ne $time_sec ]]; do
  15.     echo "$time_sec, waiting... to activate"
  16.     time_sec=$[$time_sec-1]
  17.     xdotool search --onlyvisible --name "$window_title" windowactivate
  18.     window_name=$(xdotool getwindowfocus getwindowname)
  19.     if echo $window_name | grep -q "$window_title" ; then
  20.       echo "window active "$window_name
  21.       break
  22.     fi
  23.     sleep 0.5
  24.   done
  25. }
  26.  
  27. function time_add_10s() {
  28.     # time format 00:58:12.749
  29.     IFS=':' read -ra my_array1 <<< "$1"
  30.     hr=${my_array1[0]}
  31.     min=${my_array1[1]}
  32.     sec=${my_array1[2]%.*}
  33.     msec=${my_array1[2]##*.}
  34.     secs=$(date +%s --date="1970-03-24 $hr:$min:$sec")
  35.     # add 10s
  36.     d=$(date '+%d.%b.%Y %T' --date="@$((secs + 10))")
  37.     t="${d##* }"".$msec"
  38.     echo $t
  39. }
  40.  
  41. function enter_timecode() {
  42.     wait_for_window_to_activate "$player_title"
  43.     echo -n "" | xclip -selection clipboard
  44.     xdotool key g
  45.     sleep 0.1
  46.     xdotool key Ctrl+a
  47.     sleep 0.1
  48.     xdotool key Ctrl+c
  49.     clip_read=$(xsel -b)
  50.     mod_t=$(time_add_10s "$clip_read")
  51.     echo -n "$mod_t" | xclip -selection clipboard
  52.     xdotool key Ctrl+v
  53.     xdotool key Return
  54.     echo $clip_read
  55. }
  56.  
  57. enter_timecode
  58. spd-say -t female2 n::::::::::::::
  59. fforward_s.bash
  60. ::::::::::::::
  61. #!/bin/bash
  62.  
  63.  
  64. player_title="LosslessCut"
  65.  
  66.  
  67. function wait_for_window_to_activate() {
  68.   # first parameter  - window title or part of the window title
  69.   window_title="$1"
  70.   time_sec=900
  71.   while [[ 0 -ne $time_sec ]]; do
  72.     echo "$time_sec, waiting... to activate"
  73.     time_sec=$[$time_sec-1]
  74.     xdotool search --onlyvisible --name "$window_title" windowactivate
  75.     window_name=$(xdotool getwindowfocus getwindowname)
  76.     if echo $window_name | grep -q "$window_title" ; then
  77.       echo "window active "$window_name
  78.       break
  79.     fi
  80.     sleep 0.5
  81.   done
  82. }
  83.  
  84. function time_add_3s() {
  85.     # time format 00:58:12.749
  86.     IFS=':' read -ra my_array1 <<< "$1"
  87.     hr=${my_array1[0]}
  88.     min=${my_array1[1]}
  89.     sec=${my_array1[2]%.*}
  90.     msec=${my_array1[2]##*.}
  91.     secs=$(date +%s --date="1970-03-24 $hr:$min:$sec")
  92.     # add 10s
  93.     d=$(date '+%d.%b.%Y %T' --date="@$((secs + 3))")
  94.     t="${d##* }"".$msec"
  95.     echo $t
  96. }
  97.  
  98. function enter_timecode() {
  99.     wait_for_window_to_activate "$player_title"
  100.     echo -n "" | xclip -selection clipboard
  101.     xdotool key g
  102.     sleep 0.1
  103.     xdotool key Ctrl+a
  104.     sleep 0.1
  105.     xdotool key Ctrl+c
  106.     clip_read=$(xsel -b)
  107.     mod_t=$(time_add_3s "$clip_read")
  108.     echo -n "$mod_t" | xclip -selection clipboard
  109.     xdotool key Ctrl+v
  110.     xdotool key Return
  111.     echo $clip_read
  112. }
  113.  
  114. enter_timecode
  115. spd-say -t female2 n::::::::::::::
  116. load_file.bash
  117. ::::::::::::::
  118. #!/bin/bash
  119.  
  120.  
  121. recordings_dir="/media/$(whoami)/extsd/recordings/"
  122. music_dir="/media/$(whoami)/extsd/Music/"
  123. clips_dir="$music_dir"clips/""
  124. player_full_path="$music_dir"LosslessCut-linux-x86_64.AppImage""
  125. player_title="LosslessCut"
  126.  
  127.  
  128. function wait_for_window() {
  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 appear"
  134.     sleep 1
  135.     time_sec=$[$time_sec-1]
  136.     xdotool search --onlyvisible --name "$window_title" windowactivate
  137.     if [[ $? == 0 ]]; then
  138.         xdotool getactivewindow windowmove 1 30
  139.       echo "window found"
  140.       break
  141.     fi
  142.   done
  143. }
  144.  
  145. function repeat_send_key() {
  146.   window_title="$1"
  147.   key="$2"
  148.   repeat="${3:-1}"
  149.   xdotool search --onlyvisible --name "$window_title" windowactivate
  150.   if [[ $? == 0 ]]; then
  151.       for (( i=1; i <= repeat; i++ ))
  152.       do
  153.        xdotool key $key
  154.        sleep 0.1
  155.       done
  156.     fi
  157. }
  158.  
  159. function make_it_exec() {
  160.     file_full_path="$1"
  161.     if [[ -x "$file_full_path" ]]; then
  162.         echo "File is executable"
  163.     else
  164.         chmod +x "$file_full_path"
  165.         echo "File is executable now"
  166.     fi
  167. }
  168.  
  169. function check_out_loc() {
  170.   w_dir="$1"
  171.   if [ -d "$w_dir" ]; then
  172.     echo direcotry exists
  173.   else
  174.     mkdir "$w_dir"
  175.     echo direcotry created
  176.   fi
  177. }
  178.  
  179. function check_audio_playback() {
  180.   time_sec=60
  181.   while [[ 0 -ne $time_sec ]]; do
  182.     repeat_send_key "$player_title" space
  183.     echo "$time_sec, waiting... to play"
  184.     sleep 1
  185.     time_sec=$[$time_sec-1]
  186.     status=$(pacmd list-sink-inputs | grep -c 'state: RUNNING')
  187.     if [[ $status -gt 0 ]]; then
  188.       echo "sound is playing"
  189.       break
  190.     fi
  191.   done
  192. }
  193.  
  194. function load_file() {
  195.     check_out_loc "$clips_dir"
  196.     cd $recordings_dir
  197.     readarray -t files < <(find ./ -maxdepth 1 -type f -regex '.*\.\(mp3\|flac\)$' | sed "s/.*\///" | sort)
  198.     if [ ${#files[@]} -gt 0 ]; then
  199.         file_name=$(basename "${files[0]}" | cut -d. -f1)
  200.         file_extension=$(basename "${files[0]}" | cut -d. -f2)
  201.         out_dir="$music_dir"
  202.         mv "$file_name.$file_extension" "$out_dir"
  203.         make_it_exec "$player_full_path"
  204.         echo "$out_dir$file_name.$file_extension"
  205.         killall losslesscut
  206.         "$player_full_path" --settings-json '{customOutDir:"'"${clips_dir::-1}"'", "autoMerge":"true"}' "$out_dir$file_name.$file_extension" &
  207.         wait_for_window "$player_title"
  208.         check_audio_playback
  209.     fi
  210. }
  211.  
  212. function move_previous() {
  213.     cd $music_dir
  214.     readarray -t files < <(find ./ -maxdepth 1 -type f -regex '.*\.\(mp3\|flac\)$' | sed "s/.*\///" | sort)
  215.     if [ ${#files[@]} -gt 0 ]; then
  216.         file_name=$(basename "${files[0]}" | cut -d. -f1)
  217.         file_extension=$(basename "${files[0]}" | cut -d. -f2)
  218.         date_str=$(date +%s)
  219.         check_out_loc "$clips_dir"
  220.         out_dir="$clips_dir"
  221.         echo "file to move: ""$file_name.$file_extension"
  222.         mv "$file_name.$file_extension" "$out_dir"$date_str"_$file_name.$file_extension"
  223.     fi
  224. }
  225.  
  226. move_previous
  227. load_file
  228. spd-say -t female2 "file loaded"::::::::::::::
  229. mark_in_out.bash
  230. ::::::::::::::
  231. #!/bin/bash
  232.  
  233.  
  234. recordings_dir="/media/$(whoami)/extsd/recordings/"
  235. player_title="LosslessCut"
  236. markin_loc="$recordings_dir"markin.txt""
  237.  
  238.  
  239. function wait_for_window_to_activate() {
  240.   # first parameter  - window title or part of the window title
  241.   window_title="$1"
  242.   time_sec=900
  243.   while [[ 0 -ne $time_sec ]]; do
  244.     echo "$time_sec, waiting... to activate"
  245.     time_sec=$[$time_sec-1]
  246.     xdotool search --onlyvisible --name "$window_title" windowactivate
  247.     window_name=$(xdotool getwindowfocus getwindowname)
  248.     if echo $window_name | grep -q "$window_title" ; then
  249.       echo "window active "$window_name
  250.       break
  251.     fi
  252.     sleep 0.5
  253.   done
  254. }
  255.  
  256. function repeat_send_key() {
  257.   window_title="$1"
  258.   key="$2"
  259.   repeat="${3:-1}"
  260.   xdotool search --onlyvisible --name "$window_title" windowactivate
  261.   if [[ $? == 0 ]]; then
  262.       for (( i=1; i <= repeat; i++ ))
  263.       do
  264.         xdotool key $key
  265.         sleep 0.1
  266.       done
  267.     fi
  268. }
  269.  
  270. function mark_in_out() {
  271.     if [[ -f $markin_loc ]]; then
  272.         repeat_send_key "$player_title" "o"
  273.         rm $markin_loc
  274.     else
  275.         repeat_send_key "$player_title" "i"
  276.         echo "mark in" > $markin_loc
  277.     fi
  278. }
  279.  
  280. wait_for_window_to_activate "$player_title"
  281. mark_in_out
  282. spd-say -t female2 m::::::::::::::
  283. play_pause.bash
  284. ::::::::::::::
  285. #!/bin/bash
  286.  
  287.  
  288. player_title="LosslessCut"
  289.  
  290.  
  291. function wait_for_window_to_activate() {
  292.   # first parameter  - window title or part of the window title
  293.   window_title="$1"
  294.   time_sec=900
  295.   while [[ 0 -ne $time_sec ]]; do
  296.     echo "$time_sec, waiting... to close"
  297.     time_sec=$[$time_sec-1]
  298.     xdotool search --onlyvisible --name "$window_title" windowactivate
  299.     window_name=$(xdotool getwindowfocus getwindowname)
  300.     if echo $window_name | grep -q "$window_title" ; then
  301.       echo "window active "$window_name
  302.       break
  303.     fi
  304.     sleep 0.5
  305.   done
  306. }
  307.  
  308. function repeat_send_key() {
  309.   window_title="$1"
  310.   key="$2"
  311.   repeat="${3:-1}"
  312.   xdotool search --onlyvisible --name "$window_title" windowactivate
  313.   if [[ $? == 0 ]]; then
  314.       for (( i=1; i <= repeat; i++ ))
  315.       do
  316.         xdotool key $key
  317.         sleep 0.1
  318.       done
  319.     fi
  320. }
  321.  
  322. spd-say -t female2 s
  323. wait_for_window_to_activate "$player_title"
  324. repeat_send_key "$player_title" space::::::::::::::
  325. redshift.bash
  326. ::::::::::::::
  327. #!/bin/bash
  328.  
  329. redshift -O 3700
  330. spd-say -t female2 "redshift"::::::::::::::
  331. rewind.bash
  332. ::::::::::::::
  333. #!/bin/bash
  334.  
  335.  
  336. player_title="LosslessCut"
  337.  
  338.  
  339. function wait_for_window_to_activate() {
  340.   # first parameter  - window title or part of the window title
  341.   window_title="$1"
  342.   time_sec=900
  343.   while [[ 0 -ne $time_sec ]]; do
  344.     echo "$time_sec, waiting... to activate"
  345.     time_sec=$[$time_sec-1]
  346.     xdotool search --onlyvisible --name "$window_title" windowactivate
  347.     window_name=$(xdotool getwindowfocus getwindowname)
  348.     if echo $window_name | grep -q "$window_title" ; then
  349.       echo "window active "$window_name
  350.       break
  351.     fi
  352.     sleep 0.5
  353.   done
  354. }
  355.  
  356. function time_minus_10s() {
  357.   # time format 00:58:12.749
  358.   IFS=':' read -ra my_array1 <<< "$1"
  359.   hr=${my_array1[0]}
  360.   min=${my_array1[1]}
  361.   sec=${my_array1[2]%.*}
  362.   msec=${my_array1[2]##*.}
  363.   secs=$(date +%s --date="1970-03-24 $hr:$min:$sec")
  364.   # minus 10s
  365.   d=$(date '+%d.%b.%Y %T' --date="@$((secs - 10))")
  366.   t="${d##* }"".$msec"
  367.   echo $t
  368. }
  369.  
  370. function enter_timecode() {
  371.   wait_for_window_to_activate "$player_title"
  372.   echo -n "" | xclip -selection clipboard
  373.   xdotool key g
  374.   sleep 0.1
  375.   xdotool key Ctrl+a
  376.   sleep 0.1
  377.   xdotool key Ctrl+c
  378.   clip_read=$(xsel -b)
  379.   mod_t=$(time_minus_10s "$clip_read")
  380.   echo -n "$mod_t" | xclip -selection clipboard
  381.   xdotool key Ctrl+v
  382.   xdotool key Return
  383.   echo $clip_read
  384. }
  385.  
  386. enter_timecode
  387. spd-say -t female2 p::::::::::::::
  388. rewind_s.bash
  389. ::::::::::::::
  390. #!/bin/bash
  391.  
  392.  
  393. player_title="LosslessCut"
  394.  
  395.  
  396. function wait_for_window_to_activate() {
  397.   # first parameter  - window title or part of the window title
  398.   window_title="$1"
  399.   time_sec=900
  400.   while [[ 0 -ne $time_sec ]]; do
  401.     echo "$time_sec, waiting... to activate"
  402.     time_sec=$[$time_sec-1]
  403.     xdotool search --onlyvisible --name "$window_title" windowactivate
  404.     window_name=$(xdotool getwindowfocus getwindowname)
  405.     if echo $window_name | grep -q "$window_title" ; then
  406.       echo "window active "$window_name
  407.       break
  408.     fi
  409.     sleep 0.5
  410.   done
  411. }
  412.  
  413. function time_minus_3s() {
  414.   # time format 00:58:12.749
  415.   IFS=':' read -ra my_array1 <<< "$1"
  416.   hr=${my_array1[0]}
  417.   min=${my_array1[1]}
  418.   sec=${my_array1[2]%.*}
  419.   msec=${my_array1[2]##*.}
  420.   secs=$(date +%s --date="1970-03-24 $hr:$min:$sec")
  421.   # minus 10s
  422.   d=$(date '+%d.%b.%Y %T' --date="@$((secs - 3))")
  423.   t="${d##* }"".$msec"
  424.   echo $t
  425. }
  426.  
  427. function enter_timecode() {
  428.   wait_for_window_to_activate "$player_title"
  429.   echo -n "" | xclip -selection clipboard
  430.   xdotool key g
  431.   sleep 0.1
  432.   xdotool key Ctrl+a
  433.   sleep 0.1
  434.   xdotool key Ctrl+c
  435.   clip_read=$(xsel -b)
  436.   mod_t=$(time_minus_3s "$clip_read")
  437.   echo -n "$mod_t" | xclip -selection clipboard
  438.   xdotool key Ctrl+v
  439.   xdotool key Return
  440.   echo $clip_read
  441. }
  442.  
  443. enter_timecode
  444. spd-say -t female2 p::::::::::::::
  445. screen_off.bash
  446. ::::::::::::::
  447. #!/bin/bash
  448.  
  449. xrandr --output DSI-1 --brightness 0.20
  450. spd-say -t female2 "screen off"
  451. xset dpms force off::::::::::::::
  452. split_audio.bash
  453. ::::::::::::::
  454. #!/bin/bash
  455.  
  456.  
  457. player_title="LosslessCut"
  458.  
  459.  
  460. function wait_for_window_to_activate() {
  461.   # first parameter  - window title or part of the window title
  462.   window_title="$1"
  463.   time_sec=900
  464.   while [[ 0 -ne $time_sec ]]; do
  465.     echo "$time_sec, waiting... to activate"
  466.     time_sec=$[$time_sec-1]
  467.     xdotool search --onlyvisible --name "$window_title" windowactivate
  468.     window_name=$(xdotool getwindowfocus getwindowname)
  469.     if echo $window_name | grep -q "$window_title" ; then
  470.       echo "window active "$window_name
  471.       break
  472.     fi
  473.     sleep 0.5
  474.   done
  475. }
  476.  
  477. function cut_audio() {
  478.   xdotool key e
  479.   sleep 0.5
  480.   xdotool key e
  481.   sleep 0.5
  482. }
  483.  
  484. wait_for_window_to_activate "$player_title"
  485. cut_audio
  486. spd-say -t female2 "split audio"::::::::::::::
  487. volume_down.bash
  488. ::::::::::::::
  489. #!/bin/bash
  490.  
  491. pactl -- set-sink-volume 0 -1%::::::::::::::
  492. volume_up.bash
  493. ::::::::::::::
  494. #!/bin/bash
  495.  
  496. pactl -- set-sink-volume 0 +1%::::::::::::::
  497. .xbindkeysrc
  498. ::::::::::::::
  499. "/media/$(whoami)/extsd/Music/rewind.bash"
  500. c:87
  501.  
  502. "/media/$(whoami)/extsd/Music/fforward.bash"
  503. c:88
  504.  
  505. "/media/$(whoami)/extsd/Music/play_pause.bash"
  506. c:89
  507.  
  508. "/media/$(whoami)/extsd/Music/mark_in_out.bash"
  509. c:104
  510.  
  511. "/media/$(whoami)/extsd/Music/split_audio.bash"
  512. c:83
  513.  
  514. "/media/$(whoami)/extsd/Music/volume_up.bash"
  515. c:86
  516.  
  517. "/media/$(whoami)/extsd/Music/volume_down.bash"
  518. c:82
  519.  
  520. "/media/$(whoami)/extsd/Music/load_file.bash"
  521. c:90
  522.  
  523. "/media/$(whoami)/extsd/Music/screen_off.bash"
  524. c:91
  525.  
  526. "/media/$(whoami)/extsd/Music/redshift.bash"
  527. c:85
  528.  
  529. "/media/$(whoami)/extsd/Music/rewind_s.bash"
  530. c:79
  531.  
  532. "/media/$(whoami)/extsd/Music/fforward_s.bash"
  533. c:80
Advertisement
Add Comment
Please, Sign In to add comment