Code Monkey home page Code Monkey logo

i3-volume's Introduction

i3-volume

Volume control with on-screen display notifications. Works with any window manager, such as i3wm, bspwm, and KDE, as a standalone script, or with statusbars such as polybar, i3blocks, i3status, and more.

License: GPL v2 build

Installation

Read the installation instructions to get started. For a specific usage:

Usage

Use your keyboard volume keys to increase, decrease, or mute your volume. If you have a volume indicator in your status line it will be updated to reflect the volume change. When notifications are enabled a popup will display the volume level.

On-Screen Notifications

notify-osd dunst xob
notify-osd notifications dunst notifications xob notifications
XOSD herbe volnoti
xosd notifications herbe notifications volnoti notifications
KOSD
kosd notifications

Read about notifications for more information.

Standalone

i3-volume does not require any particular desktop environment and can be used as a standalone script.

Command-line options

Usage: ./volume [<options>] <command> [<args>]
Control volume and related notifications.

Commands:
  up <value>                  increase volume
  down <value>                decrease volume
  set <value>                 set volume
  mute                        toggle mute
  listen                      listen for changes to a PulseAudio sink
  output <format>             output volume in a supported format
                              custom format substitutions:
                                  %v = volume
                                  %s = sink name (PulseAudio only)
                                  %c = card (alsamixer only)
                                  %m = mixer (alsamixer only)
                                  %p = volume progress bar
                                  %i = volume icon/emoji

                                  examples:
                                      "Volume is %v" = Volume is 50%
                                      "%i %v %p \n"  = 奔 50% ██████████
  outputs                     show available output formats
  notifications               show available notification methods
  help                        display help

Options:
  -a                          use amixer
  -n                          enable notifications
  -C                          use libcanberra for playing event sounds
  -P                          play sound for volume changes
  -j <muted,high,low,medium>  specify custom volume emojis as a comma separated list
  -t <process_name>           process name of status bar (requires -u)
  -u <signal>                 signal to update status bar (requires -t)
  -x <value>                  maximum volume
  -X <value>                  maximum amplification; if supported (default: 2)
  -h                          display help

amixer Options:
  -c <card>                   card number to control
  -m <mixer>                  set mixer (default: Master)

PulseAudio Options:
  -s <sink>                   symbolic name of sink

Notification Options:
  -N <method>                 notification method (default: libnotify)
  -p                          enable progress bar
  -L <placement>              progress bar placement (default: summary; requires -p)
                              placements:
                                  body
                                  summary
  -e <expires>                expiration time of notifications in ms
  -l                          use fullcolor instead of symbolic icons
  -S <suffix>                 append suffix to symbolic icon names
  -y                          use dunstify (default: notify-send)

Environment Variables:
  XOSD_PATH                   path to osd_cat
  HERBE_PATH                  path to herbe
  VOLNOTI_PATH                path to volnoti-show
  DUNSTIFY_PATH               path to dunstify
  CANBERRA_PATH               path to canberra-gtk-play
  NOTIFY_SEND_PATH            path to notify-send or notify-send.py
  USE_NOTIFY_SEND_PY          flag to use notify-send.py instead of notify-send
  NO_NOTIFY_COLOR             flag to disable colors in notifications

Migrating

Version 2.x to 3.x

Version 3 introduces commands which makes it incompatible with previous versions. Your command-line usage and/or configured hotkeys need to be updated to reflect this.

Change v2 v3
-d is now the down command volume -d 5 volume down 5
-i is now the up command volume -i 5 volume up 5
-m is now the mute command volume -m volume mute
-o is now the output command volume -o i3blocks volume output i3blocks
-v is now the set command volume -v 5 volume set 5
-L is now the listen command volume -L volume listen
-M is now the -m option volume -M Master volume -m Master

Interoperability

i3-volume is capable of working with many other programs. The following lists a few with examples:

Program Note
i3blocks See our example blocklet
i3status-rust See our example custom block
xob Requires extra steps for notifications. Guide
XOSD Notifications require the -N xosd option. Example
herbe Notifications require the -N herbe option. Example
volnoti Notifications require the -N volnoti option. Example
KOSD Notifications require the -N kosd option. Example
sxhkd For keybindings with or without i3wm, often used with bspwm. Example

Help

Having a problem? Try reading our common issues or open an issue.

License

i3-volume is released under GNU General Public License v2

Copyright (C) 1989, 1991 Free Software Foundation, Inc.

i3-volume's People

Contributors

2ico avatar aleozlx avatar alzee avatar asuza avatar hastinbe avatar jose1711 avatar kr1ss-xd avatar sparr 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

i3-volume's Issues

Automatic sink selection feature

Hello, thanks for sharing the project it helped me understand some nuances of sounds in linux.

I was wondering if you ever thought about putting a small enhancement which would apply the changes to all sinks that are currently in RUNNING state. (notation is specific to pactl.

basically the script could extract a list of sinks running using something like:

for s in $(pactl list short sinks | grep RUNNING | cut -f2); do volume -n -s $s down 10; done

and a loop could be applied to all the sinks which comes out of the command.

Just an idea, you might have already thought about it...

Cheers,
Rodrigo

Documentation outdated for i3blocks

Unfortunatlely there is no way to open pull requests for wiki pages, or I would have done that.

The documentation for using i3-volume with i3blocks is this

[i3volume]
label=
command=~/i3-volume/volume -o i3blocks
interval=once
signal=10
color=#b8bb26
separator_block_width=10
markup=pango

The -o flag doesn't work, so the example should be updated to

[i3volume]
label=
command=~/i3-volume/volume output i3blocks
interval=once
signal=10
color=#b8bb26
separator_block_width=10
markup=pango

😃

sudden blue progress bar appears on dunstify notification below the original one

shortcut to change volume via sxhkd:
super + {F10, F11} i3-volume {down, up} 5 -np -N dunstify
super + F12 i3-volume mute -np -N dunstify
what is looks like now:
2021-05-05_3840x2160-crop

using the -y option won't fix it, instead making the whole thing greenish like this:
2021-05-05_3840x2160-crop

without the -p option it still persists.

What could be the cause of that blue progress bar appearing suddenly?

on arch with i3wm, was normal until i tried to change volume while playing a video via mpv, it was normal before.

support raising volume to clamping/max volume even though it's not a multiple of the volume step

If you set your vol to 0 and then execute ./volume up 3 -x 100, you can only get to 99% because 100 is not a multiple of 3.

If you have the volume set to 98%, i3-volume won't increase the volume to the max volume set with -x 100.

However, if you set the volume to -0.17dBa (see also: #25) and ./volume up 1 -x 100, it'll set the volume to 0.09dBa, which is slightly more than 100%.

Please consider changing the behaviour of the script so it a) adheres to the max volume if you have "crude" dBa volumes set, and b) increases the volume to the max volume even if it's not a multiple of the increase.

No icon found warning

Hi, I have a small problem with the notification icon. It is not showing and I can see warning messages such as the following if run from the terminal.

WARNING: No icon found in path: 'audio-volume-high'

What I tried:
I have double checked the dunst config:

$ grep icon_path ~/.config/dunst/dunstrc
    icon_path = /usr/share/icons/Adwaita/16x16/status/:/usr/share/icons/Adwaita/16x16/devices/

And I do have these stuff on my system:

$ ls /usr/share/icons/Adwaita/16x16/status/audio* 
/usr/share/icons/Adwaita/16x16/status/audio-volume-high-symbolic.symbolic.png
/usr/share/icons/Adwaita/16x16/status/audio-volume-low-symbolic.symbolic.png
/usr/share/icons/Adwaita/16x16/status/audio-volume-medium-symbolic.symbolic.png
/usr/share/icons/Adwaita/16x16/status/audio-volume-muted-symbolic.symbolic.png
/usr/share/icons/Adwaita/16x16/status/audio-volume-overamplified-symbolic.symbolic.png

Not sure what else I might be missing and I'm not familiar with how dunst pulls icons, so I am not sure if it's even hitting those files or am I missing packages.

Thanks for your time.

i3-volume changes volume properly, but doesn't show notification

Running the current git version of i3-volume on Ubuntu 17.10 x86_64 with i3 window manager

i3-volume changes the volume properly, but if run with the -n switch, the notification does not appear and errors show up:

$ notify-send --version
notify-send 0.7.7

$ ./volume -i 5 -n
./volume: line 117: [: : integer expression expected
./volume: line 119: [: : integer expression expected
./volume: line 121: [: : integer expression expected
./volume: line 123: [: : integer expression expected
Value "" of hint "value" could not be parsed as type "int".

Compatibility with pipewire

Currently i3-volume became incompatible with distributions that switched from Pulseaudio to Pipewire as pacmd is removed during the migration. Not sure what options are there to bring it back.

Version 3 always shows help/usage

I can't help but feel like I'm doing something wrong here. No matter what I do, the help/usage always pops up and it seems like the volume doesn't change at all.

I've tried the default settings, which don't work. This is expected because of my setup.

➜  ~ i3-volume/volume -an -t i3status -u SIGUSR1 up 5
amixer: Unable to find simple control 'Master',0

So then I update the command to use the Headphone mixer, which I assume it finds because the above error goes away:

➜  ~ i3-volume/volume -an -m Headphone -t i3status -u SIGUSR1 up 5
Usage: i3-volume/volume [<options>] <command> [<args>]
Control volume and related notifications.

Commands:
  up <value>            increase volume
  down <value>          decrease volume
  set <value>           set volume
  mute                  toggle mute
  listen                listen for changes to a PulseAudio sink
  output <format>       output volume in a supported format
                        custom format substitutions:
                            %v = volume
                            example: "My current volume is %v"
  outputs               show available output formats
  notifications         show available notification methods
  help                  display help

Options:
  -a                    use amixer
  -n                    enable notifications
  -t <process_name>     process name of status bar (requires -u)
  -u <signal>           signal to update status bar (requires -t)
  -x <value>            maximum volume
  -X <value>            maximum amplification; if supported (default: 2)
  -h                    display help

amixer Options:
  -c <card>             card number to control
  -m <mixer>            set mixer (default: Master)

PulseAudio Options:
  -s <sink>             symbolic name of sink

Notification Options:
  -N <method>           notification method (default: libnotify)
  -p                    enable progress bar
  -e <expires>          expiration time of notifications in ms
  -l                    use fullcolor instead of symbolic icons
  -S <suffix>           append suffix to symbolic icon names
  -y                    use dunstify (default: notify-send)

I've tried many different combinations of things and no matter what I do, I still get the usage script. Is it me?

Simplifying it down to i3-volume/volume -an -m Headphone up 5 doesn't help, either.

Notification dosn't work on archlinux+i3

On my computer this code dosn't work

get_volume_pulseaudio() {
    local sink="$1"

    pacmd list-sinks |
        awk -W posix -v 'RS=\r?\n' \
            '/^[ \t]+name: /{insink = $2 == "<'$sink'>"}
             /^[ \t]+volume: / && insink {gsub("%", ""); print $5; exit}'
}

But, this code work very well

get_volume_pulseaudio() {
    local sink="$1"

    pacmd list-sinks |
    gawk '/^[ \t]+name: /{insink = $2 == "<'$sink'>"}/^[ \t]+volume: / && \
          insink {gsub("%", ""); print $5; exit}'
}

I on ArchLinux with i3, i use PulseAudio and libnotify.

Aur installation resets /etc/i3/config to default

I had some trouble manually placing the scripts so I decided to use yay. I noticed my /etc/i3/config was completely reset to default...
Why is that necessary? I have to rewrite my config again, as I didnt do a backup because I didnt expect anything to overwrite it.

support decimals for volume steps

if you run .scripts/volume up 1.5 -x 105.5, you get ./volume: line 1025: 105.5: syntax error: invalid arithmetic operator (error token is ".5"). It would be nice if one could use decimal values.

i3-volume causes an error in notify-send.py

See phuhl/notify-send.py#19. When I run your script like this:

USE_NOTIFY_SEND_PY=true ./volume -n -t i3status -u SIGUSR1 up 5

This causes the following error:

  File "/home/reindert/.local/lib/python3.7/site-packages/notify_send_py/notify_send_py.py", line 126, in notify
    conn = Client(pidf.read())
  File "/usr/lib/python3.7/multiprocessing/connection.py", line 487, in Client
    family = family or address_type(address)
  File "/usr/lib/python3.7/multiprocessing/connection.py", line 108, in address_type
    raise ValueError('address type of %r unrecognized' % address)
ValueError: address type of b'' unrecognized

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/reindert/.local/bin/notify-send.py", line 8, in <module>
    sys.exit(main())
  File "/home/reindert/.local/lib/python3.7/site-packages/notify_send_py/notify_send_py.py", line 218, in main
    NotifySendPyCLI()
  File "/home/reindert/.local/lib/python3.7/site-packages/notify_send_py/notify_send_py.py", line 211, in __init__
    dontQuitOnAction=args.dontQuitOnAction
  File "/home/reindert/.local/lib/python3.7/site-packages/notify_send_py/notify_send_py.py", line 132, in notify
    pidf.write(listener.address)
TypeError: a bytes-like object is required, not 'str'

Using python 3.7.3 on Debian buster.

More ".symbolic"-problems

I have a similar problem to #11 , but I'm using an icon font that calls the symbolic files "audio-volume-high-symbolic.svg" (so a middle case between legacy and the redundant "*-symbolic.symbolic" thing.
I'd suggest a numeric -l option, so that it would be

0: "audio-volume-high-symbolic.symbolic"
1: "audio-volume-high"
2: "audio-volume-high-symbolic"

(probably defaulting to 0 if not given and 1 if given without a number)

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.