Skip to content

Commit 1374d67

Browse files
committed
Moved content from stand-alone fork into central Cinnamon Git repo fork
1 parent 533aac3 commit 1374d67

5 files changed

Lines changed: 90 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# CPU Load desklet for Cinnamon
2+
3+
Displays CPU utilization per core - now with optional background opacity setting.
4+
5+
Fork of Cinnamon Desklet [cpuload@kimse](https://github.com/linuxmint/cinnamon-spices-desklets/tree/master/cpuload%40kimse)
6+
7+
## What I added:
8+
1. A new `desklet-background-color` entry in `settings-schema.json`, using the same `colorchooser` widget type your `font-color` and `static-theme-color` settings already use. That widget's picker has an alpha slider built in, so one control gives you both color *and* transparency - no separate opacity slider needed. Default is `rgba(0,0,0,0)` (fully transparent), so existing users see no change until they pick a color.
9+
2. A `refreshBackground()` method in `desklet.js` that sets `this.content.style = "background-color: " + this.desklet_background_color + ";"` - same pattern your code already uses for `font-color` in `getTextLabelStyle()`.
10+
3. Wired it to run once at startup and again whenever settings change (`on_setting_changed`), so picking a new color updates in real time.
11+
4. I also gave `show-background` a clearer label ("Show gauge track") and a tooltip, since it's easy to confuse with the new setting.
12+
13+
You can see all the changes in [`desklet-background-color.patch`](./desklet-background-color.patch).
14+
15+
Screenshots:
16+
![Transparent Background](Screenshot_0.png)
17+
![Semi-Opaque Background](Screenshot_1.png)
18+
![Settings Box](Screenshot_2.png)
1.33 MB
Loading
1.06 MB
Loading
42.4 KB
Loading
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
diff --git a/desklet.js b/desklet.js
2+
index bbcf4dc..44fce22 100644
3+
--- a/desklet.js
4+
+++ b/desklet.js
5+
@@ -45,6 +45,7 @@ CpuLoadDesklet.prototype = {
6+
this.settings.bindProperty(Settings.BindingDirection.IN, 'static-theme-color', 'static_theme_color', this.on_setting_changed);
7+
this.settings.bindProperty(Settings.BindingDirection.IN, 'show-background', 'show_background', this.on_setting_changed);
8+
this.settings.bindProperty(Settings.BindingDirection.IN, 'hide-decorations', 'hide_decorations', this.on_setting_changed);
9+
+ this.settings.bindProperty(Settings.BindingDirection.IN, 'desklet-background-color', 'desklet_background_color', this.on_setting_changed);
10+
11+
// Properties
12+
this.cpus_utilization = [];
13+
@@ -73,6 +74,7 @@ CpuLoadDesklet.prototype = {
14+
// Refresh the desklet window
15+
this.refreshScalingSizes();
16+
this.toggleDecoration();
17+
+ this.refreshBackground();
18+
19+
// Start the main desklet loop
20+
this.main();
21+
@@ -89,6 +91,17 @@ CpuLoadDesklet.prototype = {
22+
this._updateDecoration();
23+
},
24+
25+
+ /**
26+
+ * Apply the user-selected background color/transparency to the
27+
+ * desklet face. `this.content` is the St.Bin the base Desklet class
28+
+ * wraps our window in (see setContent() in ui/desklet.js) - styling
29+
+ * it, rather than this.window, covers the full desklet bounding box
30+
+ * instead of just the area behind the gauges.
31+
+ */
32+
+ refreshBackground() {
33+
+ this.content.style = "background-color: " + this.desklet_background_color + ";";
34+
+ },
35+
+
36+
/**
37+
* Refresh desklet scaling.
38+
*/
39+
@@ -621,6 +634,9 @@ CpuLoadDesklet.prototype = {
40+
// Update decoration settings
41+
this.toggleDecoration();
42+
43+
+ // Refresh background color/transparency
44+
+ this.refreshBackground();
45+
+
46+
// Refresh scaling sizes
47+
this.refreshScalingSizes();
48+
49+
diff --git a/settings-schema.json b/settings-schema.json
50+
index 62cd74c..064a96b 100644
51+
--- a/settings-schema.json
52+
+++ b/settings-schema.json
53+
@@ -94,10 +94,17 @@
54+
"type": "header",
55+
"description": "Background"
56+
},
57+
+ "desklet-background-color": {
58+
+ "type": "colorchooser",
59+
+ "default": "rgba(0,0,0,0)",
60+
+ "description": "Desklet background",
61+
+ "tooltip": "Background color for the whole desklet face. Use the alpha slider in the color picker to set transparency - alpha 0 keeps it fully see-through, matching the old behavior."
62+
+ },
63+
"show-background": {
64+
"type": "checkbox",
65+
- "description": "Show background",
66+
- "default": true
67+
+ "description": "Show gauge track",
68+
+ "default": true,
69+
+ "tooltip": "Show a faint ring behind each CPU gauge. This is separate from the desklet background above."
70+
},
71+
"hide-decorations": {
72+
"type": "checkbox",

0 commit comments

Comments
 (0)