Xfce Forum

Sub domains
 

You are not logged in.

#1 2019-08-29 07:18:17

johnywhy
Member
Registered: 2011-10-09
Posts: 288

[Script] Zero-RAM Volume Control

In my effort to reduce RAM footprint, i'm trying to eliminate services and daemons.

i believe pulse (or the pulse volume control) runs a daemon all the time. Other volume widgets i've tried do, eating 20-30MB RAM. Plus they pull in loads of deps when you install them. To me that's crazy. It's just a volume control.

So i wrote my own volume control. Instead of 20 or 30MB, it consumes exactly 0MB RAM when you're not using it. When you click the icon in the tray, the slider appears.

FxPG5jW.png

Alsa handles all my audio needs just fine, so i was able to uninstall pulse. This script does require yad, but yad doesn't run any daemons.

install yad and alsa-utils

determine your audio device. In my case, it's "Master":

amixer scontrols

ensure your audio device is unmuted with

amixer set Master 100 unmute

Put the script below in /usr/local/bin/set-volume.sh, make it executable, then make a launcher pointing to it.
Replace "Master" with the name of your audio device.

#!/bin/sh
VolCur=`amixer -M get Master,0 | sed -nr 's/.*\[([0-9]+)%.*/\1/p'`
yad --close-on-unfocus --scale --min-value 0 --max-value 100 --value $VolCur --print-partial --undecorated --width 300 --fixed --sticky --mouse --on-top --escape-ok --no-buttons --hide-value --timeout=4 --image=audio-volume-high --skip-taskbar --theme=Adwaita | while read VolNew 
	do amixer -M -q set Master,0 ${VolNew}%
	done

Last edited by johnywhy (2019-09-14 18:02:54)


arch xfce x86_64

Offline

#2 2019-08-29 13:28:15

kunzlata
Member
Registered: 2019-06-24
Posts: 42

Re: [Script] Zero-RAM Volume Control

Hey, nice! I'll try it, replacing the command with a pulseaudio one¹ (as I won't remove it anyway), for my icewm session.

As for reducing unnecessary stuff, have a look at the Porteus distribution. I think it's mainly targeted to be a portable OS and they have years of experience with this.

¹ hope a layman like me can figure this port.

Last edited by kunzlata (2019-08-29 13:29:46)

Offline

#3 2019-08-29 16:09:28

johnywhy
Member
Registered: 2011-10-09
Posts: 288

Re: [Script] Zero-RAM Volume Control

Thx, I have tried Porteus. Had issues, but I don't recall the details.

I've tried lots of Linuxes. Arch is my fave. Minimal. Easier to get up and running than others.

If you're going to keep running pulse, then i'm not sure what benefit this slider will give you. Might be easier to just use their volume widget.

Cheers

Last edited by johnywhy (2019-08-29 21:07:44)


arch xfce x86_64

Offline

#4 2019-08-29 18:00:20

Aravisian
Member
Registered: 2019-08-17
Posts: 410

Re: [Script] Zero-RAM Volume Control

johnywhy wrote:

In my effort to reduce RAM footprint, i'm trying to eliminate services and daemons.

i believe pulse (or the pulse volume control) runs a daemon all the time. Other volume widgets i've tried do, eating 20-30MB RAM. Plus they pull in loads of deps when you install them. To me that's crazy. It's just a volume control.

So i wrote my own volume control. Instead of 20 or 30MB, it consumes exactly 0MB RAM when you're not using it. When you click the icon in the tray, the slider appears.

https://imgur.com/FxPG5jW.png

Alsa handles all my audio needs just fine, so i was able to uninstall pulse. This script does require yad, but yad doesn't run any daemons.

Put it in /usr/local/bin/set-volume.sh, make it executable, then make a launcher pointing to it.

#!/bin/sh
VolCur=`amixer -M get Master | sed -nr 's/.*\[([0-9]+)%.*/\1/p'`
yad --close-on-unfocus --scale --min-value 0 --max-value 100 --value $VolCur --print-partial --undecorated --width 300 --fixed --sticky --mouse --on-top --escape-ok --no-buttons --hide-value --timeout=4 --image=audio-volume-high --skip-taskbar --theme=Adwaita | while read VolNew 
	do amixer -M -q set Master ${VolNew}%
	done

This deserves repeating. Admittedly, Pulse on my machine consumes about 1/2 a percent... but I agree with your thinking and experimentalism. Why should it be running at all if I am not actively using it?
I will try this out, as well.

Actually... I decided to just try it out while in the middle of this post. I installed yad with "sudo apt-get install yad", created the script, then the launcher, changed permissions.... and pop, instant volume control. Admittedly, the Pulseaudio plugin gives a lot more options. But I bet they are generally unnecessary.
I'll test it for about a week before i decide to uninstall pulse.
But works well.

EDIT - I spoke Too soon big_smile
It produces a visual sliding volume control... However, it always pops up set to minimum volume and has no effect on the actual volume coming out of my speakers.

Last edited by Aravisian (2019-08-29 18:03:53)

Offline

#5 2019-08-29 18:09:27

johnywhy
Member
Registered: 2011-10-09
Posts: 288

Re: [Script] Zero-RAM Volume Control

Maybe your audio device isn't Master.

What does this give you?

amixer -M get Master,0

Last edited by johnywhy (2019-08-29 18:10:06)


arch xfce x86_64

Offline

#6 2019-08-29 18:12:12

Aravisian
Member
Registered: 2019-08-17
Posts: 410

Re: [Script] Zero-RAM Volume Control

johnywhy wrote:

Maybe your audio device isn't Master.

What does this give you?

amixer -M get Master,0

amixer: Unable to find simple control 'Master',0

Offline

#7 2019-08-29 18:16:18

johnywhy
Member
Registered: 2011-10-09
Posts: 288

Re: [Script] Zero-RAM Volume Control

Please give results of:
amixer scontrols

Aravisian wrote:

Pulse on my machine consumes about 1/2 a percent... but I agree with your thinking and experimentalism.

Thx! Pulse is just one of the things i'm doing to reduce RAM and storage footprint. It all adds up smile

If it's only 1/2% for you, then maybe you have other much fatter stuff running (be sure to check when you don't have any user apps running).

This project isn't necessary for new PC's loaded with lots of RAM and storage, but i'm trying to achieve a lightweight desktop for older machines with very limited RAM and storage.

Last edited by johnywhy (2019-08-29 21:12:43)


arch xfce x86_64

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.014 seconds, 8 queries executed - Memory usage: 545.45 KiB (Peak: 546.29 KiB) ]