Giter VIP home page Giter VIP logo

pulseaudio-ctl's Introduction

Pulseaudio-ctl

Simple bash script to allow for control of pulseaudio without alsautils. Simply map the following to keyboard shortcuts in your DE or WM. Xfce4 allows for this under Settings > Keyboard > Application Shortcuts.

/usr/bin/pulseaudio-ctl mute        ==>  Toggle status of mute
/usr/bin/pulseaudio-ctl mute-input  ==>  Toggle status of mute for mic
/usr/bin/pulseaudio-ctl up          ==>  Increase vol by 5 %
/usr/bin/pulseaudio-ctl up 25       ==>  Increase vol by 25 %
/usr/bin/pulseaudio-ctl down        ==>  Decrease vol by 5 %
/usr/bin/pulseaudio-ctl down 50     ==>  Decrease vol by 50 %
/usr/bin/pulseaudio-ctl set 40      ==>  Set vol to 40%
/usr/bin/pulseaudio-ctl atmost 30   ==>  Set vol to 30% if current higher than that

Configuration

A config file resides in ~/.config/pulseaudio-ctl/config and allows for some options including:

Example:

# 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

# Show a graphical progress-bar type visualization of the volume level in
# libnotify. No setting or commented out will show a simply percentage but
# a setting will convert the percentage to a progress-bar in libnotify.
#
BARCHART=yes

# Use KDE OSD notification. Set to any value to enable this feature.
KDE_OSD=yes

If config file isn't present script uses default value 100 for the UPPER_THRESHOLD and notifications are disabled by default.

Links

AUR package: https://aur.archlinux.org/packages/pulseaudio-ctl

pulseaudio-ctl's People

Contributors

bebehei avatar blackwolf12333 avatar graysky2 avatar jdkaplan avatar ntrp avatar perpetual-hydrofoil avatar philosoft avatar randallsquared avatar somini avatar type8 avatar zjeffer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pulseaudio-ctl's Issues

"Cannot determine which version of pactl is installed" after upgrading pulseaudio

Running pulseaudio-ctl show the following output:

(standard_in) 1: syntax error
(standard_in) 1: syntax error
(standard_in) 1: syntax error
Cannot determine which version of pactl is installed. Aborting.

This happened after upgrading pulseaudio (13.0-3 -> 13.99.2+7+g6101798c7-1)

uname -a: Linux Arch 5.8.13-arch1-1 #1 SMP PREEMPT Thu, 01 Oct 2020 20:40:35 +0000 x86_64 GNU/Linux

error message: awk: line 1: regular expression compile failed (missing operand)

Hello, every time I try to run pulseaudio-ctrl I get some variation of the output below.
Is this a mistake I am making or a problem with the code?

(precise)onhoplus@localhost:~/.config/pulseaudio-ctl$ /usr/bin/pulseaudio-ctl mute
awk: line 1: regular expression compile failed (missing operand)

  • index:
    awk: line 1: regular expression compile failed (missing operand)
  • index:
    Assertion 'o' failed at pulse/operation.c:67, function pa_operation_unref(). Aborting.
    /usr/bin/pulseaudio-ctl: line 97: 29301 Aborted (core dumped) pactl set-sink-mute "$SINK" toggle
    (precise)jacob@localhost:~/.config/pulseaudio-ctl$ /usr/bin/pulseaudio-ctl up
    awk: line 1: regular expression compile failed (missing operand)
  • index:
    awk: line 1: regular expression compile failed (missing operand)
  • index:
    Assertion 'o' failed at pulse/operation.c:67, function pa_operation_unref(). Aborting.
    /usr/bin/pulseaudio-ctl: line 97: 29414 Aborted (core dumped) pactl set-sink-volume "$SINK" -- +5%

crashy

$ pulseaudio-ctl down

awk: line 1: regular expression compile failed (missing operand)

  • index:
    Assertion 'o' failed at pulse/operation.c:67, function pa_operation_unref(). Aborting.
    /usr/local/bin/pulseaudio-ctl: line 50: 5357 Aborted (core dumped) pactl set-sink-volume "$SINK" -- -5%

Make possible increase volume above 100% mark

It's rather often when I face issues with movies with quiter sound on my laptop, so I need to use that sound boost' that PulseAudio offering me with volume up to 150%. Naturally as a user of that script of yours I'd like to do so without help of pavucontrol tool and leaving my video player for a bit. On rarer occasions I need that functionality in other cases. So I propose to allow that. Also I understand that my proposition can be unwanted beaviour for others, so I additionaly suggest to add some sort of param and/or config for that either with global shell variable f.e. PULSE_AUDIO_CTL_ALLOW_VOLUME_ABOVE_100=1, or through config with shell variables which will be sourced if exists from user's home directory at every script envocation. Although we can make it more generic and add param like PULSE_AUDIO_CTL_UPPER_THRESHOLD=100` and compare current volume level with threshold instead of 100 or 150 or not comparing it at all.

I can offer my assistece and prepare pull request with those changes after we discuss that matter here - in this issue, with aim to choose implementation and naming methods.

`Invalid volume specification`

Getting this when trying to run volume commands like pulseaudio-ctl up

On Arch Linux, withpulseaudio and libpulse version 11.0+6+g01f489c3

CURVOL not calculated

Decrease volume doesn't work because CURVOL is always empty string. Relevant output below. (No 'front' or 'base volume' strings, pacmd 2.0)

pacmd list-sinks|grep -A 15 '* index'

  • index: 1
    volume: 0: 55% 1: 55%
    0: -15.58 dB 1: -15.58 dB
    balance 0.00
    base volume: 100%
    0.00 dB

A workaround for inability to lower volume is to comment out
[[ "$CURVOL" -le 0 ]] && (echo 'wha..' ; exit 0) || in pulseaudio-ctl

Customize notification messages

It seems like the notification messages text are hardcoded in the script. It would be nice to be able to customize them (e.g.: via the config file)

Config loading does not respect $PREFIX

When installed using the likes of PREFIX=/usr/local make install pulseaudio-ctl still attempts to load configuration from usr/share/pulseaudio-ctl/config.skel, resulting in a broken installation.

Pulseaudio-ctl doesn't use the socket to start Pulseaudio when it's not running

Pulseaudio is configured to start automatically when it's needed, which makes superflous to configure my WM to start it at login. The problem is that Pulseaudio-ctl doesn't start Pulseaudio automatically when it's not running, which means that I won't be able to change the volume until I've started an application that outputs audio. Is this intended?

BARCHART does not acknowledge UPPER_THRESHOLD

When UPPER_THRESHOLD is set to a level higher than 100, the bar reported still relies con $CURVOL instead of recalculating the new percentage.

This is I believe the expected behavior, as can be seen on something like KMixer.

get current volume level

Greetings,

my use case is to play an alert sound from a cron entry. For that I want to set the output level at its maximum, so that the sound may be heared from another room. But once the sound has been played, I want to set the level back to its prior level.

Would it be possible to have a function to retrieve the current sound level value so that it can be stored for later use in a script ?

Thank you so much for this nice program.

Add bc as a dependency

On first start it tried to determine the version of pusleaudio but couldn't because bc wasn't installed. Please make bc a dependency.

regex syntax issue on Debian

So on fresh install of Debian (nothing fancy, I just installed Debian testing on a vm and added PulseAudio Volume Control) I am getting the following error twice running pulseaudio-ctl:
[awk: line 1: regular expression compile failed (missing operand)

  • index:
    ]

If I open up the script and change all instances (there are 4) of [/* index] to [/*index] the error is resolved, I am surprised this isn't an issue on other systems. I guess it might be the version of some software I am using, but I have always escaped special characters like * when I am writing regular expressions.

Other than that, excellent script thanks for your work!

Add `set-input` option

Hi!
Would it be possible to add a new option called set-input?
It does what it says. Set volume for default source, just like set does for sink.
It would be cool if we had also up-input and down-input, but I'm not sure how useful that would be

equalizer sink outputs volume for front left with trailing comma -> script fails to parse

Hi, thanks for useful script. Equalizer sink outputs volume for front left with trailing comma

        active port: <analog-output-headphones>
  * index: 1
        name: <alsa_output.pci-0000_00_1b.0.analog-stereo.equalizer>
        driver: <module-equalizer-sink.c>
        flags: HW_MUTE_CTRL LATENCY DYNAMIC_LATENCY
        state: RUNNING
        suspend cause: 
        priority: 1000
        volume: front-left: 54394 /  83%,   front-right: 54394 /  83%
                balance 0.00
        base volume: 65536 / 100%
        volume steps: 65537
        muted: no

in result

 $  /usr/bin/pulseaudio-ctl up
Cannot determine current volume.
/usr/bin/pulseaudio-ctl: line 110: 5 + 83, : syntax error: operand expected (error token is ", ")

I removed equalizer as a workaround :) To reproduce load pulseaudio equalizer https://wiki.archlinux.org/index.php/PulseAudio#Equalizer

Operate on currently running sink

I just noticed that when I have headphones in that pulseaudio-ctl only operates on the built-in sink even though I have selected the headphones as the output source.

% pacmd list-sinks
2 sink(s) available.
index: 0
    name: <alsa_output.pci-0000_00_1b.0.analog-stereo>
    ...
    state: IDLE
    ...

index: 1
    name: <alsa_output.usb-0d8c_C-Media_USB_Audio_Device-00-Device.analog-stereo>
    ...
    state: RUNNING
    ...

So in my case, only the first sink is changed while the currently running second sink is left unaffected.

Perhaps the state: RUNNING versus state: IDLE could be the solution?

Controll all sinks instead of only default one.

First of all - great work!

Existing pulse audio control utilities are very complex and yet not versatile at all. For example, you have to use some awk magic to know if the device is muted. Your software is way more convenient.

When I was searching for something which would help me to control volume I was looking for a console utility that helps me to control all my volume sinks at once. For example, when I attach HDMI, or Bluetooth headphones and press the volume down button, I want to decrease volume everywhere. The same with mute and everything. But I couldn't find any way to control my audio this way. Your is the most convenient, but (afaik) can't do it either.

Do you think you can implement "global" volume control? Not only for the default sink. I think it would mean running your script on all sinks discovered. And maybe adding a new config line to tune this behavior.

I read a couple of other issues in the project, seems like you have no time. I guess working on other open-source projects, thank you one more time. But maybe you gonna find time to do it. Or, maybe someone else will consider it to be simple enough to do it theyself.

Anyway, I just wanted to ping you to check if you are able to approve and merge a pull request with this feature if there gone be one.

Thank you for your time!

mute function doesn't unmute

/usr/bin/pulseaudio-ctl mute does a great job of muting the volume. However typing the same command again doesn't seem to unmute the volume. Nor do the volume up or volume down commands.
I can re-enable sound by going into the pulseaudio gui clicking the output devices tab and unmuting there.

DBUS call for displaying OSD after Plasma 5.21

With the Plasma 5.21 update, seems like something changed on the dbus call needed for displaying the volume OSD element.

Currently this seems to be the call pulseaudio-ctl uses for showing that element:

dbus-send --session --dest="org.freedesktop.Notifications" --type="method_call" "/org/kde/osdService" "org.kde.osdService.volumeChanged" "int32:$1"

This currently throws an error with Plasma 5.21:

Error org.freedesktop.DBus.Error.UnknownObject: No such object path '/org/kde/osdService'

I was able to make the OSD appear again altering the line to:

dbus-send --session --dest="org.kde.plasmashell" --type="method_call" "/org/kde/osdService" "org.kde.osdService.volumeChanged" "int32:$1"

I just started using pulseaudio-ctl, so I have never seen how was the OSD element shown before, but with this change, if I make "$1" a value over 100, it just shows the OSD as if my volume is 100%, which doesn't seem right.
It may be how it worked before too, I don't know.

[Feature Request] Respect the ratio for each channel

Hello,
I'm using pulseaudio-ctl with a 5.1 audio configuration, but when I'm increasing or decreasing the volume, it doesn't respect the ratio I have setup for each channel.

For example:

  • front: 75%
  • rear: 100%

Decreasing the volume of 40% will result to:

  • front: 35%
  • rear: 60%

So the ratio is not respected.
Also, there is another issue: max volume is configured to be 100%, but again, it doesn't respect the ratio if I keep increasing the volume. Every channels will be set to 100% instead of stopping when only one of the channels reaches 100%.

Thanks !

Check for integer values for UPPER_THRESHOLD

I do not know other ways to communicate here, but through issues and pull requests. I do not add PR because of incomplete implementation. So here it goes Philosoft@cb00d83 please look into it. I do not know what script expects to be in SINK and SOURCE I do understand what lies in CURVOL, but I tired and sleepy to do proper checks and catch unexoected cases (CURVOL not an integer) so i leave it to you or my future self.

Error with recent version of pactl

For some time now pulseaudio-ctl has been giving off this error:

Invalid volume specification

This is because it uses this command to change the volume:

pactl set-sink-volume 0 -- (volume)%

This is wrong with newer versions of pactl, the -- have to be removed and everything works fine.

pulseaudio 4 on Ubuntu 14.04

So, I installed this today, and the first use muted my default sink.

I'm writing this mainly for anyone using the same versions I am, and wondering what to do to get their audio back. I don't expect that it would be worth patching pulseaudio-ctl to fix this, and I don't have a machine with other versions to test on in any case.

Step 1:

 $ pacmd list-sinks|grep '* index'
 * index: 1   # yours might differ, I guess?  Anyway, use the same number below before " false"
 $ pacmd
 Welcome to PulseAudio! Use "help" for usage information.
 >>> set-sink-mute 1 false

You should have audio now. Press Ctrl+d to exit pacmd.

Step 2:

If this worked for you, then fixing pulseaudio-ctl is simple.

First make sure that the problem I had is really the problem you had:

 $ grep 'volume: front' /usr/bin/pulseaudio-ctl

You should have five lines of output that contain "... CURVOL ...". If so:

 $ sudo sed -i -e 's/volume: front/volume: 0/g' /usr/bin/pulseaudio-ctl

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.