How to change background color of font for Cinnamon TextApplet?

48 Views Asked by At

I want to change background color of font as displayed on the panel for https://cinnamon-spices.linuxmint.com/applets/view/222 ("Workspace Name").

Web search found some clues, but they did not work.

based on: https://forums.linuxmint.com/viewtopic.php?t=230128 ("If it's a third-party applet, these instructions will not work.")

I've added stylesheet.ccs to applet folder with:

.applet-label {
  font-weight: bold;
  font-size: 0.2em;
  color: #f0f0f0; }

Only that did not work, so I think applet code need to read it somehow.

The code sets text with this.set_applet_label(name);.

After reading How to display multiple objects in a Cinnamon Applet I've looked at /usr/share/cinnamon/js/ui/applet.js, it has

var TextApplet = class TextApplet extends Applet {

    /**
     * _init:
     * @orientation (St.Side): orientation of the applet; Orientation of panel containing the actor
     * @panelHeight (int): height of the panel containing the applet
     * @instance_id (int): instance id of the applet
     *
     * Note that suitability for display in a vertical panel is handled by having applets declare
     * they work OK, handled elsewhere
     */
    _init(orientation, panel_height, instance_id) {
        super._init(orientation, panel_height, instance_id);
        this._applet_label = new St.Label({ reactive: true,
                                            track_hover: true,
                                            style_class: 'applet-label'});
        this._applet_label.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;

        this._layoutBin = new St.Bin();
        this._layoutBin.set_child(this._applet_label);

        this.actor.add(this._layoutBin, { y_align: St.Align.MIDDLE,
                                          y_fill: false });
        this.actor.set_label_actor(this._applet_label);
    }

    /**
     * set_applet_label:
     * @text (string): text to be displayed at the label
     *
     * Sets the text of the actor to @text
     */
    set_applet_label (text) {
        this._applet_label.set_text(text);
    }

    on_applet_added_to_panel() {
    }
}

How to use/modify it to set stylesheet in addition to the text? TIA

0

There are 0 best solutions below