summaryrefslogtreecommitdiff
path: root/bin/guiscripts
diff options
context:
space:
mode:
Diffstat (limited to 'bin/guiscripts')
-rwxr-xr-xbin/guiscripts/dmapimg7
-rwxr-xr-xbin/guiscripts/dmask2
-rwxr-xr-xbin/guiscripts/dmclip92
-rwxr-xr-xbin/guiscripts/dmemoji2
-rwxr-xr-xbin/guiscripts/dmpdf14
-rwxr-xr-xbin/guiscripts/dmvid20
6 files changed, 66 insertions, 71 deletions
diff --git a/bin/guiscripts/dmapimg b/bin/guiscripts/dmapimg
index 25c414b..3677ed3 100755
--- a/bin/guiscripts/dmapimg
+++ b/bin/guiscripts/dmapimg
@@ -1,6 +1,7 @@
-#!/bin/bash
+#!/bin/sh
+dest="$XDG_DATA_HOME"/appimages/
appimage="$(\
- find ~/.local/share/appimages -type f -printf "%f\n" \
+ find "$dest" -type f -printf "%f\n" \
| sed 's/\.[Aa]pp[Ii]mage$//g' \
| dmenu -x -l 10 -g 1 -p "AppImage:")"
-setsid ~/AppImages/"${appimage:-NOSEL}"*
+setsid "${dest}/${appimage:-NOSEL}"*
diff --git a/bin/guiscripts/dmask b/bin/guiscripts/dmask
index 6772854..dd52c5a 100755
--- a/bin/guiscripts/dmask
+++ b/bin/guiscripts/dmask
@@ -4,7 +4,7 @@
which dmenu Xdialog ask > /dev/null ||
exit 1
-prompt="$(echo -n | dmenu -p "prompt:" | tr '"' "'")"
+prompt="$(echo -n | dmenu -p "prompt:" | tr '"' "'" | tee -a /tmp/dmask_history)"
test -z "$prompt" && exit 1
answer="$(ask "$prompt" | tr '"' "'" | fold -w 80 -s)"
diff --git a/bin/guiscripts/dmclip b/bin/guiscripts/dmclip
index 5282b35..9c09b04 100755
--- a/bin/guiscripts/dmclip
+++ b/bin/guiscripts/dmclip
@@ -1,83 +1,79 @@
-#!/usr/bin/env bash
+#!/bin/sh
+
+# Display Clipboard Length
+DICL_LEN=48
+tmp="/tmp/dmclip"
+
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" ]]
+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
+ echo -n "$clipboard" | xclip -sel c
exit
-elif [[ "${selection}" == "" ]]
+elif [ "$selection" == "" ]
then
exit 1
-fi
-if "${selection}" == "primary" ]]
+elif [ "$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" ]]
+if xclip -sel $selection -o -t TARGETS | grep "image/png"
then
disp_clip="IMAGE"
else
- disp_clip="$(echo -n "${clipboard}" | tr -d '\n' | cut -c -"${DICL_LEN}")"
+ clipboard="$(xclip -out -sel "$selection" -r)"
+ 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
+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}"
+ 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
+ echo "$clipboard" >> /tmp/tmpclip.txt
;;
load)
- choice="$(\
- sort /tmp/tmpclip.txt \
- | uniq \
- | dmenu -g 1 -l 5 || exit \
- )"
- echo -n "${choice}" | xclip -sel "${selection}"
+ choice="$(sort "${tmp}.txt" |
+ uniq |
+ dmenu -g 1 -l 5)"
+ [ "$choice" ] || exit 1
+ 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
+ xclip -o -sel c > "${tmp}.png"
+ file -bi "${tmp}.png" |
+ grep "image/png" || 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}"
+ tesseract "${tmp}.png" stdout > "$tmp"
+ sed "1i\ " "$tmp" |
+ dmenu -l 10 -g 1 -p "PREVIEW:" -l 20 ||
+ exit
+ xclip -sel "$selection" -i "$tmp"
;;
esac
diff --git a/bin/guiscripts/dmemoji b/bin/guiscripts/dmemoji
index 9f026b1..21c5150 100755
--- a/bin/guiscripts/dmemoji
+++ b/bin/guiscripts/dmemoji
@@ -17,7 +17,7 @@ case "$1" in
if [ ! -z "$input" ]; then
emoji=${input::1}
echo -n "$emoji" | xclip -selection c
- dunstify "dmemoji" "$emoji copied!"
+ notify-send "dmemoji" "$emoji <b>copied!</b>"
fi
;;
"")
diff --git a/bin/guiscripts/dmpdf b/bin/guiscripts/dmpdf
index 21f3ed0..2d51760 100755
--- a/bin/guiscripts/dmpdf
+++ b/bin/guiscripts/dmpdf
@@ -1,14 +1,14 @@
#!/bin/bash
-find ${1:-$HOME/docs $HOME/dl} 2> /dev/null | grep -E ".+\.pdf" | sort > /tmp/dmpdf
+tmp="/tmp/dmpdf"
+find ${1:-$HOME/docs $HOME/dl} 2> /dev/null | grep -E ".+\.pdf" | sort > "$tmp"
choice="$(\
- sed 's|^/home/aluc|\~| ; s|\([^/]\)[^/]*/|\1/|g' /tmp/dmpdf \
- | awk '{printf "%s %s\n", NR ":", $0}' \
- | dmenu -l 10 -g 1 -x -i \
- | grep -oE "^[0-9]+:" \
-)"
+ sed 's|^/home/aluc|\~| ; s|\([^/]\)[^/]*/|\1/|g' "$tmp" |
+ awk '{printf "%s %s\n", NR ":", $0}' |
+ dmenu -p "pdf:" -l 10 -g 1 -x -i |
+ grep -oE "^[0-9]+:")"
if [ -z "$choice" ]; then
exit
fi
-file="$(sed -n "${choice::-1}p" /tmp/dmpdf)"
+file="$(sed -n "${choice::-1}p" "$tmp")"
zathura "$file" &
diff --git a/bin/guiscripts/dmvid b/bin/guiscripts/dmvid
index 16e164f..fe3155e 100755
--- a/bin/guiscripts/dmvid
+++ b/bin/guiscripts/dmvid
@@ -1,14 +1,12 @@
#!/usr/bin/env bash
find ${1:-~/vids ~/dl} 2> /dev/null | grep -E ".+\.(webm|mp4|mpeg|mkv)$" | sort > /tmp/dmvids
-choice="$(\
- sed 's|^/home/aluc|\~| ; s|\([^/]\)[^/]*/|\1/|g' /tmp/dmvids \
- | awk '{printf "%s %s\n", NR ":", $0}' \
- | dmenu -l 10 -g 1 -x -i \
- | grep -zoE "^[0-9]+:" \
-)"
-if [ -z "$choice" ]; then
- exit
-fi
-vid="$(sed -n "${choice::-1}p" /tmp/dmvids)"
-mpv "$vid"
+
+choice="$(sed 's|^/home/aluc|\~| ; s|\([^/]\)[^/]*/|\1/|g' /tmp/dmvids |
+ awk '{printf "%s %s\n", NR ":", $0}' |
+ dmenu -l 10 -g 1 -x -i |
+ grep -zoE "^[0-9]+:")"
+test -z "$choice" &&
+ exit 1
+
+mpv "$(sed -n "${choice::-1}p" /tmp/dmvids)"