05-06-2021, 10:29 PM
Before I got my PinePhone I thought I could just run Barrier on both devices and it would be awesome, but no go. I could not get the devices to find each other.
So I tried KDE Connect and It lacked the all important clipboard sharing functionality .
I decided that being able to share the clipboard would make the lack of desktop-sharing much more tolerable.
Sidenote: I connect to my phone (ssh) on one of 3 networks USB, Wifi or WifiHotspot so I have a script, SetHostRoute.sh, to find which network the phone is connected.
Here is my clipboard sharing script:
PasteToMobian.sh
This script finds my phone on one of the 3 networks and writes the hostname to a temp file (It runs at startup or I re-run it if I switch networks):
SetRouteToMobian.sh
It all works just fine but I'm curious if there is a better way to do this
I'm also curious to see if clipboard sharing on the pinephone exists in some other form.
If anyone is interested I'll post the script for doing the reverse and copying from Pinephone's clipboard.
Cheers!
So I tried KDE Connect and It lacked the all important clipboard sharing functionality .
I decided that being able to share the clipboard would make the lack of desktop-sharing much more tolerable.
Sidenote: I connect to my phone (ssh) on one of 3 networks USB, Wifi or WifiHotspot so I have a script, SetHostRoute.sh, to find which network the phone is connected.
Here is my clipboard sharing script:
PasteToMobian.sh
Code:
#!/bin/bash
tempFile=/tmp/tempHost.txt
# Uncomment to set ssh hostname manually
# echo "ssh_hostname_here" > $tempFile
# Check if the temp file created by SetHostRoute.sh exists.
if [ -f "$tempFile" ]; then
# Set tempFile contents as $hostRoute
hostRoute=$(</tmp/tempHost.txt)
# Make sure SetHostRoute.sh found mobian (via usb||wifi||hotspot)
if [ $hostRoute != "notset" ]; then
# Get the clipboard
clipb="`xclip -o -sel clip`"
# Unify file path formats (file vs. file path)
clipc=${clipb/file:\/\//}
# Check if clipboard contents are a file (or a path), if so scp the file to the mobian's home directory
if [ -f "$clipc" ]; then
scp "$clipc" $hostRoute:/home/mobian/
notify-send Clipboard2Mobian "$clipc
Copied via $hostRoute"
else
# Clipboard contents are not a file, so.. Treat as text and copy to Mobian's clipboard (using a temp file to preserve all special characters)
echo "$clipb" > ~/.clipSync.txt
ssh $hostRoute wl-copy -n < ~/.clipSync.txt &
rm ~/.clipSync.txt
notify-send Clipboard2Mobian "Text Copied via
$hostRoute"
fi
else
# SetHostRoute.sh didn't find an ssh route and printed "notset" to the tempfile.
notify-send Clipboard2Mobian "No Route to Mobian..."
fi
else
# SetHostRoute.sh has yet to execute (ie. no tempFile) so.. Run it and then re-run this script.
notify-send Clipboard2Mobian "No Route to Mobian..."
/home/mj/Scripts/SetHostRoute.sh &&
sleep 5s
/home/mj/Scripts/xClipboard/PasteToMobian.sh
fi
This script finds my phone on one of the 3 networks and writes the hostname to a temp file (It runs at startup or I re-run it if I switch networks):
SetRouteToMobian.sh
Code:
#!/bin/bash
notify-send Clipboard2Mobian "Finding a Route to Mobian..."
hostRoute="notset"
echo $hostRoute > /tmp/tempHost.txt
ping -q -c 1 10.66.0.1 > /dev/null
if [ $? -eq 0 ]; then
hostRoute="mobianusb"
echo $hostRoute > /tmp/tempHost.txt
notify-send Clipboard2Mobian "$hostRoute Route Set!"
else
ping -q -c 1 192.168.3.108 > /dev/null
if [ $? -eq 0 ]; then
hostRoute="mobianwifi"
echo $hostRoute > /tmp/tempHost.txt
notify-send Clipboard2Mobian "$hostRoute Route Set!"
else
ping -q -c 1 10.42.0.1 > /dev/null
if [ $? -eq 0 ]; then
hostRoute="mobianhotspot"
echo $hostRoute > /tmp/tempHost.txt
notify-send Clipboard2Mobian "$hostRoute Route Set!"
else
notify-send Clipboard2Mobian "...No Route To Mobian"
fi
fi
fi
I'm also curious to see if clipboard sharing on the pinephone exists in some other form.
If anyone is interested I'll post the script for doing the reverse and copying from Pinephone's clipboard.
Cheers!