[Solved] Good cli text reader?
-
Hi, does anyone know a commandline text reader which can be navigated using a pad?
I've set up a new system called docs for txt files but I don't know a good way to actually read them.
I tried more and less, the programs that is.
But more just ends at the end of a file, which means with short texts, EmulationStation basically pops right back up.
And less does not use the mapped keys. So it can't be closed with a controller.So, I'm looking for an alternative before I went on and write a script as workaround.
Edit: Solution here: https://retropie.org.uk/forum/topic/33037/good-cli-text-reader/7?_=1659071335138
-
[edit:
dialog --msgbox
does scroll, so for example something like this will probably work:dialog --no-collapse --msgbox "$(cat "$file")" 22 86
This will display "
$file
" in a window 22x86 (minus 4x4 for borders) characters in dimension, scrollable, with an "ok" button, and operable under defaultjoy2key
mapping:Here's how it looks on my screen.]
You use q to exit
less
. You could use a custom mapping injoy2key
(I think it's 0x51), like RP does indocsview.sh
forpandoc | lynx
:joy2keyStop joy2keyStart 0x00 0x00 kich1 kdch1 0x20 0x71 pandoc "$dir/docs/$file" | lynx -localhost -restrictions=all -stdin >/dev/tty joy2keyStop joy2keyStart
Stop it, start it with your custom mapping, run your function, stop it, and restart it with default.
Or maybe you could rig something up with
dialog --msgbox
: -
@sleve_mcdichael Thanks for the suggestion. I'm not really digging the dialog method, it is probably to much wasted space, especially on a handheld screen.
And I'm not really in the mood to write another script just for plain text files. I think this should be implemented in retropie. But I guess I have to look at using joy2key for this then.
Edit: I just tried the dialog msgbox method, because it was easy to set up. I just put your command in the es_systems file and replaced $file with %rom%. It semi works. It works for some files but not for others. And currently I'm to lazy to test if the files I mainly want to read are to big or contain characters that break the dialog. Too bad.
Edit2: I tried to replace dialog with whiptail, which can handle the files but can't, for whatever reason, be controlled with a pad. :(
whiptail --clear --scrolltext --msgbox "$(cat "%ROM%")" $(stty size)
-
Um, so how exactly do I activate joy2key? I thought just adding joy2keyStart/joy2keyStop to my script would work.
#!/bin/bash joy2keyStart whiptail --clear --scrolltext --msgbox "$(cat "$1")" $(stty size) joy2keyStop
But it does not. Do I somehow need to source one of retropies script to be able to use this function?
-
@EctoOne try:
/opt/retropie/admin/joy2key/joy2key start
-
@sleve_mcdichael yay, that did it. I was getting an permission error at first but i just had to chmod +x my script.
Now I just need to adapt my Super Metroid Randomizer script to put the solution files in the docs folder and whenever I'm stuck I can just look at it without using ssh or something like that. :)
Thanks.
-
I tinkered around a bit more and got rid of the extra script by moving the commands completly in the es_systems file. Here is the full entry, if anybody wants to add it themself. Just don't forget to create the docs directory in the roms folder. Also remember, that this is probably not well supported by themes.
<system> <name>docs</name> <fullname>Documents</fullname> <path>/home/pi/RetroPie/roms/docs</path> <extension>.txt .TXT</extension> <command>/opt/retropie/admin/joy2key/joy2key start; whiptail --clear --scrolltext --msgbox "$(cat "%ROM%")" $(stty size); /opt/retropie/admin/joy2key/joy2key stop</command> <theme>docs</theme> </system>
-
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.