Percentage Indicator Unavailable for Sound and Brighness while Changing

Please post suggestions for improvement of Cinnamon here
https://github.com/linuxmint/Cinnamon
Post Reply
User avatar
N3wb
Level 2
Level 2
Posts: 71
Joined: Mon Sep 17, 2018 11:33 am

Percentage Indicator Unavailable for Sound and Brighness while Changing

Post by N3wb » Wed Sep 19, 2018 10:53 am

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.
Linux Mint 19 Cinnamon
Kernel: 4.15.0-36-generic

User avatar
smurphos
Level 8
Level 8
Posts: 2007
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: Percentage Indicator Unavailable for Sound and Brighness while Changing

Post by smurphos » Wed Sep 19, 2018 1:44 pm

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.

User avatar
N3wb
Level 2
Level 2
Posts: 71
Joined: Mon Sep 17, 2018 11:33 am

Re: Percentage Indicator Unavailable for Sound and Brighness while Changing

Post by N3wb » Thu Sep 20, 2018 9:52 am

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?
Linux Mint 19 Cinnamon
Kernel: 4.15.0-36-generic

User avatar
smurphos
Level 8
Level 8
Posts: 2007
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: Percentage Indicator Unavailable for Sound and Brighness while Changing

Post by smurphos » Thu Sep 20, 2018 1:11 pm

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.

User avatar
N3wb
Level 2
Level 2
Posts: 71
Joined: Mon Sep 17, 2018 11:33 am

Re: Percentage Indicator Unavailable for Sound and Brighness while Changing

Post by N3wb » Sat Sep 22, 2018 3:32 am

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)
Linux Mint 19 Cinnamon
Kernel: 4.15.0-36-generic

User avatar
smurphos
Level 8
Level 8
Posts: 2007
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: Percentage Indicator Unavailable for Sound and Brighness while Changing

Post by smurphos » Sat Sep 22, 2018 3:46 am

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));

Post Reply

Return to “Cinnamon”