Set Ubuntu sound volume on boot

Ubuntu startup / login sound can be very loud, but I like to have it. I wrote a script that uses amixer to set the volume to 25%. This is the level that I like, but when I use TV-out or headphones, I need to increase the volume. It seems I can not run the script until the input sound starts. I tried cron @reboot and put a symlink to the script in / etc / rc3.d / and in my .bash_profile script. Only the third method actually sets the volume correctly, but after playing the input sound.

Ideally, I want to run a script when I am logged out at night, or just before the ubuntu login screen is displayed.

Here is the volume setting:

`/usr/bin/amixer -c 0 sset Master,0 25% > /dev/null`

Recommendations for other methods are evaluated.

+5
source share
7 answers

You might want to add this line to your type. /etc/rc.localThis may not be fast enough, since rc.local will be called after gdm.

Also note that the default runlevel is on Ubuntu 2 , not 3 . Your link in rc3.d probably did not work simply because you are not using runlevel 3. The runlevel is configured by default with / etc / event.d / rc-default

+2
source

Yeah, yes, but do they also contain an "alsactl repository" at shutdown?

+1
source

Rob,

. "amixer" , /etc/rc #.d update-rc.d. . - , , .

.

.....

sudo echo "#!/bin/ bash" > /etc/init.d/lowvol.sh

sudo echo "/usr/bin/amixer -c 0 sset Master, 0 35% > /dev/null" → /etc/init.d/lowvol.sh

sudo chmod + x/etc/init.d/lowvol.sh

sudo chown root: root/etc/init.d/lowvol.sh

sudo update-rc.d lowvol.sh stop 20 0 6.

+1

, Arch Linux. init, Ubuntu, , Ubuntu.

0

, Ubuntu " alsactl". "alsactl store" 25% .

0

, script, . - :

#!/bin/sh

amixer -- sset Master playback -40dB

exit 1 

script .

0

.

ALSA systemd (Ubuntu systemd 14 )

/etc/systemd/system/alsavolume.service

. /usr/bin/amixer sset PCM -- 97%. ( systemd ).

[Unit]
Description="Set volume level."
After=sound.target

[Service]
Type=simple
ExecStart=/usr/bin/amixer sset PCM -- 97%

[Install]
WantedBy=multi-user.target

( /etc/systemd/system/multi-user.target.wants , .)

  • systemctl daemon-reload

  • systemctl enable alsavolume.service

    You can add a parameter --nowto start the device immediately.

0
source

All Articles