Notices


Reply
Thread Tools
Posts: 49 | Thanked: 39 times | Joined on May 2011
#1
Dear Maemo Community,

Disclaimer:
I'd like to share an achivement of mine. It has been born out of the struggle to make my (computer-)life easier. Unfortunately, it is just a quick and dirty proof of concept, not a final application. I can't guarantee that you don't mess up your system while trying to implement this. Please try to understand every command before you hack it into your machines!
The "system" requirements are quite hight too. Take everything I drop here and feel free to improve it. Please also take a look at the explanaitions at the end of the post for a little more clarification if you're confused.

Motivation:

If you ever had the desire to share clipboard contents amog your (linux)devices, this is for you. Ctrl(+Shift)+C something on your desktop, paste it on your N900 via a desktop widget. Or paste it on your Notebook via Ctrl(+Shift)+V.
That's the idea.

Use:
A use case before we start with setting it all up: You stumble upon an interesting website while browsing the web. You would like to have the information from that website on your N900 but the URL is complicated and long. Too long to copy it by typing it in.
So you copy the address from the URL bar to your clipboard via Ctrl+C. Immediately after that you press Ctrl+Shift+C to save it to your Universal Clipboard.
Now on your N900, you tap on your desktop widget that says "get from U.C.", proceed to open MicroB and past it via Ctrl+V into your URL bar. Easy, wasn't it?

Requirements:
Now, this is the sad part. It works for me this way but it would be possible to do it all much "cheaper", of course.
You need:
  • KDE with custom keyboard shortcuts (for doing Strg(+Shift)+C )
  • Desktop Command Execution Widget on your N900
  • A web server running Mediawiki with ssh access
  • EasyDebian to install xclip
Of course, you could do without mediawiki and instead just have ssh access or even ftp access to a server. Or use your N900 as ssh server. But this is not how I did it. Mediawiki has some additional benefits!

Implementation:
Make sure you are running at least Mediawiki 1.6, otherwise you would have to manually backport getText.php.
Start a new Mediawiki article on your server and call it UniversalClipboard.

On your N900, create the following script in /usr/local/bin/clip2wiki/wiki2uniclip/uniclip2wiki:
Code:
#!/bin/bash
/sbin/route | grep -q \* || dbus-send --system --type=method_call --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:"[ANY]" uint32:0 ; sleep 6
/sbin/route | grep -q \* || exit 1
( ssh USER@SERVER php /usr/share/mediawiki/maintenance/getText.php "UniversalClipboard" ) | debbie xclip -in -selection clipboard 
#mplayer /usr/local/bin/clip2wiki/ding.wav
additionally, create /usr/local/bin/clip2wiki/wiki2uniclip/wiki2uniclip:
Code:
#!/bin/bash
/sbin/route | grep -q \* || dbus-send --system --type=method_call --dest=com.nokia.icd /com/nokia/icd com.nokia.icd.connect string:"[ANY]" uint32:0 ; sleep 6
/sbin/route | grep -q \* || exit 1
(debbie xclip -out -selection clipboard) | ssh USER@SERVER php /usr/share/mediawiki/maintenance/edit.php -s "Autoedit" -m "UniversalClipboard"
#mplayer /usr/local/bin/clip2wiki/ding.wav
Add a meaningful Desktop Command Execution Widge executing the following code:
Code:
nohup /usr/local/bin/clip2wiki/wiki2uniclip > /dev/null 2>/dev/null &
Do the same for the other command (uniclip2wiki)

On your Linux Desktop/Notebook, add the following scripts:
/usr/local/bin/clip2wiki/wiki2uniclip
Code:
#!/bin/bash
/sbin/route | grep -q \\* || echo "no net" && ( ssh USER@SERVER php /usr/share/mediawiki/maintenance/getText.php "UniversalClipboard" ) | xclip -in -selection clipboard
#mplayer ding.wav
echo done
and /usr/local/bin/clip2wiki/uniclip2wiki
Code:
#!/bin/bash
/sbin/route | grep -q \\* || echo "no net" && (xclip -out -selection clipboard) | ssh USER@SERVER php /usr/share/mediawiki/maintenance/edit.php -s "Autoedit" -m "UniversalClipboard" 
#mplayer ding.wav
then, open KDE systemsettings / Custom Shortcuts and create a shortcut for Ctrl+Shift+C which executes:
Code:
kdialog --msgbox $(/usr/local/bin/clip2wiki/uniclip2wiki)
and for Ctrl+Shift+V which executes:
Code:
/usr/local/bin/clip2wiki/wiki2uniclip; kdialog --msgbox done
and you are done with setting up


Explanations:

Copying works by reading the clipboard on one machine and pasting it over ssh and php into a wiki software (Mediawiki).
Pasting works the opposit way, reading the wiki software via php and a ssh login and writing the contents to the clipboard.

ssh is a way of logging in to another computer and executing programs there.
Mediawiki is the php-Server-Software that drives Wikipedia. The benefits of using Mediawiki over e.g. a simple text file on a FTP server are: You get a full history of your clipboard-shares via the "history" button. You would neet a Webserver (or a homeserver) to run it. I can't go into details about configuring it here, but Google may help. Be warned, that running such a server securely is not easy and misconfigured webservers are frequently attacked.
KDE is a Qt-based Desktop Environment that runs on Unix-like Operating Systems. I prefer it over Gnome. Of course, you could get shortcuts like the ones I used in many different ways on Linux.
xclip is used to manipulate the contents of the computer's clipboard
EasyDebian: Easy way of running a full Debian Environment on your N900, used to run xclip - I had to clean up all the "debbie" scripts to not get a messed up clipboard, since these are quite verbose about what they are doing.
Desktop Command Execution Widget: Greatest software for Maemo there is

I am really amazed how easy this was to pull off, given that I am not a developer. There's no other smartphone OS that would have allowed me to do this this quickly (without digging into APIs). I'd like to thank everybody who was involved in developing and sharing the wonderful software I used here (which is a lot of software, if you think about it).

I'd like to hear your thoughts!

Last edited by lohner; 2012-04-28 at 03:43. Reason: many typos
 

The Following 10 Users Say Thank You to lohner For This Useful Post:
qwazix's Avatar
Moderator | Posts: 2,622 | Thanked: 5,447 times | Joined on Jan 2010
#2
Sorry for the party-spoiling but I think it's much easier to use synergy for tthat job. With the bonus that you can use the pc's keyboard on the N900
__________________
Proud coding competition 2012 winner: ρcam
My other apps: speedcrunch N9 N900 Jolla –– contactlaunch –– timenow

Nemo UX blog: Grog
My website: qwazix.com
My job: oob
 

The Following 4 Users Say Thank You to qwazix For This Useful Post:
Posts: 49 | Thanked: 39 times | Joined on May 2011
#3
whoa, didn't know that existed. looks quite promising. thanks!
 
Posts: 49 | Thanked: 39 times | Joined on May 2011
#4
here's a guide to synergy on the N900:
http://talk.maemo.org/showthread.php?p=1137989

The only benefit of my solution would be that you don't have to open a port on your clients and need no software running in the background. You would need ssh tunneling to have synergy traffic encrypted properly. Plus when using mediawiki, you can access your clipboard form anywhere in the web.

Still synergy is great and I'll be using it!
 

The Following 2 Users Say Thank You to lohner For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 14:38.