mirror of
https://github.com/jarun/nnn.git
synced 2025-01-15 21:36:42 +00:00
1b5cfbca3d
- Work with multiple connected devices by sending files to the first device - Support multi-files selection - Support sending hovered file in case no file is selected Co-authored-by: NRK <nrk@disroot.org> Co-authored-by: Arun Prakash Jana <engineerarun@gmail.com>
44 lines
1.1 KiB
Bash
Executable file
44 lines
1.1 KiB
Bash
Executable file
#!/usr/bin/env sh
|
|
|
|
# Description: Send files or folders to your Android device using kdeconnect-cli.
|
|
# kdeconnect must be configured on the Android device and the PC.
|
|
#
|
|
# Usage:
|
|
# - Hover over a file or a folder and call the plugin.
|
|
# - Alternatively, select the files and folders you would like to send, and activate the plugin.
|
|
#
|
|
# Shell: POSIX compliant
|
|
# Author: juacq97, raffaem
|
|
|
|
# If you want system notification, put this equal to 1
|
|
notify=0
|
|
|
|
note() {
|
|
if [ $notify = 1 ]; then
|
|
notify-send -a "Kdeconnect" "$1"
|
|
else
|
|
echo "[Kdeconnect] $1"
|
|
fi
|
|
}
|
|
|
|
send() {
|
|
xargs -0 -I{} kdeconnect-cli --name "$devname" --share {}
|
|
note "Files sent"
|
|
}
|
|
|
|
devname=$(kdeconnect-cli --list-available --name-only 2>/dev/null | awk NR==1)
|
|
if [ -z "$devname" ]; then
|
|
note "No devices available"
|
|
exit
|
|
fi
|
|
|
|
selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection}
|
|
if [ -s "$selection" ]; then
|
|
send < "$selection"
|
|
[ -p "$NNN_PIPE" ] && printf "-" > "$NNN_PIPE" # clear selection
|
|
elif [ -n "$1" ]; then
|
|
printf "%s" "$1" | send
|
|
else
|
|
note "No selection and no hovered file"
|
|
fi
|