summaryrefslogtreecommitdiff
path: root/bin/dmscripts/dmclip
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-03-03 19:53:22 +0100
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-03-03 19:53:22 +0100
commit97487ed1431ed0cfa4f5b6facd69dbd0f13911f4 (patch)
treecacc50f96ebb5a9b2a3c8d374bbf9e8ccedc64cf /bin/dmscripts/dmclip
parent5522d426e21cbedb8791ee4399ff7d28a4c6f10e (diff)
renamed dmscripts to guiscripts
Diffstat (limited to 'bin/dmscripts/dmclip')
-rwxr-xr-xbin/dmscripts/dmclip83
1 files changed, 0 insertions, 83 deletions
diff --git a/bin/dmscripts/dmclip b/bin/dmscripts/dmclip
deleted file mode 100755
index 5282b35..0000000
--- a/bin/dmscripts/dmclip
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/usr/bin/env bash
-NotImage () {
- echo -n "" | dmenu -p "NOT AN IMAGE"
- exit
-}
-
-# Display clipboard max length
-
-selection="$(echo -e "primary\nclipboard\nswap" | dmenu -l 1 -g 3 -p "selection:")"
-if [[ "${selection}" == "swap" ]]
-then
- clipboard="$(xclip -o)"
- xclip -o | xclip -sel c
- echo -n "${clipboard}" | xclip -sel c
- exit
-elif [[ "${selection}" == "" ]]
-then
- exit 1
-fi
-if "${selection}" == "primary" ]]
-then
- selection2="clipboard"
-else
- selection2="primary"
-fi
-
-
-clipboard="$(xclip -out -sel "${selection}" -r)"
-
-DICL_LEN=48
-if [[ "$(xclip -sel ${selection} -o | head -n1 | cut -c 2-4)" == "PNG" ]]
-then
- disp_clip="IMAGE"
-else
- disp_clip="$(echo -n "${clipboard}" | tr -d '\n' | cut -c -"${DICL_LEN}")"
-fi
-
-menu_option="$(\
- echo -e "save\nload\nimage\nreplace" \
- | dmenu -l 1 -g 4 -p "'${disp_clip}'" \
-)"
-[[ "${menu_option}" ]] || exit
-
-case "${menu_option}" in
-
- replace)
- replace_text="$(echo -n "" | dmenu -l 0 -p "replace:")"
- [[ "${replace_text}" ]] || exit
- replace_by_text="$(echo -n "" | dmenu -l 0 -p "by:")"
- [[ "${replace_by_text}" ]] || exit
- echo "${clipboard}" \
- | sed "s/${replace_text}/${replace_by_text}/g" \
- | xclip -r -sel "${selection}"
- ;;
-
- save)
- echo "${clipboard}" >> /tmp/tmpclip.txt
- ;;
- load)
- choice="$(\
- sort /tmp/tmpclip.txt \
- | uniq \
- | dmenu -g 1 -l 5 || exit \
- )"
- echo -n "${choice}" | xclip -sel "${selection}"
- ;;
-
- image)
- # Menu
- # 1: line from paragraph
- # 2: param
- #
- file_name="tmp_xclip"
- xclip -o -sel c > "/tmp/${file_name}.png"
- file "/tmp/${file_name}.png" \
- | cut -d ':' -f 2 \
- | grep "image" || NotImage
- # sed so that dmenu doesn't skip if one line
- tesseract "/tmp/${file_name}.png" stdout > "/tmp/${file_name}"
- sed "1i\ " "/tmp/${file_name}" | dmenu -l 10 -g 1 -p "PREVIEW:" -l 20 || exit
- xclip -sel "${selection}" -in "/tmp/${file_name}"
- ;;
-esac