Skip to content

Commit 4a89c00

Browse files
authored
[desaturate-all@hkoosha] Add a tooltip showing the next auto action time (#7254)
- Add a Tooltip which will show when the next automatic enable/disable action will occur - Change info.json to set the author to myself (added original_author set to hkoosha) - Add a change log file
1 parent 5b25375 commit 4a89c00

File tree

14 files changed

+387
-31
lines changed

14 files changed

+387
-31
lines changed

desaturate-all@hkoosha/CHANGELOG.md

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Changelog
2+
3+
## 1.1.1
4+
5+
* Added a Tooltip which will show when the next automatic enable/disable action will occur
6+
* Changed info.json to set the author to myself (added original_author set to hkoosha)
7+
* Added this change log file
8+
9+
## 1.1
10+
11+
* Added "bedtime mode" where the user can configure an enable/disable time
12+
* Added an option to restore the previous effect state on Cinnamon startup
13+
* Added the ability to control the saturation amount (gray-scale 0% to 100%)
14+
15+
## 1.0
16+
17+
* Original version

desaturate-all@hkoosha/files/desaturate-all@hkoosha/applet.js

+65-12
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
const Applet = imports.ui.applet;
22
const Lang = imports.lang;
33
const Settings = imports.ui.settings;
4-
const UUID = "desaturate-all@hkoosha";
54
const Clutter = imports.gi.Clutter;
65
const Main = imports.ui.main;
76
const Mainloop = imports.mainloop;
7+
const Gettext = imports.gettext;
8+
const Gio = imports.gi.Gio;
9+
10+
const UUID = "desaturate-all@hkoosha";
11+
12+
function _(str) {
13+
return Gettext.dgettext(UUID, str);
14+
}
815

916
function MyApplet() {
1017
this._init.apply(this, arguments);
@@ -34,6 +41,10 @@ MyApplet.prototype = {
3441
this.settings.connect( "changed::start-timechooser", Lang.bind(this, this.on_time_changed));
3542
this.settings.connect( "changed::end-timechooser", Lang.bind(this, this.on_time_changed));
3643

44+
this.desktop_settings = new Gio.Settings({ schema_id: "org.cinnamon.desktop.interface" });
45+
this.set_applet_tooltip("time"); // initial value so that the show/hide events will occur
46+
this._applet_tooltip._tooltip.connect( "show", Lang.bind(this, this.on_tooltip_shown));
47+
3748
this.on_keybinding_changed();
3849
this.on_saturation_changed();
3950
if (!this.settings.getValue("automatic")) {
@@ -44,6 +55,40 @@ MyApplet.prototype = {
4455
}
4556
},
4657

58+
on_tooltip_shown() {
59+
let ttText;
60+
let effectEnabled = Main.uiGroup.has_effects() && Main.uiGroup.get_effects().indexOf(this.effect) > -1;
61+
if (effectEnabled) {
62+
ttText = _("Click to disable effect");
63+
} else {
64+
ttText = _("Click to desaturate the desktop")
65+
}
66+
if (this.settings.getValue("automatic")) {
67+
let toggleTime = this._get_toggle_time();
68+
let hours = Math.floor(toggleTime.seconds / 60 / 60);
69+
if (hours === 0 ) {
70+
let min = Math.floor((toggleTime.seconds / 60) + 1);
71+
if (toggleTime.enable) {
72+
ttText += "\n" + _("Will automatically desaturate in" );
73+
} else {
74+
ttText += "\n" + _("Will automatically disable in");
75+
}
76+
ttText += ` ${min} ` + _("minutes");
77+
} else {
78+
if (toggleTime.enable) {
79+
ttText += "\n" + _("Will automatically desaturate at") + " ";
80+
} else {
81+
ttText += "\n" + _("Will automatically disable at") + " ";
82+
}
83+
let use_24h = this.desktop_settings.get_boolean("clock-use-24h");
84+
let ttTimeFormat = new Intl.DateTimeFormat(undefined, {hour: "numeric", minute: "2-digit", hour12: !use_24h});
85+
86+
ttText += ttTimeFormat.format(toggleTime.time);
87+
}
88+
}
89+
this.set_applet_tooltip( ttText );
90+
},
91+
4792
_toggleEffect(enable = null) {
4893
let effectEnabled = Main.uiGroup.has_effects() && Main.uiGroup.get_effects().indexOf(this.effect) > -1;
4994
if (enable != true && effectEnabled) {
@@ -55,15 +100,7 @@ MyApplet.prototype = {
55100
}
56101
},
57102

58-
_toggleEffect_based_on_time() {
59-
if (this.toggleDelay) {
60-
Mainloop.source_remove(this.toggleDelay);
61-
this.toggleDelay = null;
62-
}
63-
64-
if (!this.settings.getValue("automatic"))
65-
return;
66-
103+
_get_toggle_time() {
67104
const date = new Date();
68105
const enableAt = new Date();
69106
const disableAt = new Date();
@@ -82,16 +119,32 @@ MyApplet.prototype = {
82119
disableAt.setDate( disableAt.getDate() + 1 );
83120

84121
let enable = (date < disableAt && date >= enableAt);
85-
this._toggleEffect( enable );
86-
87122
let diffTime;
123+
let time;
88124
if (enable) {
89125
diffTime = Math.abs(disableAt - date) / 1000;
126+
time = disableAt;
90127
//log( `Disabling in ${diffTime} seconds` );
91128
} else {
92129
diffTime = Math.abs(enableAt - date) / 1000;
130+
time = enableAt;
93131
//log( `Enabling in ${diffTime} seconds` );
94132
}
133+
return {enable: !enable, seconds: diffTime, time: time};
134+
},
135+
136+
_toggleEffect_based_on_time() {
137+
if (this.toggleDelay) {
138+
Mainloop.source_remove(this.toggleDelay);
139+
this.toggleDelay = null;
140+
}
141+
142+
if (!this.settings.getValue("automatic"))
143+
return;
144+
145+
let toggleTime = this._get_toggle_time();
146+
this._toggleEffect( !toggleTime.enable );
147+
let diffTime = toggleTime.seconds;
95148
this.toggleDelay = Mainloop.timeout_add_seconds(diffTime, () => {this.toggleDelay = null; this._toggleEffect_based_on_time();} );
96149
},
97150

desaturate-all@hkoosha/files/desaturate-all@hkoosha/metadata.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"name": "Desaturate All",
33
"uuid": "desaturate-all@hkoosha",
44
"description": "Convert your screen to gray-scale.",
5-
"version": "1.1"
5+
"version": "1.1.1"
66
}

desaturate-all@hkoosha/files/desaturate-all@hkoosha/po/ca.po

+29-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ msgstr ""
99
"Project-Id-Version: \n"
1010
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-applets/"
1111
"issues\n"
12-
"POT-Creation-Date: 2025-04-27 15:03-0400\n"
12+
"POT-Creation-Date: 2025-05-17 10:44-0400\n"
1313
"PO-Revision-Date: 2025-02-13 20:57+0100\n"
1414
"Last-Translator: Odyssey <odysseyhyd@gmail.com>\n"
1515
"Language-Team: \n"
@@ -19,6 +19,34 @@ msgstr ""
1919
"Content-Transfer-Encoding: 8bit\n"
2020
"X-Generator: Poedit 3.4.2\n"
2121

22+
#. applet.js:62
23+
msgid "Click to disable effect"
24+
msgstr ""
25+
26+
#. applet.js:64
27+
msgid "Click to desaturate the desktop"
28+
msgstr ""
29+
30+
#. applet.js:72
31+
msgid "Will automatically desaturate in"
32+
msgstr ""
33+
34+
#. applet.js:74
35+
msgid "Will automatically disable in"
36+
msgstr ""
37+
38+
#. applet.js:76
39+
msgid "minutes"
40+
msgstr ""
41+
42+
#. applet.js:79
43+
msgid "Will automatically desaturate at"
44+
msgstr ""
45+
46+
#. applet.js:81
47+
msgid "Will automatically disable at"
48+
msgstr ""
49+
2250
#. metadata.json->name
2351
msgid "Desaturate All"
2452
msgstr "Dessaturar Tot"

desaturate-all@hkoosha/files/desaturate-all@hkoosha/po/da.po

+29-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgstr ""
88
"Project-Id-Version: \n"
99
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-applets/"
1010
"issues\n"
11-
"POT-Creation-Date: 2025-04-27 15:03-0400\n"
11+
"POT-Creation-Date: 2025-05-17 10:44-0400\n"
1212
"PO-Revision-Date: 2023-12-28 15:43+0100\n"
1313
"Last-Translator: Alan Mortensen <alanmortensen.am@gmail.com>\n"
1414
"Language-Team: \n"
@@ -19,6 +19,34 @@ msgstr ""
1919
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
2020
"X-Generator: Poedit 3.0.1\n"
2121

22+
#. applet.js:62
23+
msgid "Click to disable effect"
24+
msgstr ""
25+
26+
#. applet.js:64
27+
msgid "Click to desaturate the desktop"
28+
msgstr ""
29+
30+
#. applet.js:72
31+
msgid "Will automatically desaturate in"
32+
msgstr ""
33+
34+
#. applet.js:74
35+
msgid "Will automatically disable in"
36+
msgstr ""
37+
38+
#. applet.js:76
39+
msgid "minutes"
40+
msgstr ""
41+
42+
#. applet.js:79
43+
msgid "Will automatically desaturate at"
44+
msgstr ""
45+
46+
#. applet.js:81
47+
msgid "Will automatically disable at"
48+
msgstr ""
49+
2250
#. metadata.json->name
2351
msgid "Desaturate All"
2452
msgstr "Fjern farver overalt"

desaturate-all@hkoosha/files/desaturate-all@hkoosha/po/de.po

+29-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgstr ""
88
"Project-Id-Version: \n"
99
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-applets/"
1010
"issues\n"
11-
"POT-Creation-Date: 2025-04-27 15:03-0400\n"
11+
"POT-Creation-Date: 2025-05-17 10:44-0400\n"
1212
"PO-Revision-Date: 2024-03-22 22:14+0100\n"
1313
"Last-Translator: Martin Posselt <nekomajin@gmx.de>\n"
1414
"Language-Team: \n"
@@ -19,6 +19,34 @@ msgstr ""
1919
"X-Generator: Poedit 2.3\n"
2020
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
2121

22+
#. applet.js:62
23+
msgid "Click to disable effect"
24+
msgstr ""
25+
26+
#. applet.js:64
27+
msgid "Click to desaturate the desktop"
28+
msgstr ""
29+
30+
#. applet.js:72
31+
msgid "Will automatically desaturate in"
32+
msgstr ""
33+
34+
#. applet.js:74
35+
msgid "Will automatically disable in"
36+
msgstr ""
37+
38+
#. applet.js:76
39+
msgid "minutes"
40+
msgstr ""
41+
42+
#. applet.js:79
43+
msgid "Will automatically desaturate at"
44+
msgstr ""
45+
46+
#. applet.js:81
47+
msgid "Will automatically disable at"
48+
msgstr ""
49+
2250
#. metadata.json->name
2351
msgid "Desaturate All"
2452
msgstr "Alles entsättigen"

desaturate-all@hkoosha/files/desaturate-all@hkoosha/po/desaturate-all@hkoosha.pot

+30-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
#, fuzzy
66
msgid ""
77
msgstr ""
8-
"Project-Id-Version: desaturate-all@hkoosha 1.1\n"
8+
"Project-Id-Version: desaturate-all@hkoosha 1.1.1\n"
99
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-applets/"
1010
"issues\n"
11-
"POT-Creation-Date: 2025-04-27 15:03-0400\n"
11+
"POT-Creation-Date: 2025-05-17 10:44-0400\n"
1212
"PO-Revision-Date: \n"
1313
"Last-Translator: \n"
1414
"Language-Team: \n"
@@ -17,6 +17,34 @@ msgstr ""
1717
"Content-Type: text/plain; charset=UTF-8\n"
1818
"Content-Transfer-Encoding: 8bit\n"
1919

20+
#. applet.js:62
21+
msgid "Click to disable effect"
22+
msgstr ""
23+
24+
#. applet.js:64
25+
msgid "Click to desaturate the desktop"
26+
msgstr ""
27+
28+
#. applet.js:72
29+
msgid "Will automatically desaturate in"
30+
msgstr ""
31+
32+
#. applet.js:74
33+
msgid "Will automatically disable in"
34+
msgstr ""
35+
36+
#. applet.js:76
37+
msgid "minutes"
38+
msgstr ""
39+
40+
#. applet.js:79
41+
msgid "Will automatically desaturate at"
42+
msgstr ""
43+
44+
#. applet.js:81
45+
msgid "Will automatically disable at"
46+
msgstr ""
47+
2048
#. metadata.json->name
2149
msgid "Desaturate All"
2250
msgstr ""

desaturate-all@hkoosha/files/desaturate-all@hkoosha/po/es.po

+35-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgstr ""
88
"Project-Id-Version: \n"
99
"Report-Msgid-Bugs-To: https://github.com/linuxmint/cinnamon-spices-applets/"
1010
"issues\n"
11-
"POT-Creation-Date: 2025-04-27 15:03-0400\n"
11+
"POT-Creation-Date: 2025-05-17 10:44-0400\n"
1212
"PO-Revision-Date: 2025-04-28 16:09-0400\n"
1313
"Last-Translator: \n"
1414
"Language-Team: \n"
@@ -18,6 +18,36 @@ msgstr ""
1818
"Content-Transfer-Encoding: 8bit\n"
1919
"X-Generator: Poedit 3.4.4\n"
2020

21+
#. applet.js:62
22+
msgid "Click to disable effect"
23+
msgstr ""
24+
25+
#. applet.js:64
26+
msgid "Click to desaturate the desktop"
27+
msgstr ""
28+
29+
#. applet.js:72
30+
msgid "Will automatically desaturate in"
31+
msgstr ""
32+
33+
#. applet.js:74
34+
#, fuzzy
35+
msgid "Will automatically disable in"
36+
msgstr "Hora del día para desactivar automáticamente"
37+
38+
#. applet.js:76
39+
msgid "minutes"
40+
msgstr ""
41+
42+
#. applet.js:79
43+
msgid "Will automatically desaturate at"
44+
msgstr ""
45+
46+
#. applet.js:81
47+
#, fuzzy
48+
msgid "Will automatically disable at"
49+
msgstr "Hora del día para desactivar automáticamente"
50+
2151
#. metadata.json->name
2252
msgid "Desaturate All"
2353
msgstr "Desaturar todo"
@@ -43,8 +73,8 @@ msgid ""
4373
"Automatically enable and disable the desaturation effect based on the time "
4474
"of day"
4575
msgstr ""
46-
"Activar y desactivar automáticamente el efecto de desaturación en función "
47-
"de la hora del día"
76+
"Activar y desactivar automáticamente el efecto de desaturación en función de "
77+
"la hora del día"
4878

4979
#. settings-schema.json->start-timechooser->description
5080
msgid "Time of day to automatically enable"
@@ -61,5 +91,5 @@ msgstr "Restaurar el estado del efecto de desaturación al arrancar"
6191
#. settings-schema.json->resume-on-startup->tooltip
6292
msgid "Restore the previously set desaturation state when cinnamon starts"
6393
msgstr ""
64-
"Restaurar el estado de desaturación previamente establecido cuando se "
65-
"inicia Cinnamon"
94+
"Restaurar el estado de desaturación previamente establecido cuando se inicia "
95+
"Cinnamon"

0 commit comments

Comments
 (0)