Coder Social home page Coder Social logo

kabessao / gnome-volume-step-osd Goto Github PK

View Code? Open in Web Editor NEW

This project forked from garrett92895/gnome-volume-step-osd

0.0 1.0 0.0 10 KB

A workaround script that allows you to change the system volume by a desired step size while still triggering GNOME's volume notification OSD (On Screen Display)

Python 100.00%

gnome-volume-step-osd's Introduction

gnome-volume-step-osd


A workaround script that allows you to change the system volume by a desired step size while still triggering GNOME's volume notification OSD (On Screen Display)

Requirements

The script is built using Python3 and has a the following requirements

  • python3
  • python3-dbus (or equivalent)

The package with the correct version is listed as python-dbus in the Arch repositories and python3-dbus in the Debian and Fedora repositories

This was also written and tested to be working on GNOME 3.16 with gnome-shell installed. I'm unsure if it will work on other versions of GNOME (although I don't see why it shouldn't) so your mileage may vary.

How to Use

Just download the script and make sure it is executable with chmod +x volume-change.py The script takes in two arguments:

  • [string arg1] increase or decrease
  • [int arg2] percentage change

an example for running this script might look like

python3 volume-change.py increase 2

This would increase the volume by 2 percent

You can then create a custom keyboard shortcut setting the command to either of these commands

python3 [SCRIPT_DIRECTORY]/volume-change.py [arg1] [arg2]
./[SCRIPT_DIRECTORY]/volume-change.py [arg1] [arg2]

Because this script will run every time you press the volume up or down keys, you may want to run a compiled version. You can compile the script with basic optimizations with

python3 -O -m py_compile volume-change.py

and then your command would be

python3 [SCRIPT_DIRECTORY]/__pycache__/volume-change.cpython-[PYTHON_VERSION].pyo [arg1] [arg2]

Motivation and Explanation

The motivation behind this is that each time you change the volume in GNOME 3, the volume changes by a set percentage (6% in GNOME 3.16). That percentage is literally hardcoded into the C code of the gnome-settings-daemon and is therefore not configurable. For me, 6% was too much of a step and I would continue to bounce back and forward between too loud and too quiet of a volume.

The way to work around this is to create a custom keyboard shortcut for your volume keys to run a command that will manually adjust the volume the desired amount. This is what I do in my script, using the command amixer -D pulse sset Master [percentage]%[+-]. If this does not adjust your volume, you'll have to replace the command with one that works for you.

The problem with this approach is that it no longer triggers the nice volume notification OSD like the default volume control buttons do. You don't get a notification or indication of what the current volume is. A solution to this is to create your own notifications with the current percentage. However, I wanted my solution to work seemlessly with the system, and I didn't want to have to replace GNOME's built-in volume OSD with my own just because I was manually setting the volume.

It's much easier to just use your own custom notification by using notify-send. However, in order to get GNOME's volume OSD to show up as instead of my own, less-appealing version of a volume notification, I make a dbus ShowOSD() method call to org.gnome.Shell with the proper icon and level values.

As a side note, the bash commands (amixer...) are what I use to adjust my volume and then reduce the stdout from that command to just the volume percentage level. You may need to alter the script slightly to fit your system.

gnome-volume-step-osd's People

Contributors

garrett92895 avatar guybrush1973 avatar idelsink avatar ortega-dan avatar

Watchers

 avatar

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.