GitSquared / edex-ui

A cross-platform, customizable science fiction terminal emulator with advanced monitoring & touchscreen support.
GNU General Public License v3.0
40.35k stars 2.54k forks source link

WIP: Sketch using OSC sequences to interact with openFile and openMedia #1163

Closed pyrocto closed 2 years ago

pyrocto commented 2 years ago

In the discussion at https://github.com/GitSquared/edex-ui/discussions/973#discussioncomment-374497, @branislavblazek asked

can I open editor for .txt file by some command? I can open editor by clicking on file in filessytem explorer.

@Animus-Surge replied

It's very hard to add commands into the terminal (especially for windows) that works with eDEX, so unfortunately it is not possible to do the command.

This is an attempt to solve the problem using an OSC sequence. It is a work in progress, as I haven't bothered to do path resolution yet, but it illustrates the concept.

With this shell script:

printf '\e]1024;{"cmd":"openFile","path":"'
printf "$1"
printf '"}\a'

one can provide the full path to a file and open it. For instance, ./openFile "/Users/stay/Library/Application Support/eDEX-UI/settings.json" opens the json file in the built-in text editor.

pyrocto commented 2 years ago

Also at the moment, openMedia will display a media player for mp3s but won't play them. The pdf viewer works.

GitSquared commented 2 years ago

Interesting idea, so we could build & bundle in some kind of CLI tool that leverages those escape sequences to talk to the UI?

pyrocto commented 2 years ago

Yes, exactly.

pyrocto commented 2 years ago

This is, as I wrote, a sketch. If someone would like to contribute a PR to my fork that resolves relative paths properly and fixes the sound player issue, then it might be worth submitting. Another option is to close it without submitting.

GitSquared commented 2 years ago

Closing as I'm archiving the project (announcement).

Regardless, thanks for digging into this and sharing your prototype :pray: