nadrad / h-m-m

Hackers Mind Map
GNU General Public License v3.0
1.89k stars 53 forks source link

Support copy/paste/clipboard without display server #11

Closed d5ve closed 2 years ago

d5ve commented 2 years ago

h-m-m looks awesome thanks!

I playing around with it a few hours ago on macOS via the following Dockerfile and command.

FROM php:7.4-cli
RUN /usr/local/bin/docker-php-ext-install pcntl
WORKDIR /app
CMD [ "php", "./h-m-m" ]

Then running

$ docker build -t h-m-m .
$ docker run --rm -it -v $PWD:/app h-m-m

This worked pretty well, but I couldn't paste in stuff from the macOS system clipboard...

Then I saw an issue about the clipboard and a fix, so I ran git pull to get 265992fc4 and crossed my fingers.

After that I couldn't launch h-m-m at all, as the docker container doesn't have any X/display server running, so none of pbcopy/pbpaste/xclip/xsel/wl-copy are installed, or even installable.

I don't know if it's even possible, but could h-m-m also support copy/paste for systems not running displays at all? Like when sshing into a remote server? Or when running in a docker container as you're too lazy to install PHP locally?

nadrad commented 2 years ago

I'm glad you like it.

Before that commit, it would have run, but it couldn't go far because many of the functions use the clipboard and they run into problems without it.

I don't know much about how Docker works, but just searched for reading and writing content from Docker to the host clipboard, and it doesn't seem simple at all.

I can add something to the program to use a local file for reading and writing to instead of the clipboard when it doesn't have access to one. Then the program would run and work inside Docker, but you would have to find a way to connect that local file to your host clipboard.

jonas-w commented 2 years ago

Would this be suffice to you? https://github.com/nadrad/h-m-m/pull/15#issuecomment-1249876055

nadrad commented 2 years ago

So, the clipboard works inside the Docker, and the only issue is communicating with the host clipboard.

I'll close it for now, but if there's anyone willing to integrate the two clipboards, we can think about the solutions again, including the potential solution of using a local file as the proxy.

nadrad commented 2 years ago

a61e4ac may be helpful here.

d5ve commented 2 years ago

Sorry for the delay testing this. a61e4ac did work well for me thanks!

The following now reliably works for copy and paste under docker in a terminal on macOS.

$ git log -1 --oneline
80bf357 (HEAD -> main, origin/main, origin/HEAD) clearer explanation of the clipboard options

$ docker build -t h-m-m .

$ docker run --rm -it --env hmm_clipboard=file h-m-m

I can paste from the system clipboard when creating or editing nodes, plus can use d and p to copy and paste the nodes around.

Edit: I had mistyped --env hmm_clipboard=file as --env clipboard=file