F5F Stay Refreshed Software Operating Systems Execute terminal commands at startup on a Raspberry Pi

Execute terminal commands at startup on a Raspberry Pi

Execute terminal commands at startup on a Raspberry Pi

Pages (2): 1 2 Next
L
leonism
Member
171
01-20-2023, 12:39 PM
#1
I'm working with a Raspberry Pi B running the latest Raspbian. I want to play several MP3 files in sequence automatically when the system starts up. Right now, using omxplayer and typing the file path directly doesn't work as expected. I need a solution so that upon startup (via local.rt or similar), the player starts one track, then another, and so on in a random order, looping after the last one finishes. I'm not very comfortable with shell commands or Linux, so I hope this helps. Thanks!
L
leonism
01-20-2023, 12:39 PM #1

I'm working with a Raspberry Pi B running the latest Raspbian. I want to play several MP3 files in sequence automatically when the system starts up. Right now, using omxplayer and typing the file path directly doesn't work as expected. I need a solution so that upon startup (via local.rt or similar), the player starts one track, then another, and so on in a random order, looping after the last one finishes. I'm not very comfortable with shell commands or Linux, so I hope this helps. Thanks!

S
Sertero28
Senior Member
589
01-21-2023, 08:49 AM
#2
I’m going to be honest... starting with shellcode is a smart move. Bash scripts aren’t that difficult to grasp, and getting your hands dirty early makes things much clearer later. Code that’s hard to understand becomes a real pain fast.
S
Sertero28
01-21-2023, 08:49 AM #2

I’m going to be honest... starting with shellcode is a smart move. Bash scripts aren’t that difficult to grasp, and getting your hands dirty early makes things much clearer later. Code that’s hard to understand becomes a real pain fast.

G
GabraPvP
Junior Member
42
01-21-2023, 09:39 AM
#3
I understand, I'm trying to learn Python right now. I should have started with shellcode earlier. Could you assist me?
G
GabraPvP
01-21-2023, 09:39 AM #3

I understand, I'm trying to learn Python right now. I should have started with shellcode earlier. Could you assist me?

P
poulsonater101
Junior Member
33
01-21-2023, 03:38 PM
#4
To ensure it functions properly, provide the person responsible for creating such code a location with the necessary files. Mention the media player you intended to use and clarify the context. I’ll note that setting MPlayer to play a random folder should also be viable. Having everything in one folder with this configuration will simplify setup. I’m familiar with the process. EDIT: OMXPlayer also works. EDIT: Further reading suggests Python might be a good option... EDIT: Additional notes are being reviewed.
P
poulsonater101
01-21-2023, 03:38 PM #4

To ensure it functions properly, provide the person responsible for creating such code a location with the necessary files. Mention the media player you intended to use and clarify the context. I’ll note that setting MPlayer to play a random folder should also be viable. Having everything in one folder with this configuration will simplify setup. I’m familiar with the process. EDIT: OMXPlayer also works. EDIT: Further reading suggests Python might be a good option... EDIT: Additional notes are being reviewed.

A
Accismus
Junior Member
9
01-21-2023, 03:44 PM
#5
This link leads to a discussion on the Raspberry Pi forum.
A
Accismus
01-21-2023, 03:44 PM #5

This link leads to a discussion on the Raspberry Pi forum.

B
BoazPVP
Junior Member
37
01-22-2023, 07:10 PM
#6
I'm drafting a script now, just to check if it functions properly.
B
BoazPVP
01-22-2023, 07:10 PM #6

I'm drafting a script now, just to check if it functions properly.

K
KyleFrxst
Junior Member
13
01-23-2023, 04:20 PM
#7
I've conducted some investigation and discovered something useful. When you have files without spaces, disable the quotes on echo $line and try that setup—it works perfectly. Problems arise with spaces; using quotes or double quotes makes it interpret the path incorrectly, leading to errors like multiple files when one exists. Still, progress is being made. Script code for bash file sort.txt
K
KyleFrxst
01-23-2023, 04:20 PM #7

I've conducted some investigation and discovered something useful. When you have files without spaces, disable the quotes on echo $line and try that setup—it works perfectly. Problems arise with spaces; using quotes or double quotes makes it interpret the path incorrectly, leading to errors like multiple files when one exists. Still, progress is being made. Script code for bash file sort.txt

C
CuzImBlaZeR
Junior Member
47
02-04-2023, 10:13 AM
#8
So far, I've been working wtih omxplayer, but I don't care as long as it works. Actually, omxplayer doesn't have volume controls, so other things could be better. The path is /home/pi/Desktop/fourthofjuly.mp3 for one of them, all the others are just home/pi/Desktop/[nameofsong].mp3 I could put them in one folder, if I did that it would be /home/pi/Desktop/music/[nameofsong].mp3 Also, if I need to download anything, give me a link not meant to be taken straight on to the pi; my pi mysteriously won't connect to the internet.
C
CuzImBlaZeR
02-04-2023, 10:13 AM #8

So far, I've been working wtih omxplayer, but I don't care as long as it works. Actually, omxplayer doesn't have volume controls, so other things could be better. The path is /home/pi/Desktop/fourthofjuly.mp3 for one of them, all the others are just home/pi/Desktop/[nameofsong].mp3 I could put them in one folder, if I did that it would be /home/pi/Desktop/music/[nameofsong].mp3 Also, if I need to download anything, give me a link not meant to be taken straight on to the pi; my pi mysteriously won't connect to the internet.

Y
YummyGummy_
Member
166
02-04-2023, 12:00 PM
#9
They are all in one folder. Yes. It only needs basic Linux tools, which I can confirm. The updated file hasn’t been debugged again since I don’t have an Omniverse player, and I made a change to something that was working before. It should work fine. Here’s a bash script for sort.txt:
Y
YummyGummy_
02-04-2023, 12:00 PM #9

They are all in one folder. Yes. It only needs basic Linux tools, which I can confirm. The updated file hasn’t been debugged again since I don’t have an Omniverse player, and I made a change to something that was working before. It should work fine. Here’s a bash script for sort.txt:

C
135
02-16-2023, 09:48 PM
#10
Sure, I can provide a script you can run in a shell or Python environment. Let me know if you need it tailored for Stack Overflow.
C
caitlin_straet
02-16-2023, 09:48 PM #10

Sure, I can provide a script you can run in a shell or Python environment. Let me know if you need it tailored for Stack Overflow.

Pages (2): 1 2 Next