After something is copied to clipboard (using ctrl+c) I want a script (bash, python or any other language) to automatically detect that new entry is added to clipboard, change it's content and put it back to clipboard so when I paste it I get the modified text. The script should constantly run in background and monitor the clipboard for changes.
The following script describes the modification that is needed :
Source : https://superuser.com/questions/796292/is-there-an-efficient-way-to-copy-text-from-a-pdf-without-the-line-breaks
#!/bin/bash
# title: copy_without_linebreaks
# author: Glutanimate (github.com/glutanimate)
# license: MIT license
# Parses currently selected text and removes
# newlines that aren't preceded by a full stop
SelectedText="$(xsel)"
ModifiedText="$(echo "$SelectedText" | \
sed 's/\.$/.|/g' | sed 's/^\s*$/|/g' | tr '\n' ' ' | tr '|' '\n')"
# - first sed command: replace end-of-line full stops with '|' delimiter and keep original periods.
# - second sed command: replace empty lines with same delimiter (e.g.
# to separate text headings from text)
# - subsequent tr commands: remove existing newlines; replace delimiter with
# newlines
# This is less than elegant but it works.
echo "$ModifiedText" | xsel -bi
I do not want to use shortcut key binding to run the script.