shell scripting topic
-
@lilbud
Bash? School computer?Code on your Pie!
All you need is a SSH terminal andnano
as editorSo you I would do the following.
- You write a selection menu that provides a layout for selected system and save it to config
- You write an "enabler" that sets overlay according to choosen system
;)
-
@cyperghost I don't have access to my pi in school, besides, the schools network is locked to any device that isn't a school issued computer.
-
@cyperghost said in shell scripting topic:
For graphics menu layout you can use this
I'm afraid that a scriptmodule isn't a good example for starters ;-)
@lilbud said in shell scripting topic:
Anything else needing further explanation?
Yes, post your code in ghostbin or something so we can give more effective guidance.
-
@meleu I'll have to redo it today, I'll post a link later.
-
@meleu Yes but for the sake of coding style
choice=$(dialog --command1 --command2 --menulist \ 1 Option 1 \ 2 Option 2 \ redirection to ....)
is better coded in this script menu example ;)
dialogcmd=(dialog --command1 --command2 --menu) dialogoptions=("1" "Option 1" "2" "Option 2") choice=$("${dialogcmd[@]}" "${dialogoptions[@]}" redirection to)
And it will be much easier for bug hunting. Because structur here is clear. And this was my intention to bring this script module into game.
dialogcmd sets the structure of how the menu will looks like as array
dialogoptions is the data array for selection
and now with choice you put cmd and options together.And I think this is a good example of clean coding ;)
Of course @lilbud will choose his own flavour later -
@meleu @cyperghost Here is my plan for the script: https://ghostbin.com/paste/6bbsa
not much in the way of code since I don't have a way to write/test it on my school computer.
-
Hi there!
I've created my first shell script and I'd like your opinion, codewise.
It's a script to install some extras for RetroPie themes (icons, splashscreens and launching images).The code is here: https://github.com/hiulit/es-theme-extras/blob/master/es-theme-extras.sh
I've created a post on this forum https://retropie.org.uk/forum/topic/13344/extras-for-retropie-themes-icons-splashscreens-and-launching-images-es_theme_extras-shell-script You can check it out to see more details.
Thanks! :)
-
@hiulit I saw that post. That's a pretty cool idea. I'm just a little busy with RL stuff, but I'll take a look at that soon. ;-)
-
@meleu I'm glad you think it's a good idea! :D I think so too, but it would need every theme creator to get involved. We'll see if more people find it useful.
-
@hiulit Welcome on board ;)
-
@cyperghost Thanks! :)
-
Just to continue this discussion. The kill run command program portion of shutdown script no longer works with retroarch in the most latest update from yesterday. Raspian files updated as well. It works with kodi. I have no other apps other than retroarch or kodi to test on. But this happened on 2 pi’s of mine so it last not a config i messes up.
So in essence. If in ES, shuts down fine. If in kodi, it exits to ES and then shuts down. If in retroarch, it just shuts down without saving meta data. Using the kill portion as a exit button. Nothing happens in retroarch, but kodi does exit.
-
Hi guys, this is only a hypothetical question. Is it possible to reset the order of the joysticks on the raspberry pi from the command line without rebooting.
As far as I know udev takes care of the js ordering. Yet emulators like Daphne only uses js0.
So can it be done where the script takes a snapshot of the udev js order, then asks you which usb device to use, then organise the list to have your desired device use the js0 slot and disable the rest. Then on the emulator exit return the udev js order to what it was.
-
@FlashPC You don't need to reboot to change the
js*
order. I think that changing the plugs is enough.I don't know any way to set a joystick to be the js0 "on-the-fly" (keeping all of them connected). I've read something about using udev rules to set a specific controller to be the js0, but I'm afraid it isn't possible to change it on-the-fly.
By the way, I've wrote a script to let the user choose which controller to use for RetroArch players 1-4, but it works only for RetroArch emulators/cores.
-
@meleu the retroarch joystick selector is sweet, and it works great with the retroarch cores.
I did read somewhere that it might be possible to kill the udev process, and change the udev rules but that was using red hat linux I think....
-
@cyperghost let's bring this to our nerdy thread :-)
@cyperghost said in Hide systems/consoles and only show "all games" section:
@EctoOne you're right. Using that symbolic link approach and removing the unwanted systems from
es_systems.cfg
would work too (I think).Hmmm.... Are you sure? Where are the runcommand calls stored? Or do you create them by your custom control script?
The script I made to launch the emulator detects the system in ROM's path. The script is quite small, then I'm pasting it here:
#!/usr/bin/env bash # runcustom.sh # testing if it's a symbolic link if [[ ! -L "$1" ]]; then dialog --msgbox "ERROR: \"$1\" is not a symbolic link." 0 0 exit 1 fi # getting the name of the file that the symbolic link points to rom="$(readlink "$1")" # getting the system based on the folder the rom is stored system="$(echo "$rom" | sed 's|\(.*/RetroPie/roms/[^/]*\).*|\1|' | xargs basename)" # now launch runcommand normally /opt/retropie/supplementary/runcommand/runcommand.sh 0 _SYS_ "$system" "$rom"
More details in the original post: https://retropie.org.uk/forum/topic/10849/create-a-custom-es-system-able-to-launch-games-for-many-systems
-
@meleu Yes, last line is the call command like es_systems.cfg
I'm not aware of the linking method but this should work in 99% of all time.
The method I used is to extract the whole command calls of es_systems in one file.But both methods are hacks.... So your suggestions is really the best - use the all systems method. Maybe if the kios-mode is implented ES is supervisor-save and there is no need for such efforts :)
-
@hiulit Another tip for your fun-facts-script project:
Declare a variable for
fun_facts.txt
, set the file's full path to the variable, and use the variable when you need to reference that file.It avoids some
No such file or directory
errors when you invoke the script from another directory.Example:
~/src/funfacts $ ls es-fun-facts-splashscreens.sh* fun_facts.txt ~/src/funfacts $ ./es-fun-facts-splashscreens.sh Mario first appeared in 1981 as the playable character in Nintendo's arcade game Donkey Kong. However, he was a carpenter known only as Jumpman ~/src/funfacts $ # THE SCRIPT RUNS FINE ~/src/funfacts $ cd .. ~/src $ ./funfacts/es-fun-facts-splashscreens.sh shuf: fun_facts.txt: No such file or directory
EDIT
This is the best method I've found to detect the script's dir:
readonly SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
if your
fun_facts.txt
is in the same file as the script, then you can just add the following line right after theSCRIPT_DIR
definition:readonly FUN_FACTS_TXT="$SCRIPT_DIR/fun_facts.txt"
-
@meleu Thank you! Done! Works perfectly :D
Could you elaborate on how$(cd "$(dirname "$0")
works? What does$0
mean? Thanks again! -
I found that if I specify a font when using
convert
it decreases the image creation time, like a lot!
It also depends on the sentence's length. But when specifying a font I get pretty good results with a 3 line sentence :Oreal 0m3.338s user 0m2.472s sys 0m0.824s
compared to:
real 1m3.849s user 0m12.148s sys 0m1.024s
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.