]> Sergey Matveev's repositories - nnn.git/commitdiff
Allow gsconnect to handle multiple devices
authorJingMatrix <jingmatrix@gmail.com>
Sat, 9 Apr 2022 09:42:31 +0000 (11:42 +0200)
committerJingMatrix <jingmatrix@gmail.com>
Sat, 9 Apr 2022 09:42:31 +0000 (11:42 +0200)
When gsconnect is connected to multiple devices, the original
script won't work. Now the code will share files to all devices.

plugins/gsconnect

index 1b71aaf1da679646aee11cae6c3c1ea80a2032fd..f45f3d35356bc059dcfa4386dece214d38b99893 100755 (executable)
@@ -8,12 +8,14 @@
 # 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)
+ids=$($gsconnect -l)
 
-if [ -s "$selection" ]; then
-    xargs -0 < "$selection" -I{} "$gsconnect" -d "$id" --share-file="{}"
-    # Clear selection
-    printf "-" > "$NNN_PIPE"
-else
-    "$gsconnect" -d "$id" --share-file="$2/$1"
-fi
+for id in $ids; do
+       if [ -s "$selection" ]; then
+               xargs -0 < "$selection" -I{} "$gsconnect" -d "$id" --share-file="{}"
+               # Clear selection
+               printf "-" > "$NNN_PIPE"
+       else
+               "$gsconnect" -d "$id" --share-file="$2/$1"
+       fi
+done