Skip to content

Commit 681a6f5

Browse files
authored
sound150 v9.0.0: Major changes for OSD and menu (#6832)
1 parent ea967f4 commit 681a6f5

File tree

4 files changed

+118
-47
lines changed

4 files changed

+118
-47
lines changed

sound150@claudiux/files/sound150@claudiux/6.4/applet.js

Lines changed: 97 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ const MEDIA_PLAYER_2_PATH = "/org/mpris/MediaPlayer2";
4646
const MEDIA_PLAYER_2_NAME = "org.mpris.MediaPlayer2";
4747
const MEDIA_PLAYER_2_PLAYER_NAME = "org.mpris.MediaPlayer2.Player";
4848

49+
var SHOW_MEDIA_OPTICAL = true;
50+
4951
const COVERBOX_LAYOUT_MANAGER = new Clutter.BinLayout({
5052
x_align: Clutter.BinAlignment.FILL,
5153
y_align: Clutter.BinAlignment.END
@@ -63,6 +65,8 @@ const R30MPVSOCKET = RUNTIME_DIR + "/mpvradiosocket";
6365
// how long to show the output icon when volume is adjusted during media playback.
6466
const OUTPUT_ICON_SHOW_TIME_SECONDS = 3;
6567

68+
var OSD_HORIZONTAL = false;
69+
6670
function run_playerctld() {
6771
Util.spawnCommandLineAsync("bash -C '"+ PATH2SCRIPTS +"/run_playerctld.sh'");
6872
}
@@ -75,6 +79,21 @@ Main.osdWindowManager._showOsdWindow = function(monitorIndex, icon, label, level
7579
if (maxLevel>1.5) maxLevel=1.5;
7680
else if (maxLevel < 0.3) maxLevel=0.3;
7781

82+
this._osdWindows[monitorIndex]._vbox.remove_all_children();
83+
this._osdWindows[monitorIndex]._hbox.remove_all_children();
84+
85+
this._osdWindows[monitorIndex]._hbox.add_child(this._osdWindows[monitorIndex]._icon);
86+
this._osdWindows[monitorIndex]._hbox.add_child(this._osdWindows[monitorIndex]._vbox);
87+
if (!OSD_HORIZONTAL) {
88+
this._osdWindows[monitorIndex]._label.y_align = Clutter.ActorAlign.FILL;
89+
this._osdWindows[monitorIndex]._vbox.add_child(this._osdWindows[monitorIndex]._label);
90+
} else {
91+
this._osdWindows[monitorIndex]._label.y_align = Clutter.ActorAlign.CENTER;
92+
this._osdWindows[monitorIndex]._hbox.add_child(this._osdWindows[monitorIndex]._label);
93+
}
94+
this._osdWindows[monitorIndex]._level.maximum_value = maxLevel;
95+
this._osdWindows[monitorIndex]._vbox.add_child(this._osdWindows[monitorIndex]._level);
96+
7897
this._osdWindows[monitorIndex].setIcon(icon);
7998
this._osdWindows[monitorIndex].setLabel(label);
8099
this._osdWindows[monitorIndex].setMaxLevel(maxLevel);
@@ -275,6 +294,7 @@ class ControlButton {
275294

276295
class VolumeSlider extends PopupMenu.PopupSliderMenuItem {
277296
constructor(applet, stream, tooltip, app_icon) {
297+
logDebug("VolumeSlider constructor tooltip: "+tooltip);
278298
const startLevel = (tooltip == _("Microphone")) ? 1*applet.mic_level.slice(0, -1) : 1*applet.volume.slice(0, -1);
279299
super(startLevel);
280300
this.oldValue = startLevel;
@@ -318,13 +338,17 @@ class VolumeSlider extends PopupMenu.PopupSliderMenuItem {
318338
() => {
319339
let muted = false;
320340
if (this._value) this.oldValue = this._value;
321-
if (this.applet.get_stage() != null) {
341+
if (this.applet.actor.get_stage() != null) {
322342
if (this.isMic) {
323-
this.applet.mute_in_switch.setToggleState(!this.applet.mute_in_switch.state);
324-
if (this.applet.mute_in_switch.state) muted = true;
343+
if (this.applet.mute_in_switch) {
344+
this.applet.mute_in_switch.setToggleState(!this.applet.mute_in_switch.state);
345+
if (this.applet.mute_in_switch.state) muted = true;
346+
}
325347
} else {
326-
this.applet.mute_out_switch.setToggleState(!this.applet.mute_out_switch.state);
327-
if (this.applet.mute_out_switch.state) muted = true;
348+
if (this.applet.mute_out_switch) {
349+
this.applet.mute_out_switch.setToggleState(!this.applet.mute_out_switch.state);
350+
if (this.applet.mute_out_switch.state) muted = true;
351+
}
328352
}
329353
}
330354
if (muted) {
@@ -409,13 +433,15 @@ class VolumeSlider extends PopupMenu.PopupSliderMenuItem {
409433

410434
let _bar_level = null;
411435
let _volume_str = "";
436+
let rounded_volume = Math.round(volume/this.applet._volumeNorm * 100);
412437
if (this.applet.showVolumeValue === true)
413-
_volume_str = ""+Math.round(volume/this.applet._volumeNorm * 100)+PERCENT_CHAR;
438+
_volume_str = ""+rounded_volume+PERCENT_CHAR;
414439
if (this.applet.showBarLevel === true)
415-
_bar_level = Math.round(volume/this.applet._volumeNorm * 100);
440+
_bar_level = rounded_volume;
416441
let _maxLevel = Math.round(this.applet._volumeMax/this.applet._volumeNorm * 100) / 100;
442+
OSD_HORIZONTAL = this.OSDhorizontal;
417443

418-
if (this.applet.showOSD && Math.round(volume/this.applet._volumeNorm * 100) != Math.round(this.oldValue)) {
444+
if (this.applet.showOSD && rounded_volume != Math.round(this.oldValue)) {
419445
Main.osdWindowManager.show(-1, icon, _volume_str, _bar_level, _maxLevel);
420446
}
421447

@@ -1144,6 +1170,11 @@ class Player extends PopupMenu.PopupMenuSection {
11441170
});
11451171
this.coverBox.add_actor(this.cover);
11461172

1173+
if (SHOW_MEDIA_OPTICAL)
1174+
this.cover.show();
1175+
else
1176+
this.cover.hide();
1177+
11471178
this._cover_load_handle = 0;
11481179
this._cover_path = null;
11491180

@@ -1840,22 +1871,24 @@ class Sound150Applet extends Applet.TextIconApplet {
18401871
this.startingUp = true;
18411872

18421873
this.settings = new Settings.AppletSettings(this, UUID, instanceId);
1874+
this.settings.bind("showMediaOptical", "showMediaOptical", () => {
1875+
SHOW_MEDIA_OPTICAL = this.showMediaOptical;
1876+
this._on_reload_this_applet_pressed();
1877+
});
1878+
SHOW_MEDIA_OPTICAL = this.showMediaOptical;
1879+
18431880
this.settings.bind("muteSoundOnClosing", "muteSoundOnClosing");
18441881
this.settings.bind("startupVolume", "startupVolume");
18451882
this.settings.bind("showOSDonStartup", "showOSDonStartup");
18461883
this.settings.bind("showPercent", "showPercent", () => {
1847-
if (this.showPercent)
1848-
PERCENT_CHAR = _("%");
1849-
else
1850-
PERCENT_CHAR = "";
1884+
PERCENT_CHAR = (this.showPercent) ? _("%") : "";
18511885
});
1852-
if (this.showPercent)
1853-
PERCENT_CHAR = _("%");
1854-
else
1855-
PERCENT_CHAR = "";
1886+
PERCENT_CHAR = (this.showPercent) ? _("%") : "";
18561887

18571888
this.settings.bind("showBarLevel", "showBarLevel");
18581889
this.settings.bind("showVolumeValue", "showVolumeValue");
1890+
this.settings.bind("OSDhorizontal","OSDhorizontal");
1891+
OSD_HORIZONTAL = this.OSDhorizontal;
18591892

18601893
this.settings.bind("seekerTooltipDelay", "seekerTooltipDelay");
18611894
this.settings.bind("soundATcinnamonDOTorg_is_loaded", "soundATcinnamonDOTorg_is_loaded");
@@ -1954,6 +1987,17 @@ class Sound150Applet extends Applet.TextIconApplet {
19541987

19551988
this.set_applet_icon_symbolic_name("audio-x-generic");
19561989

1990+
this.mute_out_switch = new PopupMenu.PopupSwitchIconMenuItem(_("Mute output"), false, "audio-volume-muted-symbolic", St.IconType.SYMBOLIC);
1991+
this.mute_in_switch = new PopupMenu.PopupSwitchIconMenuItem(_("Mute input"), false, "microphone-sensitivity-muted-symbolic", St.IconType.SYMBOLIC);
1992+
this._applet_context_menu.addMenuItem(this.mute_out_switch);
1993+
this._applet_context_menu.addMenuItem(this.mute_in_switch);
1994+
if (this.alwaysCanChangeMic)
1995+
this.mute_in_switch.actor.show();
1996+
else
1997+
this.mute_in_switch.actor.hide();
1998+
1999+
this._applet_context_menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
2000+
19572001
this._players = {};
19582002
this._playerItems = [];
19592003
this._activePlayer = null;
@@ -2031,17 +2075,6 @@ class Sound150Applet extends Applet.TextIconApplet {
20312075
this.actor.connect("scroll-event", (...args) => this._onScrollEvent(...args));
20322076
this.actor.connect("key-press-event", (...args) => this._onKeyPressEvent(...args));
20332077

2034-
this.mute_out_switch = new PopupMenu.PopupSwitchIconMenuItem(_("Mute output"), false, "audio-volume-muted-symbolic", St.IconType.SYMBOLIC);
2035-
this.mute_in_switch = new PopupMenu.PopupSwitchIconMenuItem(_("Mute input"), false, "microphone-sensitivity-muted-symbolic", St.IconType.SYMBOLIC);
2036-
this._applet_context_menu.addMenuItem(this.mute_out_switch);
2037-
this._applet_context_menu.addMenuItem(this.mute_in_switch);
2038-
if (!this.alwaysCanChangeMic)
2039-
this.mute_in_switch.actor.hide();
2040-
else
2041-
this.mute_in_switch.actor.show();
2042-
2043-
this._applet_context_menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
2044-
20452078
this._outputApplicationsMenu = new PopupMenu.PopupSubMenuMenuItem(_("Applications"));
20462079
this._selectOutputDeviceItem = new PopupMenu.PopupSubMenuMenuItem(_("Output device"));
20472080
this._applet_context_menu.addMenuItem(this._outputApplicationsMenu);
@@ -2077,6 +2110,12 @@ class Sound150Applet extends Applet.TextIconApplet {
20772110
this._applet_context_menu.addMenuItem(this.context_menu_item_pulseEffects);
20782111
}
20792112

2113+
// button Reload this applet
2114+
this._applet_context_menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
2115+
let _reload_button = new PopupMenu.PopupIconMenuItem(_("Reload this applet"), "restart", St.IconType.SYMBOLIC);
2116+
_reload_button.connect("activate", (event) => this._on_reload_this_applet_pressed());
2117+
this._applet_context_menu.addMenuItem(_reload_button);
2118+
20802119
this._showFixedElements();
20812120

20822121
this.mute_out_switch.connect("toggled", () => this._toggle_out_mute());
@@ -2353,17 +2392,18 @@ class Sound150Applet extends Applet.TextIconApplet {
23532392

23542393
this._iconLooping = true;
23552394

2356-
//~ if (this._output && this._output.is_muted) {
2357-
//~ this.old_volume = this.volume;
2358-
//~ this._toggle_out_mute();
2359-
//~ this.volume = this.old_volume;
2360-
//~ }
2395+
if (this._output && this._output.is_muted) {
2396+
this.old_volume = this.volume;
2397+
this._toggle_out_mute();
2398+
this.volume = this.old_volume;
2399+
}
23612400

23622401
this._on_sound_settings_change();
23632402

23642403
this._loopArtId = null;
23652404
this._artLooping = true;
2366-
this._loopArtId = timeout_add_seconds(5, this.loopArt.bind(this));
2405+
//~ this._loopArtId = timeout_add_seconds(5, this.loopArt.bind(this));
2406+
this._loopArtId = timeout_add_seconds(5, () => { this.loopArt() });
23672407
//~ this.loopArt();
23682408

23692409
this.volume_near_icon();
@@ -2388,12 +2428,7 @@ class Sound150Applet extends Applet.TextIconApplet {
23882428
this._iconLooping = false;
23892429
this._artLooping = false;
23902430
this.startingUp = true;
2391-
if (this.muteSoundOnClosing && this._output && !this._output.is_muted) {
2392-
this.old_volume = this.volume;
2393-
this._toggle_out_mute();
2394-
this.volume = this.old_volume;
2395-
}
2396-
//~ logDebug("Output is now muted");
2431+
23972432

23982433
if (this.actor && (this.actor.get_stage() != null) && this._control && (this._control.get_state() != Cvc.MixerControlState.CLOSED)) {
23992434
try {
@@ -2417,6 +2452,17 @@ class Sound150Applet extends Applet.TextIconApplet {
24172452
//logDebug("_control closed");
24182453
//}
24192454

2455+
logDebug("this.volume: "+this.volume);
2456+
let old_volume = this.volume;
2457+
if (this.muteSoundOnClosing && this._output && !this._output.is_muted) {
2458+
this.old_volume = this.volume;
2459+
this._toggle_out_mute();
2460+
logDebug("this.volume: "+this.volume);
2461+
this.volume = this.old_volume;
2462+
logDebug("Output is now muted");
2463+
}
2464+
logDebug("this.volume: "+this.volume);
2465+
24202466
Main.keybindingManager.removeHotKey("sound-open-" + this.instance_id);
24212467
Main.keybindingManager.removeHotKey("switch-player-" + this.instance_id);
24222468
try {
@@ -2469,7 +2515,15 @@ class Sound150Applet extends Applet.TextIconApplet {
24692515
this._control.close();
24702516

24712517
kill_playerctld();
2518+
2519+
2520+
logDebug("old_volume: "+old_volume);
2521+
//~ this.volume = old_volume;
2522+
this.settings.setValue("volume", old_volume);
2523+
//~ setTimeout(() => { this.volume = old_volume; logDebug("this.volume: "+this.volume); }, 2100);
24722524
remove_all_sources();
2525+
//~ logDebug("old_volume: "+old_volume);
2526+
//~ this.volume = old_volume;
24732527
//~ logDebug("playerctld killed");
24742528
//~ logDebug("on_applet_removed_from_panel() END");
24752529
}
@@ -2529,6 +2583,7 @@ class Sound150Applet extends Applet.TextIconApplet {
25292583
_volume_str = ""+volume+PERCENT_CHAR
25302584
if (this.showBarLevel === true)
25312585
_bar_level = volume;
2586+
OSD_HORIZONTAL = this.OSDhorizontal;
25322587

25332588
Main.osdWindowManager.show(-1, icon, _volume_str, _bar_level, _maxLevel);
25342589
}
@@ -2563,6 +2618,7 @@ class Sound150Applet extends Applet.TextIconApplet {
25632618
_volume_str = ""+volume+PERCENT_CHAR
25642619
if (this.showBarLevel === true)
25652620
_bar_level = volume;
2621+
OSD_HORIZONTAL = this.OSDhorizontal;
25662622
Main.osdWindowManager.show(-1, icon, _volume_str, _bar_level, _maxLevel);
25672623
}
25682624
}
@@ -2709,6 +2765,7 @@ class Sound150Applet extends Applet.TextIconApplet {
27092765
if (this.showBarLevel === true)
27102766
_bar_level = volume;
27112767
let _maxLevel = Math.round(this._volumeMax/this._volumeNorm * 100) / 100;
2768+
OSD_HORIZONTAL = this.OSDhorizontal;
27122769
if (this.showOSD && (this.showOSDonStartup || volume != parseInt(this.old_volume.slice(0, -1)))) {
27132770
//~ Main.osdWindowManager.hideAll();
27142771
try {
@@ -3132,11 +3189,6 @@ class Sound150Applet extends Applet.TextIconApplet {
31323189

31333190
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
31343191

3135-
// button Reload this applet
3136-
let _reload_button = new PopupMenu.PopupIconMenuItem(_("Reload this applet"), "restart", St.IconType.SYMBOLIC);
3137-
_reload_button.connect("activate", (event) => this._on_reload_this_applet_pressed());
3138-
this.menu.addMenuItem(_reload_button);
3139-
31403192
// button "remove_soundATcinnamonDOTorg"
31413193
if (this.soundATcinnamonDOTorg_is_loaded) {
31423194
let _remove_soundATcinnamonDOTorg_button = new PopupMenu.PopupIconMenuItem(_("Remove sound applet"), "edit-delete", St.IconType.SYMBOLIC);
@@ -3507,8 +3559,8 @@ class Sound150Applet extends Applet.TextIconApplet {
35073559
this.menu.close();
35083560
// Reload this applet
35093561
let to = setTimeout( () => {
3510-
Extension.reloadExtension(UUID, Extension.Type.APPLET);
35113562
clearTimeout(to);
3563+
Extension.reloadExtension(UUID, Extension.Type.APPLET);
35123564
},
35133565
300);
35143566
}

sound150@claudiux/files/sound150@claudiux/6.4/settings-schema.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
"keepPlayerListOpen",
5252
"keepChoosePlayerOpen",
5353
"avoidTwice",
54-
"seekerTooltipDelay"
54+
"seekerTooltipDelay",
55+
"showMediaOptical"
5556
]
5657
},
5758
"sectionBehavior2": {
@@ -129,6 +130,7 @@
129130
"showOSDonStartup",
130131
"showVolumeValue",
131132
"showPercent",
133+
"OSDhorizontal",
132134
"showBarLevel"
133135
]
134136
},
@@ -202,6 +204,11 @@
202204
"step": 50,
203205
"description": "Seeker tooltip: time to disappear"
204206
},
207+
"showMediaOptical": {
208+
"type": "switch",
209+
"default": true,
210+
"description": "Show Media-Optical icon"
211+
},
205212
"keyOpen": {
206213
"type": "keybinding",
207214
"description": "Show menu",
@@ -441,6 +448,12 @@
441448
"description": "Show '%' in OSD",
442449
"default": false
443450
},
451+
"OSDhorizontal": {
452+
"type": "switch",
453+
"dependency": "showMediaKeysOSD",
454+
"description": "Show horizontal OSD",
455+
"default": false
456+
},
444457
"showBarLevel": {
445458
"type": "switch",
446459
"dependency": "showMediaKeysOSD",

sound150@claudiux/files/sound150@claudiux/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### v9.0.0~20250201
2+
* Major changes for OSD and menu.
3+
* OSD: Volume value can be displayed beside the volume bar.
4+
* New option for the menu: Show Media-Optical icon. Don't show it to save space and visual comfort.
5+
* Fixes #6830.
6+
17
### v8.0.3~20250130
28
* Improved OSD management.
39
* Fixes #6820.

sound150@claudiux/files/sound150@claudiux/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"max-instances": "1",
66
"description": "Enhanced sound applet",
77
"hide-configuration": false,
8-
"version": "8.0.3",
8+
"version": "9.0.0",
99
"cinnamon-version": [
1010
"2.8",
1111
"3.0",

0 commit comments

Comments
 (0)