You are not logged in.
Use this little script to control your pulseaudio volume from within xfce4 or other DE's via mapped keys on the keyboard (mine actually has keys for mute, vol+ and vol-). Mapping shortcut keys varies from DE to DE. On xfce4, the you can do this under Settings > Keyboard > Application Shortcuts.
Usage is very simple:
/usr/bin/pulseaudio-ctl mute will toggle status of mute
/usr/bin/pulseaudio-ctl up will increase vol by 5 %
/usr/bin/pulseaudio-ctl down will decrease vol by 5 %
You can map these three actions to three keyboard shortcuts for quick access. My keyboard actually has discrete buttons for these actions:
If you execute the script from the shell, it will output the above and also show the current vol level and mute status:
% pulseaudio-ctl
pulseaudio-ctl v1.45/usr/bin/pulseaudio-ctl {up,down,mute,mute-input,set,atmost} [n]
Where up and down adjust volume in ±5 % increments.
Where mute toggles the mute status on/off.
Where mute-input toggles the input status on/off.
Where set takes a % value.
Where atmost only takes effect if current volume is higher than this.Optionally, redefine an upper threshold in /home/facade/.config/pulseaudio-ctl/config
Volume level : 90 %
Is sink muted : no
Is source muted : no
Detected sink : 1
Detected source : 1
Pulse version : 5.0
UPDATE on 03-Nov-2014: Now uses libnotify to show vol level and mute status.
AUR: https://aur.archlinux.org/packages/pulseaudio-ctl
GitHub: https://github.com/graysky2/pulseaudio-ctl
Last edited by graysky (2014-11-03 08:38:27)
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
Cool, i was looking for something like that, but I didn't know pacmd (btw not enough search).
Maybe you should modify the link in AUR to point to this forum.
Thank you for this scripts !
Last edited by twix (2011-08-14 20:47:11)
Offline
Done. Enjoy!
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
If it matters, I have reduced the number of calls to pacmd:
diff -Nru /usr/bin/vol_up vol_up
--- /usr/bin/vol_up 2012-03-05 03:22:47.000000000 -0800
+++ vol_up 2012-04-04 18:03:39.470194066 -0700
@@ -8,12 +8,7 @@
sink=`pacmd info|grep "Default sink name"|awk '{print $4}'`
# Now we need to find volume of default sink
-# get line# of start of definition for default sink (plus 1, actually)
-let line=`pacmd list-sinks|grep -n $sink|sed '{s/://}'|awk '{print $1}'`
-
-# index down a bit for volume line
-let line=($line + 6)
-volume=`pacmd list-sinks|awk 'NR=="'"$line"'"{print $3}'|sed '{s/%//}'`
+volume=`pacmd list-sinks|grep -A 6 $sink|awk 'NR==7{print $3}'|sed '{s/%//}'`
# pacmd returns volume as %, but demands setting as range: 0-65535
let volume=($volume * 65536);let volume=($volume / 100)
I have taken this code and modified it for use in my dwm status bar (to determine current volume level). Since it gets called every 5 seconds, this optimization is important to me
edit: I'm not sure where bug reports for aur packages go. Perhaps it's better to comment on the aur page?
Last edited by sankeytm (2012-04-05 02:51:47)
Offline
Didn't see this when first posted, but my own command-line control of pulseaudio's volume simply involves amixer -D pulse, so for increasing the volume I just use:-
amixer -D pulse sset Master 5%+
Much simpler IMO, and no need to worry about overflow etc.
Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.
Offline
Okay, now amixer replaces all three files in this package.
vol_up: amixer -D pulse sset Master 5%+
vol_down: amixer -D pulse sset Master 5%-
mute_toggle: amixer -D pulse sset Master toggle
It seems to work identically. It even knows to apply changes to the (current) default sink. Is there any more use for this package (pulseaudio_ctl)?
For my status bar I still need to determine the current volume of the default sink. Right now I'm extracting bits of amixer's output:
amixer -D pulse sget Master | awk '/Front Left:/ {print $4}'
or just the percentage:
amixer -D pulse sget Master | awk '/Front Left:/ {print $5}' | tr -dc "0-9"
Does anybody know of a simpler, possibly single-command way of doing it? Is It worth patching amixer, or is using awk to extract numbers the intended use?
edit: found aur/pamixer-git which has --get-volume which returns the volume in percentage.
Last edited by sankeytm (2012-04-05 08:10:03)
Offline
Didn't see this when first posted, but my own command-line control of pulseaudio's volume simply involves amixer -D pulse, so for increasing the volume I just use:-
amixer -D pulse sset Master 5%+
Much simpler IMO, and no need to worry about overflow etc.
Late reply but amixer is an additional dependency... no need for extra/alsa-utils with these scripts
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
ngoonee wrote:Didn't see this when first posted, but my own command-line control of pulseaudio's volume simply involves amixer -D pulse, so for increasing the volume I just use:-
amixer -D pulse sset Master 5%+
Much simpler IMO, and no need to worry about overflow etc.
Late reply but amixer is an additional dependency... no need for extra/alsa-utils with these scripts
Yep, I'm sure most people using alsa don't use alsa-utils for other stuff (like, for example, saving the volume on reboot?)
Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.
Offline
Yep, I'm sure most people using alsa don't use alsa-utils for other stuff (like, for example, saving the volume on reboot?)
I don't understand... my system has been fine for months without the alsa-utils package running only pulse-audio... are you mocking me
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
ngoonee wrote:Yep, I'm sure most people using alsa don't use alsa-utils for other stuff (like, for example, saving the volume on reboot?)
I don't understand... my system has been fine for months without the alsa-utils package running only pulse-audio... are you mocking me
Probably because your default volumes are fine. As I understand it, the alsa rc.d script is needed because some systems require adjustment to the amixer values to be 'saved'. Mine doesn't, but I don't mind the 2 MB package very much.
Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.
Offline
Thanks for the scripts, I was looking for that on my xfce install
EDIT: I'll use the amixer one. But without this thread I wouldn't have found it here
EDIT2: Wait, I didn't have amixer installed either.
Your script:
Total Installed Size: 0.01 MiB
dialog, alsa-utils:
Total Installed Size: 3,27 MiB
Then I'll use your fine script!
Last edited by robotanarchy (2012-09-06 13:35:29)
Offline
EDIT2: Wait, I didn't have amixer installed either.
Your script:
Total Installed Size: 0.01 MiBdialog, alsa-utils:
Total Installed Size: 3,27 MiBThen I'll use your fine script!
That's my logic as well
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
Updated to reflect a much more simplistic, single control script.
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
@graysky
Thanks for this promising script! I am wondering why it does not recognise my running pulseaudio session?
~ /usr/bin/pulseaudio-ctl mute
No PulseAudio daemon running, or not running as session daemon.
No PulseAudio daemon running, or not running as session daemon.
No PulseAudio daemon running, or not running as session daemon.
No PulseAudio daemon running, or not running as session daemon.
No PulseAudio daemon running, or not running as session daemon.
No PulseAudio daemon running, or not running as session daemon.
Cannot find current volume. CURVOL =
~ ps aux | grep pulse
orschiro 27720 0.0 0.0 352948 6264 ? SNl 20:23 0:00 pulseaudio --start
orschiro 27746 0.0 0.0 76484 2716 ? SN 20:24 0:00 /usr/lib/pulse/gconf-helper
Offline
This I do not know... try 1.37-1 and report back.
Last edited by graysky (2014-05-04 15:09:34)
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
Something different broke now with the recent update:
~ /usr/bin/pulseaudio-ctl mute
/usr/share/pulseaudio-ctl/config.skel is missing. Reinstall this package to continue.
Reinstalling the package does not help.
Last edited by orschiro (2014-05-05 11:46:06)
Offline
Temporary solution:
sudo ln -s /usr/share/pulseaudio-ctl/pulseaudio-ctl.conf.skel /usr/share/pulseaudio-ctl/config.skel
Offline
Thank you petecan for this workaround. Please excuse if my question is too stupid: At the next update, will it be necessary to do any further steps (e.g. remove the created link)?
Offline
Ack, my bad.. .typo in the Makefile. Fixed now in 1.39-1. Please try it.
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
with xbindkeys it's that simple as
"/sbin/amixer -D pulse sset Master 10%-"
m:0x10 + c:122
Mod2 + XF86AudioLowerVolume
"/sbin/amixer -D pulse sset Master 10%+"
m:0x10 + c:123
Mod2 + XF86AudioRaiseVolume
"/sbin/amixer -D pulse sset Master toggle"
m:0x10 + c:121
Mod2 + XF86AudioMute
Offline
@jdevelop-this script does not require alsautils and was designed to function completely with pulseaudio native utils. See this comment.
Last edited by graysky (2014-11-03 10:07:23)
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
New with version 1.45-1 is support to push notifications through libnotify. Please check ~/.config/pulseaudio-ctl/config against the provided /usr/share/pulseaudio-ctl/config.skel to ensure it is current as the script does not do this automatically.
% cat ~/.config/pulseaudio-ctl/config
#
# $HOME/.config/pulseaudio-ctl/pulseaudio-ctl.conf
#
# The default setting is for pulseaudio-ctl to NOT increase to volume level
# above 100 % but Some users may wish exceed this level. If this describes
# your use case, uncomment the UPPER_THRESHOLD variable below setting it to
# the new upper threshold.
#
#UPPER_THRESHOLD=150
# Push output through libnotify. Set to any value to enable this feature
# and note that you must have /usr/bin/notify-send to use this. On Arch
# libnotify provides this. Other distros may not name it as such.
NOTIFY=yes
CPU-optimized Linux-ck packages @ Repo-ck • AUR packages • Zsh and other configs
Offline
@graysky
Great improvement to provide notifications, thanks!
Can they be tweaked to look more like the ones from Xfce4 Volume Manager, which I find produces very simple but appealing messages?
Example: http://i.imgur.com/7Hx89mk.png
Offline
@graysky
Thanks for this promising script! I am wondering why it does not recognise my running pulseaudio session?
~ /usr/bin/pulseaudio-ctl mute No PulseAudio daemon running, or not running as session daemon. No PulseAudio daemon running, or not running as session daemon. No PulseAudio daemon running, or not running as session daemon. No PulseAudio daemon running, or not running as session daemon. No PulseAudio daemon running, or not running as session daemon. No PulseAudio daemon running, or not running as session daemon. Cannot find current volume. CURVOL =
~ ps aux | grep pulse orschiro 27720 0.0 0.0 352948 6264 ? SNl 20:23 0:00 pulseaudio --start orschiro 27746 0.0 0.0 76484 2716 ? SN 20:24 0:00 /usr/lib/pulse/gconf-helper
I'm having this same problem - when I try to connect to the autostarted pulseaudio daemon. I have to kill pulseaudio and restart it manually from the commandline - and then it works. Any workaround for this? (Other than having to manually do it on every boot? Will adding a line to my .xinitrc work?)
Offline