3 # Description: Send files or folders to your Android device using kdeconnect-cli.
4 # kdeconnect must be configured on the Android device and the PC.
7 # - Hover over a file or a folder and call the plugin.
8 # - Alternatively, select the files and folders you would like to send, and activate the plugin.
10 # Shell: POSIX compliant
11 # Author: juacq97, raffaem, N-R-K
13 # If you want system notification, put this equal to 1
17 if [ $notify = 1 ]; then
18 notify-send -a "Kdeconnect" "$1"
20 echo "[Kdeconnect] $1"
24 # kdeconnect doesn't cope with non-files
30 printf "Error: not a regular file: %s\n" "{}" >&2;
35 filter_files | xargs -0 -I{} kdeconnect-cli --name "$devname" --share {}
39 # Select paired device
40 names=$(kdeconnect-cli --list-available --name-only 2>/dev/null)
41 if [ -z "$names" ]; then
42 note "No devices paired and available"
46 ndevs=$(printf "%s" "$names" | awk 'END{print NR}')
47 if [ "$ndevs" -eq 1 ]; then
50 printf "%s" "$names" | awk '{ print NR ". " $0 }'
51 printf "Pick a device: "
53 if [ -n "$pick" ] && [ "$pick" -eq "$pick" ]; then
54 devname=$(printf '%s' "$names" | awk "NR==$pick")
58 selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
59 if [ -s "$selection" ]; then
61 [ -p "$NNN_PIPE" ] && printf "-" > "$NNN_PIPE" # clear selection
62 elif [ -n "$1" ]; then
63 printf "%s" "$1" | send
65 note "No selection and no hovered file"