Percentage Indicator Unavailable for Sound and Brighness while Changing

Please post suggestions for improvement of Cinnamon on:
https://github.com/linuxmint/Cinnamon
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
N3wb

Percentage Indicator Unavailable for Sound and Brighness while Changing

Post by N3wb »

Is it possible to show the percentage of sound on the pop up window that comes up (preferably in the middle bottom) while changing it using keyboard keys?
Similar query for display brightness.
Also I'm not sure how to add suggestions to the GitHub link, but implementing these two as system default would be really helpful.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
smurphos
Level 18
Level 18
Posts: 8498
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Percentage Indicator Unavailable for Sound and Brighness while Changing

Post by smurphos »

If you are any good with javascript the place to hack this features in would be /usr/share/cinnamon/js/ui/osdWindow.js

Place to experiment is probably in a virtualbox install of Cinnamon.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
N3wb

Re: Percentage Indicator Unavailable for Sound and Brighness while Changing

Post by N3wb »

Good to see you again smurphos! I've dabbed in JavaScript back when I did some web development related projects.
Looking at the source looks like I need to understand imports.gi structure in order to add new widget for text, where can I find that? Also are you sure this file is only for those 2 popup windows because the file seems generic.
How about my second query of requesting developers for a feature using GitHub?
User avatar
smurphos
Level 18
Level 18
Posts: 8498
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Percentage Indicator Unavailable for Sound and Brighness while Changing

Post by smurphos »

Yeah same here - I used to many years ago write Javascript based add-ons for the game Oolite but to call my skills rusty would be an understatement.

You can raise a feature request as an Issue on the Cinnamon section of the Mint Github - https://github.com/linuxmint/Cinnamon/issues - but don't expect a quick response. The dev team is small, and mostly volunteers doing it in the spare time and I can't see this request being a priority, but I may be wrong.

Re that file it provides the On Screen Display GUI for brightness, volume and (without a level bar) the media keys (play, fast foward etc). As the display is already using a level value of between 0 and 100 (this._level) I think it's basically a case of adding a label using this value.

I'm tempted to have a go at this myself but I've got very limited time for messing around with stuff at the moment. If you do work it out please share (and maybe submit it on Github as a pull request). If I do get time and get it working I'll let you know.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
N3wb

Re: Percentage Indicator Unavailable for Sound and Brighness while Changing

Post by N3wb »

Update: I managed to add level percentage at the bottom of the level bar of the OSD window.
Code segment for label widget creation:

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);
		
        // Adding label to indicate level percentage
        this._label = new St.Label({ text: " Initial Level %" });
        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);
    },
};
Code segment for setting value of label:

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;
        }
        this._label.set_text(String(level) + " %");
    },
The documentation for JavaScript library is horrible IMO, had to search through the C source and some random site linking the naming scheme from C to JS. Sources:
http://zetcode.com/gui/javascriptgtktutorial/
https://github.com/linuxmint/Cinnamon/b ... e-style.js
https://developer.gnome.org/st/stable/st-st-label.html

Screenshot:
Image Image

Queries:
  1. How do I align/justify the label text to centre of widget?
  2. I've set my volume to max 150%, how can I get the raw value of these levels? (I think it is showing 101 because of this)
User avatar
smurphos
Level 18
Level 18
Posts: 8498
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Percentage Indicator Unavailable for Sound and Brighness while Changing

Post by smurphos »

Nice work.

With regards to the formatting - you can set a style-class for the label

e.g. this might work....

this._label = new St.Label({ style_class: 'info-osd', text: " Initial Level %" });

The formatting is actually pulled from your current Cinnamon desktop theme - for the example style class above look in your active cinnamon.css for .info-osd.

With regards to going above 100% i suspect this_level is being transformed to a 0 to 100 value in this line - this._level = Math.max(0, Math.min(value, 100));
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
User avatar
smurphos
Level 18
Level 18
Posts: 8498
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Percentage Indicator Unavailable for Sound and Brighness while Changing

Post by smurphos »

For anyone stumbling on this thread - see this post for a bit more guidance on adding this feature - viewtopic.php?p=1762715#p1762715
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
Locked

Return to “Cinnamon”