Skip to content

Commit c44b103

Browse files
committed
feat(calendarium): add background opacity setting, always hide decorations
- Add bg-opacity scale setting (0=transparent, 1=solid black) to Appearance - Always hide desklet frame and header via prevent-decorations metadata - Remove hide-decorations toggle (no longer needed) - Fix set_style ordering so background survives _updateDecoration() call - Store desklet name in _deskletName for reuse
1 parent 7cb5a00 commit c44b103

2 files changed

Lines changed: 22 additions & 14 deletions

File tree

calendarium@kami911/files/calendarium@kami911/desklet.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ CalendariumDesklet.prototype = {
118118
this._isDestroyed = false;
119119
this._wikiRotateStep = 0; // advances each minute to rotate Wikipedia items
120120
this._wikiOnThisDayData = null; // cached full onthisday response
121+
this._deskletName = metadata.name || "Calendarium";
121122

122-
this.setHeader(metadata.name || "Calendarium");
123+
this.setHeader(this._deskletName);
123124
this._bindAllSettings(desklet_id);
124125
try {
125126
this._setupUI();
@@ -223,7 +224,7 @@ CalendariumDesklet.prototype = {
223224
// Appearance
224225
s.bindProperty(IN, "icon-size", "icon_size", cb);
225226
s.bindProperty(IN, "text-scale", "text_scale", cb);
226-
s.bindProperty(IN, "hide-decorations", "hide_decorations", cb);
227+
s.bindProperty(IN, "bg-opacity", "bg_opacity", cb);
227228
},
228229

229230
/**
@@ -748,10 +749,12 @@ CalendariumDesklet.prototype = {
748749
},
749750

750751
_applyAppearance: function() {
751-
// Text scale: adjust base font-size so the layout naturally expands/shrinks
752-
let s = this.text_scale || 1.0;
752+
let s = this.text_scale || 1.0;
753753
let basePx = Math.round(13 * s);
754-
this._container.set_style("font-size: " + basePx + "px;");
754+
let op = Math.max(0, Math.min(1, this.bg_opacity || 0));
755+
let containerStyle =
756+
"font-size: " + basePx + "px;" +
757+
"background-color: rgba(0, 0, 0, " + op.toFixed(2) + ");";
755758

756759
// Icon / symbol size for moon and zodiac symbols
757760
let px = this._getIconPx();
@@ -765,10 +768,11 @@ CalendariumDesklet.prototype = {
765768
"font-size: " + px + "px; padding-right: 5px;"
766769
);
767770

768-
// Decorations
769-
if (this.hide_decorations) {
770-
this.setHeader(" ");
771-
}
771+
// Always hide frame and header — re-apply after _updateDecoration()
772+
// which may reset container styles.
773+
this.metadata["prevent-decorations"] = true;
774+
this._updateDecoration();
775+
this._container.set_style(containerStyle);
772776
},
773777

774778
// ── Section updaters ──────────────────────────────────────────────────

calendarium@kami911/files/calendarium@kami911/settings-schema.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
"section-appearance": {
128128
"type": "section",
129129
"title": "Appearance",
130-
"keys": ["icon-size", "text-scale", "hide-decorations"]
130+
"keys": ["icon-size", "text-scale", "bg-opacity"]
131131
}
132132
},
133133

@@ -621,9 +621,13 @@
621621
"description": "Text scale factor",
622622
"tooltip": "Scale all text in the desklet up or down."
623623
},
624-
"hide-decorations": {
625-
"type": "checkbox",
626-
"default": false,
627-
"description": "Hide desklet decorations (border and header label)"
624+
"bg-opacity": {
625+
"type": "scale",
626+
"default": 0.0,
627+
"min": 0.0,
628+
"max": 1.0,
629+
"step": 0.05,
630+
"description": "Background opacity",
631+
"tooltip": "0 = fully transparent (wallpaper shows through), 1 = solid black background"
628632
}
629633
}

0 commit comments

Comments
 (0)