RetroPie forum home
    • Recent
    • Tags
    • Popular
    • Home
    • Docs
    • Register
    • Login
    Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

    [Solved] Good cli text reader?

    Scheduled Pinned Locked Moved Help and Support
    scripttextcli
    7 Posts 2 Posters 1.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      EctoOne
      last edited by EctoOne

      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

      1 Reply Last reply Reply Quote 0
      • S
        sleve_mcdichael
        last edited by sleve_mcdichael

        [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 default joy2key mapping:

        20220726_141531.png

        Here's how it looks on my screen.]


        You use q to exit less. You could use a custom mapping in joy2key (I think it's 0x51), like RP does in docsview.sh for pandoc | lynx:

        joy2keyStop
        joy2keyStart 0x00 0x00 kich1 kdch1 0x20 0x71
        pandoc "$dir/docs/$file" | lynx -localhost -restrictions=all -stdin >/dev/tty
        joy2keyStop
        joy2keyStart
        

        https://github.com/RetroPie/RetroPie-Setup/blob/2431ec886f042b55812bf9d2f81b60b6a0ffede1/scriptmodules/supplementary/docsview.sh#L42-L46

        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:

        https://linux.die.net/man/1/dialog

        E 1 Reply Last reply Reply Quote 0
        • E
          EctoOne @sleve_mcdichael
          last edited by EctoOne

          @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)
          
          1 Reply Last reply Reply Quote 0
          • E
            EctoOne
            last edited by

            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?

            S 1 Reply Last reply Reply Quote 0
            • S
              sleve_mcdichael @EctoOne
              last edited by

              @EctoOne try:

              /opt/retropie/admin/joy2key/joy2key start
              
              E 1 Reply Last reply Reply Quote 1
              • E
                EctoOne @sleve_mcdichael
                last edited by

                @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.

                1 Reply Last reply Reply Quote 1
                • E
                  EctoOne
                  last edited by

                  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>
                  
                  1 Reply Last reply Reply Quote 0
                  • IanDaemonI IanDaemon referenced this topic on
                  • First post
                    Last post

                  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.