Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Play Sound with Script (mpv -no--video /audiofile.wav) a few seconds after logging in ? [SOLVED]

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
NarriT4010
Posts: 120
Joined: 2022-04-01 10:01
Has thanked: 10 times

Play Sound with Script (mpv -no--video /audiofile.wav) a few seconds after logging in ? [SOLVED]

#1 Post by NarriT4010 »

Hi guys,
The script doesn't want to play on boot.
I tried this :
sudo vim /etc/systemd/system/win95.service

[Unit]
Description=windows95start.sh
After=display-manager.service
[Service]
ExecStart=/usr/local/bin/windows95start.sh
[Install]
WantedBy=default.target

Code: Select all

sudo systemctl enable win95.service


The sound would play with this :

Code: Select all

cd /usr/local/bin && ./windows95start.sh
.
I use Debian Testing. What did I do wrong and should I try a different method ?
Last edited by NarriT4010 on 2022-05-19 17:26, edited 1 time in total.

NarriT4010
Posts: 120
Joined: 2022-04-01 10:01
Has thanked: 10 times

Re: Play Sound with Script (mpv -no--video /audiofile.wav) a few seconds after logging in ?

#2 Post by NarriT4010 »

Code: Select all

:~$ systemctl --failed
  UNIT             LOAD   ACTIVE SUB    DESCRIPTION  
● win95.service loaded failed failed win95.service

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.
1 loaded units listed.

NarriT4010
Posts: 120
Joined: 2022-04-01 10:01
Has thanked: 10 times

Re: Play Sound with Script (mpv -no--video /audiofile.wav) a few seconds after logging in ?

#3 Post by NarriT4010 »

Code: Select all

[Unit]
Description=windows95start.sh
After=networking.service
Restart=on-failure
StartLimitIntervalSec=60s
[Service]
ExecStart=/usr/local/bin/windows95start.sh
[Install]
WantedBy=default.target

~$ sudo systemctl --failed
  UNIT          LOAD   ACTIVE SUB    DESCRIPTION      
● win95.service loaded failed failed windows95start.sh

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.
1 loaded units listed.

User avatar
NorthEast
Posts: 349
Joined: 2018-11-18 04:35
Has thanked: 12 times
Been thanked: 30 times

Re: Play Sound with Script (mpv -no--video /audiofile.wav) a few seconds after logging in ?

#4 Post by NorthEast »

You could try:

Code: Select all

ExecStart=/bin/sh -c /usr/local/bin/windows95start.sh

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Play Sound with Script (mpv -no--video /audiofile.wav) a few seconds after logging in ?

#5 Post by Head_on_a_Stick »

Check

Code: Select all

journalctl --unit win95
^ That should show the actual error.

Perhaps try

Code: Select all

[Install]
WantedBy=graphical.target
I can't remember if default.target is defined in Debian but graphical.target is. There's also multi-user.target but that's for a console login.
deadbang

NarriT4010
Posts: 120
Joined: 2022-04-01 10:01
Has thanked: 10 times

Re: Play Sound with Script (mpv -no--video /audiofile.wav) a few seconds after logging in ?

#6 Post by NarriT4010 »

Code: Select all

ExecStart=/bin/sh -c /usr/local/bin/windows95start.sh

Code: Select all

sudo journalctl --unit myservicename.service
Thanks! Solved it and made the script play during boot, before the login. The goal would be to play a sound past the boot when all's finished loading. Or add some things to the boot and then play the sound when that's done loading. Couldn't find the gdm3 service, to play the sound after.

Code: Select all

#!/bin/bash
sleep 10s
mpv --no-video /home/me/95startupsound.wav
The sound broke one time but that should be possible to fix with a better more interesting script.

User avatar
canci
Global Moderator
Global Moderator
Posts: 2502
Joined: 2006-09-24 11:28
Has thanked: 136 times
Been thanked: 136 times

Re: Play Sound with Script (mpv -no--video /audiofile.wav) a few seconds after logging in ? [SOLVED]

#7 Post by canci »

>The goal would be to play a sound past the boot when all's finished loading.

Why not set it up in /etc/skel so that every new user's desktop just runs the MPV command?
Image Stable / Asus VivoBook X421DA / AMD Ryzen 7 3700U / Radeon Vega Mobile Gfx (Picasso) / 8 GB RAM / 512GB NVMe

READ THIS:

* How to Post a Thread Here
* Other Tips and Great Resources

NarriT4010
Posts: 120
Joined: 2022-04-01 10:01
Has thanked: 10 times

Re: Play Sound with Script (mpv -no--video /audiofile.wav) a few seconds after logging in ? [SOLVED]

#8 Post by NarriT4010 »

1.

Code: Select all

sudo vim /usr/local/bin/scriptname.sh
(hit i)

2. Any Script

Code: Select all

#!/bin/bash
sleep 20s
mpv --no-video /home/user/chosenbootsound.wav
(ctrl+shift+v to paste to terminal)

3. Save edit (hit esc , then :w scriptname.sh enter , then :q enter )

4. Make script executable

Code: Select all

cd /usr/local/bin && chmod +x scriptname.sh
5. New service to run script during boot (info for options: https://linuxhint.com/run-script-debian-11-boot-up/)

Code: Select all

 sudo vim /etc/systemd/system/servicename.service 

Code: Select all

[Unit]
Description=scriptname.sh
After=networking.service
[Service]
ExecStart=/bin/sh -c /usr/local/bin/scriptname.sh
[Install]
WantedBy=graphical.target
6. Enable service

Code: Select all

sudo systemctl enable servicename.service
7. Install mpv

Code: Select all

sudo apt-get install mpv
8. Try and check for errors

Code: Select all

sudo journalctl --unit servicename.service
Last edited by NarriT4010 on 2022-05-19 19:18, edited 7 times in total.

NarriT4010
Posts: 120
Joined: 2022-04-01 10:01
Has thanked: 10 times

Re: Play Sound with Script (mpv -no--video /audiofile.wav) a few seconds after logging in ? [SOLVED]

#9 Post by NarriT4010 »

>Why not set it up in /etc/skel so that every new user's desktop just runs the MPV command?
I'd like any boot sound to play after the pc is done loading everything but it does it so fast that it's probably pointless.

NarriT4010
Posts: 120
Joined: 2022-04-01 10:01
Has thanked: 10 times

Re: Play Sound with Script (mpv -no--video /audiofile.wav) a few seconds after logging in ? [SOLVED]

#10 Post by NarriT4010 »

You could add gtypist to the boot and the sound would only play after you finish one practice lesson.
Maybe something like that.

Post Reply