[SOLVED] LM12 LXDE: Max volume on startup!?

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
etisdale

[SOLVED] LM12 LXDE: Max volume on startup!?

Post by etisdale »

Hi, All. Curious if anybody has had the problem of max volume on startup, and if anybody know what to do about it.

I usullay keep my main/system volume at about 15%, turning it up only when an application (e.g., VLC) volume is maxed out.

Without fail, the main/system volume is maxed out each time I restart my computer. I usually remember to turn it down first thing (or keep my speakers off until I do); however, on occasion, I forget and I am inevitbly reminded by some ear-busting notification of one sort or another.

Any ideas on how to make the volume stick between sessions? This has happened since installation, and continues to this day.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
shengchieh

Re: LM12 LXDE: Max volume on startup!?

Post by shengchieh »

Write a script that make the volume 15% and have it runs at startup.

Sheng-Chieh
etisdale

Re: LM12 LXDE: Max volume on startup!?

Post by etisdale »

It seems that I have found at least a partial solution. It's a partial solution because I now know the command to run, but I do not know where to put it so that it is executed system-wide. I thought /etc/profile might work, but I couldn't get it to work. Anybody have an idea for how to run this command for each user that logs in?

Should anybody be having the same problem, below is how I figured out the exact command to run on my system. Maybe somebody will come along and provide the rest of the solution. ;)



pacmd is a program for reconfiguring the PulseAudio sound server during runtime.

The general form of the pacmd command: pacmd set-sink-volume (args: index|name, volume)

This is the specific command that I use on my system, using alsa_output.pci-0000_02_09.0.analog-stereo and 10000 for the 'name' and 'volume' arguments, respectively: pacmd set-sink-volume alsa_output.pci-0000_02_09.0.analog-stereo 10000

As for the my command, this is how I figured it out (in a condensed way):

NOTE: I did the following with my speakers turned OFF!

1) pacmd help | grep volume

This gave me the following:
set-sink-volume Set the volume of a sink (args: index|name, volume)
set-sink-input-volume Set the volume of a sink input (args: index, volume)
set-source-volume Set the volume of a source (args: index|name, volume)

2) I did not know which volume to set, so I started to fool around with the graphical volume setting to see what changed.

First, I set the volume to something high, then issued this command: pacmd info | grep volume

Then, I set the volume to something low, then issed the "pacmd info | grep volume" command again. There was definitely a change. In my case the volume went from 86% to 16%.

Without any further volume adjustments, I dumped all the info from the 'pacmd info' command into a text file on my Desktop: pacmd info > ~/Desktop/pacmd.txt

3) To learn what volume to adjust via pacmd (i.e., set-sink-volume; set-sink-input-volume; or set-source-volume), I opened the pacmd.txt file on my Desktop and searched for 16% (my last volume setting).

I the general section where I found the 16% volume, I also found the index and name of my sink:

1 sink(s) available.
* index: 0
name: <alsa_output.pci-0000_02_09.0.analog-stereo>

Further down in the file, it said, "0 sink input(s) available," so I knew it was "set-sink-volume" that I wanted to adjust and not "set-sink-input-volume."

4) Knowing which args to plug into the command, I started playing with the volume. I found that a volume argument of 10000 gave me 15% on the graphical volume setting.

I adjustied the volume setting iteratively using the following commands until I found 15% with 2.:
1. pacmd set-sink-volume <index|name> <0-65000+>
2. pacmd info | grep "volume: "

I found that a volume 65000 gave 99%, but that that was not the upper limit!



That's it! Now, if anybody could help me find a way to get the command to run for each user upon login, it would be much appreciated! Thanks.
etisdale

Re: LM12 LXDE: Max volume on startup!?

Post by etisdale »

Turned my attention back to this this morning, and I can report that I have had some success in setting the user volume at login. I say 'some' because I am getting some strange behavior.


What I did to set user volume at login:

1) cd /etc/profile.d

2) sudo vim volume.sh

3) Edit volume.sh to include the command from the previous post. In my case:

# Set volume via pacmd
pacmd set-sink-volume alsa_output.pci-0000_02_09.0.analog-stereo 10000

4) Save the file and make sure the permissions are the same as that of similar files (e.g., bash_completion.sh) in the directory. If not, try the following command:

sudo chmod 644 volume.sh

5) Adjust the graphical volume indicator to an arbitrary level, log out, and log back in again. If you used '10000' as I did, the graphical volume indicator should be at '15.'


Strange behavior:

Step 5 above works; rebooting and logging in (first time) does not! The graphical volume setting at first log in is still set at 100!

Anybody know how to fix this?!
rebelxt
Level 2
Level 2
Posts: 69
Joined: Sat Jul 16, 2011 9:48 am

Re: LM12 LXDE: Max volume on startup!?

Post by rebelxt »

In Linux Mint Mate 13 there is a "Volume Control" startup application. If you have the same program, I believe that it is overriding what you're doing in /etc/profile.d. Try putting a sleep command in your script. I suspect a low number, 3-5, will probably work.

I put my version of the program in the startup applications so each user can set the volume.
Image
etisdale

Re: LM12 LXDE: Max volume on startup!?

Post by etisdale »

rebelxt wrote:In Linux Mint Mate 13 there is a "Volume Control" startup application. If you have the same program, I believe that it is overriding what you're doing in /etc/profile.d. Try putting a sleep command in your script. I suspect a low number, 3-5, will probably work.

I put my version of the program in the startup applications so each user can set the volume.
Thanks for the suggestion. I will give it a try.

I poked around my menu and found a menu item (Menu > Preferences > Desktop Session Settings) that indicated that the PulseAudio Sound System is automatically started after entering the desktop. Ideally, I would be able to modify the way PulseAudio is automatically started, not after the fact. Trouble is, I have not been able to find a way to do it!
etisdale

Re: LM12 LXDE: Max volume on startup!?

Post by etisdale »

Solved!

I learned that /etc/xdg/autostart/pulseaudio.desktop is used when entering the desktop environment (LXDE). I opened the file, and, from there, determined that it was start-pulseaudio-x11 that I was looking for.

Specifically, near the end of pulseaudio.desktop was the following line : Exec=start-pulseaudio-x11

I found start-pulseaudio-x11 in /usr/bin/ using the 'which' command. The is also a kde version.

Below is the full file as it appears with my edit. All I did is add the following line: /usr/bin/pactl set-sink-volume 0 10000

As above, '10000' sets the volume to '15' when entering LXDE. And I chose to use '0' instead of 'alsa_output.pci-0000_02_09.0.analog-stereo.' That way, if I change my soundcard, I won't have to edit the start-pulseaudio-x11 file again!
#!/bin/sh

# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.

set -e

if [ x"$DISPLAY" != x ] ; then

/usr/bin/pactl load-module module-x11-publish "display=$DISPLAY" > /dev/null
/usr/bin/pactl load-module module-x11-bell "display=$DISPLAY" "sample=bell.ogg" > /dev/null
/usr/bin/pactl load-module module-x11-cork-request "display=$DISPLAY" > /dev/null
/usr/bin/pactl set-sink-volume 0 10000

if [ x"$SESSION_MANAGER" != x ] ; then
/usr/bin/pactl load-module module-x11-xsmp "display=$DISPLAY session_manager=$SESSION_MANAGER" > /dev/null
fi
fi
jasmineaura

Re: [SOLVED] LM12 LXDE: Max volume on startup!?

Post by jasmineaura »

Not a good idea if you want your changes to stick through upgrades. That is, on the next pulseaudio upgrade, the file will be overwritten and your changes will be lost.
You could simply add your command to the end of /xdg/lxsession/LXDE/autostart for LXDE. This applies to all users using LXDE. If you wanted to the command to run only for your user account, add it to ~/.config/lxsession/LXDE/autostart
~ being /home/yourusername
Locked

Return to “Software & Applications”