Skip to content

Notch player overlay mode #166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 31 additions & 15 deletions modules/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,9 @@ class PlayerSmall(CenterBox):
def __init__(self):
super().__init__(name="player-small", orientation="h", h_align="fill", v_align="center")
self._show_artist = False
self._display_options = ["cavalcade", "title", "artist"]
self._display_options = ["cavalcade", "title", "artist", "overlay"]
self._display_index = 0
self._current_display = "cavalcade"
self._current_display = "overlay"

self.mpris_icon = Button(
name="compact-mpris-icon",
Expand Down Expand Up @@ -528,18 +528,29 @@ def __init__(self):
self.cavalcade = SpectrumRender()
self.cavalcade_box = self.cavalcade.get_spectrum_box()

self.center_stack = Stack(
name="compact-mpris",
transition_type="crossfade",
transition_duration=100,
v_align="center",
v_expand=False,
children=[
self.cavalcade_box,
self.mpris_label,
]
)
self.center_stack.set_visible_child(self.cavalcade_box)
if self._current_display != "overlay":
self.center_stack = Stack(
name="compact-mpris",
transition_type="crossfade",
transition_duration=100,
v_align="center",
v_expand=False,
children=[
self.cavalcade_box,
self.mpris_label,
],
)
self.center_stack.set_visible_child(self.cavalcade_box)
self.center = self.center_stack
else:
self.center_overlay = Gtk.Overlay()
self.center_overlay.set_halign(Gtk.Align.CENTER)
self.center_overlay.set_valign(Gtk.Align.CENTER)

self.center_overlay.add(self.cavalcade_box) # background
self.center_overlay.add_overlay(self.mpris_label) # foreground
self.cavalcade_box.set_style("opacity: 0.6") # change opacity of the box
self.center = self.center_overlay

self.mpris_small = CenterBox(
name="compact-mpris",
Expand All @@ -549,7 +560,7 @@ def __init__(self):
v_align="center",
v_expand=False,
start_children=self.mpris_icon,
center_children=self.center_stack,
center_children=self.center,
end_children=self.mpris_button,
)

Expand Down Expand Up @@ -578,6 +589,8 @@ def _apply_mpris_properties(self):
self.mpris_label.set_text("Nothing Playing")
self.mpris_button.get_child().set_markup(icons.stop)
self.mpris_icon.get_child().set_markup(icons.disc)
if self._current_display == "overlay":
return
if self._current_display != "cavalcade":
self.center_stack.set_visible_child(self.mpris_label)
else:
Expand All @@ -599,6 +612,9 @@ def _apply_mpris_properties(self):
text = (mp.artist if mp.artist else "Nothing Playing")
self.mpris_label.set_text(text)
self.center_stack.set_visible_child(self.mpris_label)
elif self._current_display == "overlay":
text = (mp.title if mp.title and mp.title.strip() else "Nothing Playing")
self.mpris_label.set_text(text)
else:
self.center_stack.set_visible_child(self.cavalcade_box)

Expand Down