diff options
Diffstat (limited to '')
| -rw-r--r-- | Makefile | 1 | ||||
| -rwxr-xr-x | clip | 34 |
2 files changed, 35 insertions, 0 deletions
| @@ -4,6 +4,7 @@ SCRIPTS = addressgrep \ | |||
| 4 | battery-checknow \ | 4 | battery-checknow \ |
| 5 | battery-status \ | 5 | battery-status \ |
| 6 | brightness \ | 6 | brightness \ |
| 7 | clip \ | ||
| 7 | config-backup \ | 8 | config-backup \ |
| 8 | dmenu-bookmarks \ | 9 | dmenu-bookmarks \ |
| 9 | dmenu-dwm-sessionmanager \ | 10 | dmenu-dwm-sessionmanager \ |
| @@ -0,0 +1,34 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # A primitive clipboard manager. Saves the current selection to a temporary | ||
| 4 | # file and shows all saved selections in dmenu for the user to select one. | ||
| 5 | # It does not check for duplicates and it fails if there it can't | ||
| 6 | # create the temporary directory with the designated name. | ||
| 7 | |||
| 8 | # Requires: xsel, dmenu | ||
| 9 | |||
| 10 | # TODO: improve formatting in dmenu | ||
| 11 | |||
| 12 | menu="dmenu" | ||
| 13 | menuopts="-l 25" | ||
| 14 | |||
| 15 | dir="/tmp/clipdir" | ||
| 16 | mkdir -p "$dir" | ||
| 17 | |||
| 18 | file="$(mktemp -p $dir $(date +%s).XXXXX)" | ||
| 19 | xsel > "$file" | ||
| 20 | |||
| 21 | list="$(mktemp)" | ||
| 22 | ls $dir > $list; | ||
| 23 | |||
| 24 | lines="$(mktemp)" | ||
| 25 | for f in $dir/*; do | ||
| 26 | nlines=$(expr 1 + "$(wc -l $f | awk '{print $1}')") | ||
| 27 | fclean=$(echo $f | sed "s|$dir\/||") | ||
| 28 | printf "$fclean ($nlines) | $(head -n 1 $f)\n" >> "$lines" | ||
| 29 | done | ||
| 30 | |||
| 31 | selected=$(sort -r $lines | $menu $menuopts | awk '{print $1}') | ||
| 32 | if [ -n "$selected" ]; then | ||
| 33 | xsel -ib < "$dir/$selected" | ||
| 34 | fi | ||
