diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2022-02-17 19:30:15 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2022-02-17 19:30:15 +0100 |
| commit | 7d873ea2e49913a3ace857b4b4ff47acf6279db6 (patch) | |
| tree | 2eaf1e846f3d204d7167f053635f0d58020f7c8a /clip | |
| parent | 92e73d48e352e02cfc7f920402398928054a375f (diff) | |
| download | scripts-7d873ea2e49913a3ace857b4b4ff47acf6279db6.tar.gz scripts-7d873ea2e49913a3ace857b4b4ff47acf6279db6.zip | |
Added clipboard support (not only selection). Check for duplicate selections.
Diffstat (limited to '')
| -rwxr-xr-x | clip | 22 |
1 files changed, 16 insertions, 6 deletions
| @@ -1,9 +1,11 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | # A primitive clipboard manager. Saves the current selection to a temporary | 3 | # A primitive clipboard manager. Saves the current selection and clipboard |
| 4 | # file and shows all saved selections in dmenu for the user to select one. | 4 | # to a temporary file and shows all saved selections in dmenu for the user |
| 5 | # It does not check for duplicates and it fails if there it can't | 5 | # to select one. Duplicate selections are avoided. |
| 6 | # create the temporary directory with the designated name. | 6 | |
| 7 | # Bugs (wontfix): the program fails if it can't create the temporary | ||
| 8 | # directory with the designated name. | ||
| 7 | 9 | ||
| 8 | # Requires: xsel, dmenu | 10 | # Requires: xsel, dmenu |
| 9 | 11 | ||
| @@ -15,8 +17,16 @@ menuopts="-l 25" | |||
| 15 | dir="/tmp/clipdir" | 17 | dir="/tmp/clipdir" |
| 16 | mkdir -p "$dir" | 18 | mkdir -p "$dir" |
| 17 | 19 | ||
| 18 | file="$(mktemp -p $dir $(date +%s).XXXXX)" | 20 | file1="$(mktemp -p $dir $(date +%s).XXXXX)" |
| 19 | xsel > "$file" | 21 | file2="$(mktemp -p $dir $(date +%s)b.XXXX)" |
| 22 | xsel > "$file1" | ||
| 23 | xsel -b > "$file2" | ||
| 24 | |||
| 25 | # Avoid duplicates | ||
| 26 | for f in $dir/*; do | ||
| 27 | [ "$f" != "$file1" ] && if diff "$f" "$file1"; then rm "$file1"; fi | ||
| 28 | [ "$f" != "$file2" ] && if diff "$f" "$file2"; then rm "$file2"; fi | ||
| 29 | done | ||
| 20 | 30 | ||
| 21 | list="$(mktemp)" | 31 | list="$(mktemp)" |
| 22 | ls $dir > $list; | 32 | ls $dir > $list; |
