blob: e90cbb1c606d79e60237e8db29a1e11b4efb82ef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#!/bin/sh
# For theme to be applied ~/.Xresource file must be present
set -f
while read -r file; do
case "$1" in
"m")
# FIXME: Providing directory selections to dmenu limits choices;
# e.g., if `/home/user/pics` is given, `/` can't be selected.
if [ -z "${destdir}" ]; then
destdir="$(printf '' \
| dmenu -c -bw 2 -p "Copy directory: " \
| sed "s|~|${HOME}|g")"
fi
# Skip non-directories to prevent overwriting files during loop processing
if [ ! -d "${destdir}" ]; then
nsend -s "Failed to move" "Not a directory: ${destdir}"
exit 1
fi
if output=$(mv -- "${file}" "${destdir}" 2>&1); then
nsend -s "Moved" "${file} to ${destdir}" &
else
nsend -s "Failed to Move" "$output" &
fi
;;
"c")
if [ -z "${destdir}" ]; then
destdir="$(printf '' \
| dmenu -c -bw 2 -p "Copy directory: " \
| sed "s|~|${HOME}|g")"
fi
if [ ! -d "${destdir}" ]; then
nsend -s "Failed to copy" "Not a directory: ${destdir}"
exit 1
fi
if output=$(cp -- "${file}" "${destdir}" 2>&1); then
nsend -s "Copied" "${file} to ${destdir}" &
else
nsend -s "Failed to copy" "$output" &
fi
;;
"d")
mkdir -p "${HOME}/.trash"
trash_path="$HOME/.trash/$(basename -- "${file}")"
if [ -e "${trash_path}" ]; then
rand=$(od -An -N2 -tu2 /dev/urandom | tr -d ' ')
trash_path="${trash_path}_$(date +%Y%m%d%H%M%S)_${rand}"
fi
if output=$(mv -- "${file}" "${trash_path}" 2>&1); then
nsend -s "Deleted" "${file} to ${trash_path}" &
else
nsend -s "Failed to delete" "$output" &
fi
;;
"y")
if printf "%s" "${file}" | xclip -selection clipboard; then
nsend -s "Relative path copied to clipboard." &
else
nsend -s "Failed to copy relative path to clipboard." &
fi
;;
"Y")
if readlink -f "${file}" | tr -d '\n' | xclip -selection clipboard; then
nsend -s "Full path copied to clipboard." &
else
nsend -s "Failed to copy full path to clipboard." &
fi
;;
"w")
if output=$(swall -d "${file}" 2>&1); then
nsend -s "Set as wallpaper" "${file}" &
else
nsend -s "Failed to set as wallpaper" "$output" &
fi
;;
# No need for nsend since whether the photo has rotated or not is obvious
# FIXME: convert is depricated use magick instead
"r") convert -rotate 90 "${file}" "${file}" ;;
"R") convert -rotate -90 "${file}" "${file}" ;;
"f") convert -flop "${file}" "${file}" ;;
esac
done
|