We have moved to a new Sailfish OS Forum. Please start new discussions there.
20

[Question] How to access clipboard from the command line?

asked 2014-01-19 19:42:04 +0300

nodevel gravatar image

updated 2014-01-19 19:43:35 +0300

Is there any way to access the clipboard through the command line? It would be quite useful as one could retrieve/edit it for example through SSH.

I couldn't find any xclip alternative on Wayland and I'm not even sure if Jolla uses any standard clipboard management.

PS: Before someone decides to close this question as a duplicate of 'Fingerterm cannot access system clipboard': read the whole text :)

edit retag flag offensive close delete

Comments

I don't think you can.. but it seems rather easy to make an app for it.. No hate, just saying.

attah ( 2014-01-19 21:49:22 +0300 )edit

Is the clipboard still inaccessible from the command line?

kat6 ( 2016-08-28 09:07:42 +0300 )edit

4 Answers

Sort by » oldest newest most voted
3

answered 2014-04-21 03:39:10 +0300

mornfall gravatar image

There's an awkward workaround, involving sqlite and the notes app. It goes like this (substitute your own hash for the sqlite file, there only seems to be one in that directory, but probably different on each device):

$ ssh jolla
$ sqlite3 .local/share/jolla-notes/QML/OfflineStorage/Databases/8b63c31a7656301b3f7bcbbfef8a2b6f.sqlite
sqlite> insert into notes (body) values ("blabla");
sqlite> .quit

then open the notes app, you should see a new note with "blabla" in it -- open it, select the text, copy to clipboard...

uh oh!

edit flag offensive delete publish link more

Comments

Just to clarify - hash is always the same, because it's derived from database name, not something based on specific device.

koudi ( 2014-04-21 11:36:12 +0300 )edit
2

$ xdg-open http://blablablabla

Your web browser is now open, select your text in the URL, copy to clipboard...

uh oh!

But that's not the point, xclip is really usefull with command line, all we need is the possibility to read/create clipboard content from command line.

Bnurb ( 2014-04-21 12:45:42 +0300 )edit

It might be a good idea to use a statement like:

INSERT INTO notes (pagenr, body) SELECT MAX(pagenr)+1, "blabla" FROM notes;

Otherwise the notes app will get confused and unable to differentiate between any entries created in this way, and possible cause unintentional data loss if trying to edit or remove any of them.

sampi ( 2019-03-04 13:23:18 +0300 )edit
2

answered 2018-03-20 22:11:18 +0300

tauko gravatar image

There is the (sadly unmaintained, but still working) pbcopy in Openrepos.

Also, it seems to only support setting the clipboard from the command line, not reading it.

edit flag offensive delete publish link more
0

answered 2014-11-22 15:02:30 +0300

Robin gravatar image

updated 2014-11-22 15:43:02 +0300

I'm looking for an answer too, but I can offer a clue to a possible answer. On the Nokia N9, there wasn't xclip, but I could access the clipboard through Python and PySide, and the code looks like:

#!/usr/bin/env python
from PySide.QtGui import QApplication
import sys
QApplication(sys.argv) 
clipboard = QApplication.clipboard()
print clipboard.text()

There isn't any information about PySide for Sailfish. The only choices are pyotherside and pyqt which I have little/no experience with. pyotherside sounds like it needs to launch a GUI and trying to install pyqt spits out:

[root@Jolla nemo]# pkcon install pyqt

Fatal error: nothing provides libQt5MultimediaWidgets.so.5 needed by python-pyqt-5.1.1-1.armv7hl

So If anyone can get that script working on Jolla, then you may got the answer.

edit flag offensive delete publish link more

Comments

I force installed pyqt ignoring that error and I run the following script:

#!/usr/bin/env python
from PyQt5.QtWidgets import QApplication
import sys

app=QApplication(sys.argv)  # Maybe a blank list will do instead of argv?
clipboard = QApplication.clipboard()
#clipboard.setText('coppyy')
print clipboard.text()

Not working. Maybe it is related to https://together.jolla.com/question/832/system-wide-clipboard-copy-paste-capability/

Robin ( 2014-11-22 16:08:06 +0300 )edit

I don't think it is related. PyQt seems like a bit of an overkill... I had in mind a direct access from the command line, but if we are talking access through Qt, then this looks like the most likely solution. I am still a C++ beginner, though.

nodevel ( 2014-11-23 23:29:00 +0300 )edit

Maybe I haven't killed enough just to be able to access the clipboard through the command line.

Robin ( 2014-11-25 12:12:10 +0300 )edit
0

answered 2018-11-22 23:51:04 +0300

adabru gravatar image

You could try using bugaevc's wl-clipboard copy/paste utilities. I don't have a sailfish-system to test on, though.

edit flag offensive delete publish link more
Login/Signup to Answer

Question tools

Follow
10 followers

Stats

Asked: 2014-01-19 19:42:04 +0300

Seen: 1,897 times

Last updated: Nov 22 '18