sindresorhus/clipboardy

Android support

Closed this issue · 8 comments

Hello,

I am using Nodejs on Termux, a CLI environment for Android.
Currently clipboardy does not work because I don't have xsel. (And I can't build xsel because X11 is not available in Termux.)
However, Termux provides termux-clipboard-get and termux-clipboard-set commands which use Android's clipboard API.

Do you think it would possible to add support for these commands in clipboardy?

@rudolf can we detect it by process.platform?

You can detect Android (process.platform == 'android') but you can't be sure that Termux is installed.

So there is no standard way of manipulating the clipboard? The termux thing is preinstalled on some type of devices or how does that thing work?

There no way to manipulate the Android clipboard from CLI without installing some third-party app.
Termux is an app that you install (from Play Store or F-Droid). It is one the most popular Android CLI environments but it is not the only one.

Not sure if @sindresorhus is interested to support this in Android. But if there is a flag in process.env or something that could give us an indication of the terminal type, this should be perfectly possible. If the terminal is not Termux we could just throw an error.

You can probably check process.env.PREFIX == '/data/data/com.termux/files/usr'.

@Rudloff I'm open to it if you can commit to maintain this part of the code. What does process.env.TERM_PROGRAM give you?

Unfortunately, process.env.TERM_PROGRAM is undefined.
Yes, I can maintain it as I will use it myself.
I will submit a PR for this.