Cinnamon volume step and media keys

Questions about codecs, DVD playback, web plugins...
Forum rules
Before you post please read how to get help
Post Reply
Particle_Man
Level 1
Level 1
Posts: 2
Joined: Thu Feb 06, 2020 9:27 am

Cinnamon volume step and media keys

Post by Particle_Man »

LM 19.3 x64 Cinnamon.


1. I would like media keys to adjust volume in smaller than 5% increments (2% or 1%). However, a setting like "volume-step" does not appear to exist in dconf-editor.

Every media key adjusts in increments of 5%: volume-up and volume-down--as well as, curiously, volume-up-quiet and volume-down-quiet.


2. When adjusting volume, I would like to display the tooltip of the Sound applet instead of the OSD; or, alternatively, I would like to edit the OSD to include the volume percentage.


My current workaround of two keyboard shortcuts does not include notification:
pactl set-sink-volume @DEFAULT_SINK@ +2%
pactl set-sink-volume @DEFAULT_SINK@ -2%

(FWIW, '@DEFAULT_SINK@' works better than '0' with my external DAC.)

User avatar
smurphos
Level 15
Level 15
Posts: 5919
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: Cinnamon volume step and media keys

Post by smurphos »

Hi, welcome to the forums.
Particle_Man wrote:
Thu Feb 13, 2020 2:22 pm
1. I would like media keys to adjust volume in smaller than 5% increments (2% or 1%). However, a setting like "volume-step" does not appear to exist in dconf-editor.

Every media key adjusts in increments of 5%: volume-up and volume-down--as well as, curiously, volume-up-quiet and volume-down-quiet.
The media key volume step is hard-coded in cinnamon-settings-daemon. But it's a 5 minute job to download the sources, modify and install the modded version

Open Software Sources application and enable Source Code repositories - follow the prompts to update the cache.

Open a terminal window and

Download the sources

Code: Select all

apt source cinnamon-settings-daemon
Open the relevant file in a text editor

Code: Select all

xed ~/cinnamon-settings-daemon-4.4.0+tricia/plugins/media-keys/csd-media-keys-manager.c
In the text editor navigate to the line below and amend 5 to your preferred value then save and close the text editor.

Code: Select all

#define VOLUME_STEP 5           /* percents for one volume button press */
In the terminal window run (note the version string will differ for different versions of Cinnamon)

Code: Select all

cd cinnamon-settings-daemon-4.4.0+tricia
Then install the build dependencies

Code: Select all

apt build-dep cinnamon-settings-daemon
Then build from the modified sources

Code: Select all

apt build
Install the modified deb file (again note the version string may differ for different Cinnamon versions)

Code: Select all

apt deb ~/cinnamon-settings-daemon_4.4.0+tricia_amd64.deb
Log out and log back in - test.
Last edited by smurphos on Mon Feb 17, 2020 12:58 am, edited 3 times in total.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

User avatar
smurphos
Level 15
Level 15
Posts: 5919
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: Cinnamon volume step and media keys

Post by smurphos »

Particle_Man wrote:
Thu Feb 13, 2020 2:22 pm
2. When adjusting volume, I would like to display the tooltip of the Sound applet instead of the OSD; or, alternatively, I would like to edit the OSD to include the volume percentage.
Hi this post should get you started on a mod to show the volume percentage in the OSD - viewtopic.php?f=208&t=277976

I've got to go to work now but if you need more help I'll look at a step by step over the weekend for this part of your query.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

User avatar
smurphos
Level 15
Level 15
Posts: 5919
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: Cinnamon volume step and media keys

Post by smurphos »

smurphos wrote:
Fri Feb 14, 2020 3:07 am
I've got to go to work now but if you need more help I'll look at a step by step over the weekend for this part of your query.
Hi,

Here's a step by step add a label with the percentage for the volume and brightness media keys OSD

1) Backup the original osdWindow.js using this command in a terminal

Code: Select all

sudo cp /usr/share/cinnamon/js/ui/osdWindow.js /usr/share/cinnamon/js/ui/osdWindow.js.original
2) Open osdWindow.js with elevated privileges in a text editor using this command in a terminal

Code: Select all

xed admin:///usr/share/cinnamon/js/ui/osdWindow.js
Navigate to to this code block and amend to add the three lines

Code: Select all

        this._label = new St.Label();
        this._label.style = 'font-size: 1.2em; text-align: center;'
        this.actor.add(this._label);
Original

Code: Select all

OsdWindow.prototype = {
    _init: function(monitorIndex) {
        this._popupSize = 0;

        this._osdSettings = new Gio.Settings({ schema_id: "org.cinnamon" });
        this._osdSettings.connect("changed::show-media-keys-osd", Lang.bind(this, this._onOsdSettingsChanged));

        this._monitorIndex = monitorIndex;

        this.actor = new St.BoxLayout({ style_class: 'osd-window',
                                       vertical: true,
                                       important: true });

        this._icon = new St.Icon();
        this.actor.add(this._icon, { expand: true });

        this._level = new LevelBar();
        this.actor.add(this._level.actor);

        this._hideTimeoutId = 0;
        this._reset();

        Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._monitorsChanged));
        this._onOsdSettingsChanged();

        Main.uiGroup.add_child(this.actor);
    },
Amended

Code: Select all

OsdWindow.prototype = {
    _init: function(monitorIndex) {
        this._popupSize = 0;

        this._osdSettings = new Gio.Settings({ schema_id: "org.cinnamon" });
        this._osdSettings.connect("changed::show-media-keys-osd", Lang.bind(this, this._onOsdSettingsChanged));

        this._monitorIndex = monitorIndex;

        this.actor = new St.BoxLayout({ style_class: 'osd-window',
                                       vertical: true,
                                       important: true });

        this._icon = new St.Icon();
        this.actor.add(this._icon, { expand: true });

        this._level = new LevelBar();
        this.actor.add(this._level.actor);
        
        this._label = new St.Label();
        this._label.style = 'font-size: 1.2em; text-align: center;'
        this.actor.add(this._label);

        this._hideTimeoutId = 0;
        this._reset();

        Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._monitorsChanged));
        this._onOsdSettingsChanged();

        Main.uiGroup.add_child(this.actor);
    },
Then navigate to this code block and amend to add a couple of lines to set the label text.

Original

Code: Select all

    setLevel: function(level) {
        this._level.actor.visible = (level != undefined);
        if (level != undefined) {
            if (this.actor.visible)
                Tweener.addTween(this._level,
                                 { level: level,
                                   time: LEVEL_ANIMATION_TIME,
                                   transition: 'easeOutQuad' });
            else
                this._level.level = level;
        }
    },
Amended

Code: Select all

    setLevel: function(level) {
        this._level.actor.visible = (level != undefined);
        this._label.set_text("N/A");
        if (level != undefined) {
            this._label.set_text(String(level) + " %");
            if (this.actor.visible)
                Tweener.addTween(this._level,
                                 { level: level,
                                   time: LEVEL_ANIMATION_TIME,
                                   transition: 'easeOutQuad' });
            else
                this._level.level = level;
        }
    },
Save the file, restart Cinnamon with Ctrl-Alt-Esc and test.
Last edited by smurphos on Sat Feb 15, 2020 3:26 am, edited 1 time in total.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

User avatar
smurphos
Level 15
Level 15
Posts: 5919
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: Cinnamon volume step and media keys

Post by smurphos »

Image
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

Dennis_J
Level 1
Level 1
Posts: 7
Joined: Wed Jan 16, 2019 5:49 pm
Location: Florida, USA

Re: Cinnamon volume step and media keys

Post by Dennis_J »

smurphos, thank you for this fix. The last part of your post, providing an OSD, works perfectly. It's changing the volume step size where I encounter difficulty. In the last few lines of the build, is this error:
“dpkg-buildpackage: error: failed to sign .dsc file” and no .deb is created.
I notice that near the end, signing points to the directory
“cinnamon-settings-daemon_4.4.0+tricia.dsc “ which does not exist. There is a very long output in the terminal, from which I extracted areas showing warnings and errors. I appreciate any words of wisdom. Thanks, Dennis_J

This was a fresh Mint 19.3 install on my test machine, native, not a VM. 19.3 has been stable since install last month. All updates are current.

After adding source and running:
apt source cinnamon-settings-daemon
No errors.

Edited plugins/media-keys/csd-media-keys-manager.c (changed step size from 5 to 2)

First problem occurs here:
cd cinnamon-settings-daemon_4.4.0+tricia
bash: cd: cinnamon-settings-daemon_4.4.0+tricia: No such file or directory


There is a directory using a hyphen (-) instead of underscore (_). Changing to that directory, things proceed.
cd cinnamon-settings-daemon-4.4.0+tricia

tech@xps:~/cinnamon-settings-daemon-4.4.0+tricia$ apt build

Loads of errors - This warning repeats numerous times

/bin/bash ../../libtool --mode=install /usr/bin/install -c csd-a11y-keyboard '/home/tech/cinnamon-settings-daemon-4.4.0+tricia/debian/tmp/usr/lib/x86_64-linux-gnu/cinnamon-settings-daemon'
libtool: warning: '../../cinnamon-settings-daemon/libcsd.la' has not been installed in '/usr/lib/x86_64-linux-gnu/cinnamon-settings-daemon-3.0'

. . . .

make[1]: Leaving directory '/home/tech/cinnamon-settings-daemon-4.4.0+tricia'
dh_shlibdeps
dpkg-shlibdeps: warning: can't extract name and version from library name 'libcsd.so'
dpkg-shlibdeps: warning: can't extract name and version from library name 'libcsd.so'
dpkg-shlibdeps: warning: can't extract name and version from library name 'libcsd.so'
dpkg-shlibdeps: warning: can't extract name and version from library name 'libcsd.so'
dpkg-shlibdeps: warning: can't extract name and version from library name 'libcsd.so'
dpkg-shlibdeps: warning: can't extract name and version from library name 'libcsd.so'
dh_installdeb
dh_gencontrol
dpkg-gencontrol: warning: Depends field of package cinnamon-settings-daemon-dev: unknown substitution variable ${shlibs:Depends}
dh_md5sums
dh_builddeb
dpkg-deb: building package 'cinnamon-settings-daemon-dev' in '../cinnamon-settings-daemon-dev_4.4.0+tricia_amd64.deb'.
dpkg-deb: building package 'cinnamon-settings-daemon' in '../cinnamon-settings-daemon_4.4.0+tricia_amd64.deb'.
dpkg-deb: building package 'cinnamon-settings-daemon-dbgsym' in 'debian/.debhelper/scratch-space/build-cinnamon-settings-daemon/cinnamon-settings-daemon-dbgsym_4.4.0+tricia_amd64.deb'.
Renaming cinnamon-settings-daemon-dbgsym_4.4.0+tricia_amd64.deb to cinnamon-settings-daemon-dbgsym_4.4.0+tricia_amd64.ddeb


dpkg-genbuildinfo
dpkg-genchanges >../cinnamon-settings-daemon_4.4.0+tricia_amd64.changes
dpkg-genchanges: info: including full source code in upload
dpkg-source --after-build cinnamon-settings-daemon-4.4.0+tricia
dpkg-buildpackage: info: full upload; Debian-native package (full source is included)
signfile cinnamon-settings-daemon_4.4.0+tricia.dsc
gpg: skipped "Clement Lefebvre <root@linuxmint.com>": No secret key
gpg: dpkg-sign.YstRLXfV/cinnamon-settings-daemon_4.4.0+tricia.dsc: clear-sign failed: No secret key

dpkg-buildpackage: error: failed to sign .dsc file

User avatar
smurphos
Level 15
Level 15
Posts: 5919
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: Cinnamon volume step and media keys

Post by smurphos »

Dennis_J wrote:
Sun Feb 16, 2020 9:41 pm
There is a directory using a hyphen (-) instead of underscore (_). Changing to that directory, things proceed.
cd cinnamon-settings-daemon-4.4.0+tricia
Thanks for spotting that - I've edited the post to fix the typo.

The output of build / compile commands is always very verbose.

The signing errors as they are simply because your machine doesn't have Clem's personal package signing key that signs the packages being built as genuine Mint packages. As long as you got a deb file at the end of it you should be good to install it.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

Dennis_J
Level 1
Level 1
Posts: 7
Joined: Wed Jan 16, 2019 5:49 pm
Location: Florida, USA

Re: Cinnamon volume step and media keys

Post by Dennis_J »

smurphos, no .deb is created.

Is this a material error? Says warning though. As a dev, you probably have tools installed us "normal" users don't :-)
libtool: warning: '../../cinnamon-settings-daemon/libcsd.la' has not been installed in '/usr/lib/x86_64-linux-gnu/cinnamon-settings-daemon-3.0'

Will try to find that dependency and also look for how to add Clem's signing key.

Thanks! This is not an urgent thing, sure will be neat to get working though.
Dennis_J

Dennis_J
Level 1
Level 1
Posts: 7
Joined: Wed Jan 16, 2019 5:49 pm
Location: Florida, USA

Re: Cinnamon volume step and media keys

Post by Dennis_J »

smurphos,

Cleaned up from yesterday's attempt and ran it again this morning, same PC, got a deb file! Installed it and it works just like you said it would. Same errors show up, tried to install Clem's public key, that didn't fix the signing error, but bottom line is, IT WORKS! Very handy when using a workstation for audio,

Thanks again, sorry to have bothered you.

Dennis_J

Particle_Man
Level 1
Level 1
Posts: 2
Joined: Thu Feb 06, 2020 9:27 am

Re: Cinnamon volume step and media keys

Post by Particle_Man »

smurphos, First, I want to express how impressed I am at the level of support you have provided; this speaks to the helpfulness that I've observed in the Linux Mint community in general.

-------

I've compiled the .deb without signing, but it seems to contain many more files than should be relevant to this patch.

1. How to back up the current file(s)?
2. After having installed the .deb, how to revert to the backup?

-------

Otherwise, for those who may be interested, I'm currently at different degrees of scripting workarounds to display the volume percentage: one with xdotool, very kludgey, to display the tooltip of the Sound applet; and another with yad and other utils, a fairly and simply customizable OSD, less kludgey than the xdotool approach.

User avatar
smurphos
Level 15
Level 15
Posts: 5919
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher
Contact:

Re: Cinnamon volume step and media keys

Post by smurphos »

Particle_Man wrote:
Thu Feb 27, 2020 8:35 am
1. How to back up the current file(s)?
2. After having installed the .deb, how to revert to the backup?
No real need to back up because the revert is as simple as

Code: Select all

apt install --reinstall cinnamon-settings-daemon
But if you want a copy of the original deb stored somewhere you can

Code: Select all

apt download cinnamon-settings-daemon
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.

Post Reply

Return to “Sound, Multimedia, & Codecs”