2

I want the text copied from the mouse (clipboard or X selection), or copied with Ctrl+C, to be automatically transferred to a text file.

I am using a very good website for subtitling videos called VEED [1], which automatically generates subtitles from the audio, but it not allow, in the free version, to download the subtitle file in .SBV or .SRT format, with the captions and time periods. It is necessary to copy and paste each piece of caption and time period, one at a time. Therefore, I would like a way to facilitate this task, automatically transferring each piece of text and time copied for some text file.

0

1 Answer 1

2

The steps to follow are the same as the source in Glutanimate,Siddharth, but instead of using the program used in Glutanimate,Siddharth here the program given below should be used.

Before using the program, you must specify, in the program, the destination file of the copied text. In the case below, the destination file is /home/jim-carrey/Desktop/your-file.txt. The program is as follows:

#!/bin/bash

# name: automatic_transfer_copied_text
# author: Ghost Rider 
# source: Glutanimate and Siddharth (https://askubuntu.com/questions/1167026/detect-clipboard-copy-paste-event-and-modify-clipboard-contents)

# Automatically transfers text copied by the mouse to some text file

while ./clipnotify;
do
  SelectedText="$(xsel)"
  CopiedText="$(xsel -b)"
  if [[ $CopiedText == $SelectedText ]]; then
    echo $CopiedText >> "/home/jim-carrey/Desktop/your-file.txt"
  fi
done

Dependencies :

  1. xsel
    sudo apt-get install xsel
  2. clipnotify (https://github.com/cdown/clipnotify)
    You can use the pre-compiled clipnotify provided in the repository or compile yourself.

To compile clipnotify yourself :
sudo apt install git build-essential libx11-dev libxtst-dev
git clone https://github.com/cdown/clipnotify.git
cd clipnotify
sudo make

To USE :

  1. Download this repository as zip or copy and paste the script in a text editor and save it as automatic_transfer_copied_text.sh.
  2. Make sure that script and clipnotify (downloaded or precompiled) are in same folder.
  3. Open terminal in script's folder and set permission
    chmod +x "automatic_transfer_copied_text.sh"
  4. Run by entering in terminal :
    ./automatic_transfer_copied_text.sh
  5. Ready. While the program is running, any copied text will be sent to the specified file, in the case in question, /home/jim-carrey/Desktop/your-file.txt.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .