bar: media actions
This commit is contained in:
parent
b825e97639
commit
379a9d16eb
1 changed files with 29 additions and 22 deletions
|
|
@ -76,34 +76,41 @@ const MediaPlaying = () => {
|
||||||
const getLabel = (fallback = "") =>
|
const getLabel = (fallback = "") =>
|
||||||
players.lastPlayer ? `${players.lastPlayer.title} - ${players.lastPlayer.artist}` : fallback;
|
players.lastPlayer ? `${players.lastPlayer.title} - ${players.lastPlayer.artist}` : fallback;
|
||||||
return (
|
return (
|
||||||
<box
|
<button
|
||||||
className="module media-playing"
|
onClick={(_, event) => {
|
||||||
|
if (event.button === Astal.MouseButton.PRIMARY) {
|
||||||
|
// TODO: media panel
|
||||||
|
} else if (event.button === Astal.MouseButton.SECONDARY) players.lastPlayer?.play_pause();
|
||||||
|
else if (event.button === Astal.MouseButton.MIDDLE) players.lastPlayer?.raise();
|
||||||
|
}}
|
||||||
setup={self => {
|
setup={self => {
|
||||||
const label = Variable(getLabel());
|
const label = Variable(getLabel());
|
||||||
players.hookLastPlayer(self, ["notify::title", "notify::artist"], () => label.set(getLabel()));
|
players.hookLastPlayer(self, ["notify::title", "notify::artist"], () => label.set(getLabel()));
|
||||||
setupCustomTooltip(self, bind(label));
|
setupCustomTooltip(self, bind(label));
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<icon
|
<box className="module media-playing">
|
||||||
setup={self =>
|
<icon
|
||||||
players.hookLastPlayer(self, "notify::identity", () => {
|
setup={self =>
|
||||||
const icon = `caelestia-${players.lastPlayer?.identity.toLowerCase()}-symbolic`;
|
players.hookLastPlayer(self, "notify::identity", () => {
|
||||||
self.icon = players.lastPlayer
|
const icon = `caelestia-${players.lastPlayer?.identity.toLowerCase()}-symbolic`;
|
||||||
? Astal.Icon.lookup_icon(icon)
|
self.icon = players.lastPlayer
|
||||||
? icon
|
? Astal.Icon.lookup_icon(icon)
|
||||||
: "caelestia-media-generic-symbolic"
|
? icon
|
||||||
: "caelestia-media-none-symbolic";
|
: "caelestia-media-generic-symbolic"
|
||||||
})
|
: "caelestia-media-none-symbolic";
|
||||||
}
|
})
|
||||||
/>
|
}
|
||||||
<label
|
/>
|
||||||
setup={self =>
|
<label
|
||||||
players.hookLastPlayer(self, ["notify::title", "notify::artist"], () => {
|
setup={self =>
|
||||||
self.label = ellipsize(getLabel("No media")); // TODO: scroll text
|
players.hookLastPlayer(self, ["notify::title", "notify::artist"], () => {
|
||||||
})
|
self.label = ellipsize(getLabel("No media")); // TODO: scroll text
|
||||||
}
|
})
|
||||||
/>
|
}
|
||||||
</box>
|
/>
|
||||||
|
</box>
|
||||||
|
</button>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue