From 83b6d6aff77aac5b2fe4c6a8a0ea097f634d99e8 Mon Sep 17 00:00:00 2001 From: Darukutsu Date: Sun, 20 Feb 2022 17:57:30 +0100 Subject: [PATCH 1/4] Added a user-script/plugin to send selected files using GSConnect. --- plugins/README.md | 1 + plugins/gsconnect | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100755 plugins/gsconnect diff --git a/plugins/README.md b/plugins/README.md index 88449c37..f64e2fcb 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -37,6 +37,7 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina | [imgview](imgview) | View (thumbnail)images, set wallpaper, [rename](https://github.com/jarun/nnn/wiki/Basic-use-cases#browse-rename-images) and [more](https://wiki.archlinux.org/index.php/Sxiv#Assigning_keyboard_shortcuts)| sh | _see in-file docs_ | | [ipinfo](ipinfo) | Fetch external IP address and whois information | sh | curl, whois | | [kdeconnect](kdeconnect) | Send selected files to an Android device [✓] | sh | kdeconnect-cli | +| [gsconnect](gsconnect) | GNOME's implementation of kdeconnect [✓] | sh | GNOME, GSConnect-extension| | [launch](launch) | GUI application launcher | sh | fzf | | [mimelist](mimelist) | List files by mime in subtree | sh | - | | [moclyrics](moclyrics) | Show lyrics of the track playing in moc | sh | [ddgr](https://github.com/jarun/ddgr), [moc](http://moc.daper.net/) | diff --git a/plugins/gsconnect b/plugins/gsconnect new file mode 100755 index 00000000..38ebdb97 --- /dev/null +++ b/plugins/gsconnect @@ -0,0 +1,25 @@ +#!/usr/bin/env sh + +#set -x +# Description: Send the selected files to your Android device using gsconnect daemon.js. +# GSConnect must be configured on the Android device and the PC. +# +# Shell: POSIX compliant +# Author: Darukutsu + +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} +gsconnect=$HOME/.local/share/gnome-shell/extensions/gsconnect@andyholmes.github.io/service/daemon.js +id=$($gsconnect -l) + +if [ -s "$selection" ]; then + IFS=$'\n' + for file in $(cat -t $selection | sed "s/\^\@/\n/g"); do + $gsconnect -d "$id" --share-file="$file" + done +else + notify-send -a "GSConnect" "No files selected" +fi + # Clear selection + if [ -p "$NNN_PIPE" ]; then + printf "-" > "$NNN_PIPE" + fi From cd2445607be8c8a88d541d6a933facb057281afc Mon Sep 17 00:00:00 2001 From: Darukutsu Date: Tue, 22 Feb 2022 16:16:19 +0100 Subject: [PATCH 2/4] workaround with xargs -0 added hover over file to send --- plugins/gsconnect | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/plugins/gsconnect b/plugins/gsconnect index 38ebdb97..90c703b2 100755 --- a/plugins/gsconnect +++ b/plugins/gsconnect @@ -1,25 +1,19 @@ #!/usr/bin/env sh #set -x -# Description: Send the selected files to your Android device using gsconnect daemon.js. +# Description: Send the selected (or hovered) files to your Android device using gsconnect daemon.js. # GSConnect must be configured on the Android device and the PC. # # Shell: POSIX compliant # Author: Darukutsu - selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} gsconnect=$HOME/.local/share/gnome-shell/extensions/gsconnect@andyholmes.github.io/service/daemon.js id=$($gsconnect -l) if [ -s "$selection" ]; then - IFS=$'\n' - for file in $(cat -t $selection | sed "s/\^\@/\n/g"); do - $gsconnect -d "$id" --share-file="$file" - done -else - notify-send -a "GSConnect" "No files selected" -fi + xargs -0 -a $selection -i $gsconnect -d "$id" --share-file="{}" # Clear selection - if [ -p "$NNN_PIPE" ]; then - printf "-" > "$NNN_PIPE" - fi + printf "-" > "$NNN_PIPE" +else + $gsconnect -d "$id" --share-file="$(pwd)/$1" +fi From d1de515532b3e81eeb54cc94fae0faa92fc0d14f Mon Sep 17 00:00:00 2001 From: daru <54768193+Darukutsu@users.noreply.github.com> Date: Tue, 22 Feb 2022 17:02:02 +0100 Subject: [PATCH 3/4] Update plugins/gsconnect Co-authored-by: N-R-K <79544946+N-R-K@users.noreply.github.com> --- plugins/gsconnect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/gsconnect b/plugins/gsconnect index 90c703b2..1a481126 100755 --- a/plugins/gsconnect +++ b/plugins/gsconnect @@ -15,5 +15,5 @@ if [ -s "$selection" ]; then # Clear selection printf "-" > "$NNN_PIPE" else - $gsconnect -d "$id" --share-file="$(pwd)/$1" + "$gsconnect" -d "$id" --share-file="$2/$1" fi From 633a9ca8e1e1e7a445f6f1cd177bd3f0291f536e Mon Sep 17 00:00:00 2001 From: daru <54768193+Darukutsu@users.noreply.github.com> Date: Tue, 22 Feb 2022 17:04:43 +0100 Subject: [PATCH 4/4] Update plugins/gsconnect Co-authored-by: N-R-K <79544946+N-R-K@users.noreply.github.com> --- plugins/gsconnect | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/gsconnect b/plugins/gsconnect index 1a481126..1b71aaf1 100755 --- a/plugins/gsconnect +++ b/plugins/gsconnect @@ -11,7 +11,7 @@ gsconnect=$HOME/.local/share/gnome-shell/extensions/gsconnect@andyholmes.github. id=$($gsconnect -l) if [ -s "$selection" ]; then - xargs -0 -a $selection -i $gsconnect -d "$id" --share-file="{}" + xargs -0 < "$selection" -I{} "$gsconnect" -d "$id" --share-file="{}" # Clear selection printf "-" > "$NNN_PIPE" else