diff --git a/modules/dock/components/__init__.py b/modules/dock/components/__init__.py index 25236e0..66ac421 100644 --- a/modules/dock/components/__init__.py +++ b/modules/dock/components/__init__.py @@ -183,6 +183,11 @@ class DockComponents(Box): # Battery component manages its own visibility based on config and battery presence # Don't override its visibility here, let it handle it internally pass + # Special handling for music player - let it manage its own visibility based on media content + elif component_name == "music_player": + # Music player component manages its own visibility based on config and media presence + # Don't override its visibility here, let it handle it internally + pass else: widget.set_visible(visibility) diff --git a/modules/dock/components/indicators.py b/modules/dock/components/indicators.py index 305ad94..294daca 100644 --- a/modules/dock/components/indicators.py +++ b/modules/dock/components/indicators.py @@ -195,8 +195,8 @@ class RecordingIndicator(Button): self.hide() - self.check_recording_status() - self.timeout_id = GLib.timeout_add(1000, self.check_recording_status) + # Delay initial check to prevent showing during dock initialization + GLib.timeout_add(1000, self._delayed_init) def check_recording_status(self): try: @@ -250,6 +250,15 @@ class RecordingIndicator(Button): except Exception as e: print(f"Error stopping recording: {e}") + def _delayed_init(self): + """Initialize recording status check after a delay to prevent showing during dock startup""" + try: + self.check_recording_status() + self.timeout_id = GLib.timeout_add(1000, self.check_recording_status) + except Exception as e: + print(f"[DEBUG] Error in delayed recording indicator init: {e}") + return False # Don't repeat this timeout + def cleanup(self): if hasattr(self, "timeout_id"): GLib.source_remove(self.timeout_id) diff --git a/modules/dock/components/music_player.py b/modules/dock/components/music_player.py index 8938770..38eaa43 100644 --- a/modules/dock/components/music_player.py +++ b/modules/dock/components/music_player.py @@ -152,11 +152,11 @@ class MusicPlayer(Box): # Popup window will be created on-demand self.popup = None - # Initialize players - self.manager.init_all_players() + # Initialize players with delayed visibility check + GLib.timeout_add(500, self._delayed_init) - # Set initial visibility - self.update_visibility() + # Hide initially - will show only when media players are detected + self.hide() # Set up periodic check for active player self.active_player_check_timeout = GLib.timeout_add_seconds( @@ -378,6 +378,15 @@ class MusicPlayer(Box): # Return True to continue the timeout return True + def _delayed_init(self): + """Initialize players after a delay to prevent showing during dock startup""" + try: + self.manager.init_all_players() + self.update_visibility() + except Exception as e: + print(f"[DEBUG] Error in delayed music player init: {e}") + return False # Don't repeat this timeout + def _try_switch_to_alternative_player(self, current_time): """Try to switch to an alternative player when current is paused/invalid""" try: @@ -727,12 +736,13 @@ class MusicPlayer(Box): def update_visibility(self): """Update component visibility based on players with actual media content""" - # Show component only if there are players with actual media content - has_media_players = self.has_running_players() - self.set_visible(has_media_players) - - # Hide in vertical mode if user preference is set - if data.VERTICAL and hasattr(data, "DOCK_COMPONENTS_VISIBILITY"): + # Check if music player is enabled in configuration + if hasattr(data, "DOCK_COMPONENTS_VISIBILITY"): music_visible = data.DOCK_COMPONENTS_VISIBILITY.get("music_player", True) if not music_visible: self.set_visible(False) + return + + # Show component only if there are players with actual media content + has_media_players = self.has_running_players() + self.set_visible(has_media_players)