• Recent
  • Tags
  • Popular
  • Home
  • Docs
  • Register
  • Login
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] How to bind a shell command to a hotkey? (raspi2png)

Scheduled Pinned Locked Moved Help and Support
hotkeyshortcutscreenshotraspi2png
59 Posts 6 Posters 11.6k 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.
  • M
    mitu Global Moderator @Clyde
    last edited by 24 Feb 2019, 08:40

    @Clyde Hm, I bet it's because it interprets the # as a comment start. Try this

    raspi2png --pngname "/home/pi/$(ps a | grep RetroPie/roms | awk -F "/" 'NR==1 { print $NF }' | sed 's/\.[^.]*$//g; s/\\//g')"-$(date +%Y.%m.%d-%H.%M.%S).png
    
    C 1 Reply Last reply 24 Feb 2019, 08:44 Reply Quote 0
    • R
      roslof @Clyde
      last edited by 24 Feb 2019, 08:40

      @Clyde sorry, man -- but it sounded like a sub-par solution to perms issues I was having. Since mitu advised not to follow the directions, I felt it best not to give that information to the public, in case they didn't get the warning.

      M 1 Reply Last reply 24 Feb 2019, 08:41 Reply Quote 0
      • M
        mitu Global Moderator @roslof
        last edited by 24 Feb 2019, 08:41

        @roslof It's ok to leave it - this way when someone googles for this advice will see that a reply with 'bad dog' has been added and think: "Hey, that's how you do it right".

        1 Reply Last reply Reply Quote 0
        • C
          Clyde @mitu
          last edited by Clyde 24 Feb 2019, 08:44

          @mitu That works! I'll update my solution with this and add a remark about @roslof's workaround in case someone wants to run a script instead of a single command. Thank you both!

          edit: Just when you posted your solution, I wanted to report that changing the length by removing the whitespaces before and after the pipes didn't change the point of cutting off the line. You were faster. 😉

          @roslof As @mitu said, it's better (and widely seen as more honest and polite) to leave it and maybe crossing it out and/or commenting below it that it has been wrong. Just a friendly advice. 😊

          R 1 Reply Last reply 24 Feb 2019, 08:47 Reply Quote 0
          • M
            mitu Global Moderator
            last edited by 24 Feb 2019, 08:46

            @roslof 's solution is also better when you just want to change something to the script command, since you don't need to re-start the thd service or edit the .conf file - any edits to the .sh file will take effect immediately.

            C 1 Reply Last reply 24 Feb 2019, 09:13 Reply Quote 0
            • R
              roslof @Clyde
              last edited by 24 Feb 2019, 08:47

              @Clyde Thanks man. Still new here.

              1 Reply Last reply Reply Quote 1
              • C
                Clyde @mitu
                last edited by 24 Feb 2019, 09:13

                @mitu The script version even relays the output of the script commands to triggerhappy's status output. I wasn't sure if it would do that. But I will keep it as optional for my solution post, because it adds more complexity, and one command should be enough for most people.

                @roslof You're welcome! Besides, in some cases can deletion be advisable, like in this thread from me where @meleu's solution made my own completely obsolete (and wrong for many reasons). But I still added a remark about it original content. 😇

                1 Reply Last reply Reply Quote 0
                • C
                  Clyde
                  last edited by Clyde 24 Feb 2019, 09:21

                  @roslof One question about your script variant: Is there a reason that you're using nohup and 0<&- &>/dev/null &? I'm asking out of curiosity and simplicity, because it seems to work as well if I just invoke the script by path and name, as do some triggerhappy guides I found online.

                  And since I linked to your solution in mine, could you please add a remark that the script has to be made executable? (In my example for the owner "pi", or for "others" if the owner is root, since my solution configures triggerhappy to run as that user.)

                  R 1 Reply Last reply 24 Feb 2019, 12:27 Reply Quote 0
                  • R
                    roslof @Clyde
                    last edited by roslof 24 Feb 2019, 12:27

                    @Clyde As requested, I added a note in my previous post about setting the executable permission.

                    Also, you're absolutely right about my use of nohup. It's not necessary for such a simple/quick script. nohup ensures the process doesn't stop until it's done. Overkill for the near-instant execution of the script. Again, my newbie-ness is shining through.

                    Regardless -- Cool write-up on nohup, its uses, and why output needs to be considered for other, longer tasks:
                    https://www.maketecheasier.com/nohup-and-uses/

                    I revised my post with the simple path/script and included an edit note with my original nohup line for reference...
                    Cheers

                    C 1 Reply Last reply 24 Feb 2019, 14:52 Reply Quote 1
                    • C
                      Clyde @roslof
                      last edited by 24 Feb 2019, 14:52

                      @roslof Perfect, thanks!

                      1 Reply Last reply Reply Quote 0
                      • C
                        cyperghost @Lolonois
                        last edited by 24 Feb 2019, 17:30

                        @Lolonois said in [Solved] How to bind a shell command to a hotkey? (raspi2png):

                        @hermit triggerhappy is not related to retropie. AFAIK %ROM% or $ROM is not available from the environment. However, to get the rom file name you may start with

                        basename `ps a | grep RetroPie/roms | head -1 | awk '{ print $NF }'`
                        

                        Without a physical keyboard attached the tool jslisten may be an option.

                        This is definitly the master path for such purpose. Why it gets so less attention?
                        Together with the jslisten tool we can call any script and manipulate filenames (because we aren't restricted to one liners) ;)

                        Thx @Lolonois for this nice suggestion ;)

                        @mitu @Clyde
                        The triggerhappy solution is also nice but imho the joypad usecase is a real fine way to coop with.

                        Btw: You can always use GPIO inputs to call commands

                        C 1 Reply Last reply 24 Feb 2019, 17:33 Reply Quote 0
                        • C
                          Clyde @cyperghost
                          last edited by 24 Feb 2019, 17:33

                          @cyperghost said in [Solved] How to bind a shell command to a hotkey? (raspi2png):

                          Btw: You can always use GPIO inputs to call commands

                          If you're not like me and prefer USB connections. ;) (because, I don't know, lazyness?)

                          C 1 Reply Last reply 24 Feb 2019, 17:35 Reply Quote 1
                          • C
                            cyperghost @Clyde
                            last edited by cyperghost 24 Feb 2019, 17:35

                            @Clyde Well ... I think it's not lazyness. I think with this Breadboard unit on Amazon.de there is no space for any excuse ;)
                            So you develop your scripts and connections on this board and just take them over to your RetroPie ;)

                            C 1 Reply Last reply 24 Feb 2019, 18:11 Reply Quote 0
                            • C
                              Clyde @cyperghost
                              last edited by 24 Feb 2019, 18:11

                              @cyperghost If I compare this to a ready-to-use usb device like a keyboard or game controller, I think I can still plead lazyness with a clear concience. ;)

                              C 1 Reply Last reply 24 Feb 2019, 18:50 Reply Quote 0
                              • C
                                cyperghost @Clyde
                                last edited by 24 Feb 2019, 18:50

                                @Clyde Now we are getting closer why I entered this thread ;)

                                If I compare this to a ready-to-use usb device like a keyboard or game controller

                                So does triggerhappy work out of the box with joypads? If yes then this would be a real cool deal ;)

                                Maybe I will post a thread of annother solution that's only script based ;) Stay tuned ;)

                                M 1 Reply Last reply 24 Feb 2019, 18:55 Reply Quote 0
                                • M
                                  mitu Global Moderator @cyperghost
                                  last edited by 24 Feb 2019, 18:55

                                  @cyperghost said in [Solved] How to bind a shell command to a hotkey? (raspi2png):

                                  So does triggerhappy work out of the box with joypads?

                                  If it's reading the events correctly from /dev/input/eventX, I see why not. You can verify like @clyde did via thd --dump /dev/input/*. Looking at the supported event types (thd --listevents), I think it should work.

                                  C 1 Reply Last reply 24 Feb 2019, 19:02 Reply Quote 1
                                  • C
                                    cyperghost @mitu
                                    last edited by cyperghost 24 Feb 2019, 19:02

                                    @mitu Yes I'm reading the github content now. Sounds feasible for me to get this work with js0 as input source. Even one issue on github explainded that there were inputs of buttons detectable.

                                    But I'm also in annother doc for retropie: Take and Scrape Your Own Screenshots. There it is explained

                                    1. How to setup the screenshot function with button
                                    2. How to retrieve Screenshot name from ROM name
                                    3. How to store them per system

                                    The only minus point of the raspi2png internal retroarch solution is... this will work (of course) only in lr- core emulatores ;) Or did I misunderstood the whole thread?

                                    M 1 Reply Last reply 24 Feb 2019, 19:27 Reply Quote 0
                                    • H
                                      hermit
                                      last edited by hermit 24 Feb 2019, 19:25

                                      Rapi2png , I think it works with any emulator.
                                      I used it with uae4arm which is not Libretro

                                      1 Reply Last reply Reply Quote 0
                                      • M
                                        mitu Global Moderator @cyperghost
                                        last edited by 24 Feb 2019, 19:27

                                        @cyperghost It works with any emulator, since it screenshots the framebuffer. What you should - actually - do is make it work on the 'Droid (i.e. find a raspi2png substitute).

                                        C 1 Reply Last reply 24 Feb 2019, 19:30 Reply Quote 0
                                        • C
                                          cyperghost @mitu
                                          last edited by cyperghost 24 Feb 2019, 19:30

                                          @mitu said in [Solved] How to bind a shell command to a hotkey? (raspi2png):

                                          @cyperghost It works with any emulator, since it screenshots the framebuffer. What you should - actually - do is make it work on the 'Droid (i.e. find a raspi2png substitute).

                                          Yes... I ment that the retroarch internal solution will only work on lr-cores

                                          @hermit @mitu
                                          Corrected previous posting

                                          But I think the internal screenshot modul of retroarch should not be underestimated, too ;)

                                          M 1 Reply Last reply 24 Feb 2019, 19:36 Reply Quote 0
                                          56 out of 59
                                          • First post
                                            56/59
                                            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.

                                            This community forum collects and processes your personal information.
                                            consent.not_received