music controls actions (#172)

This commit is contained in:
end-4 2024-01-05 08:22:39 +07:00
parent 92d98a1a43
commit 26a0e34b8b
3 changed files with 10 additions and 6 deletions

View file

@ -30,12 +30,12 @@ const TrackProgress = () => {
}) })
} }
export const ModuleMusic = () => Widget.EventBox({ export const ModuleMusic = () => Widget.EventBox({ // TODO: use cairo to make button bounce smaller on click
onScrollUp: () => Hyprland.sendMessage(`dispatch workspace -1`), onScrollUp: () => Hyprland.sendMessage(`dispatch workspace -1`),
onScrollDown: () => Hyprland.sendMessage(`dispatch workspace +1`), onScrollDown: () => Hyprland.sendMessage(`dispatch workspace +1`),
onPrimaryClickRelease: () => showMusicControls.setValue(!showMusicControls.value), onPrimaryClickRelease: () => showMusicControls.setValue(!showMusicControls.value),
onSecondaryClickRelease: () => execAsync(['bash', '-c', 'playerctl next || playerctl position `bc <<< "100 * $(playerctl metadata mpris:length) / 1000000 / 100"` &']), onSecondaryClickRelease: () => execAsync(['bash', '-c', 'playerctl next || playerctl position `bc <<< "100 * $(playerctl metadata mpris:length) / 1000000 / 100"` &']),
onMiddleClickRelease: () => Mpris.getPlayer('')?.playPause(), onMiddleClickRelease: () => execAsync('playerctl play-pause').catch(print),
child: Widget.Box({ child: Widget.Box({
className: 'bar-group-margin bar-sides', className: 'bar-group-margin bar-sides',
children: [ children: [

View file

@ -200,6 +200,7 @@ const TrackControls = ({ player, ...rest }) => Widget.Revealer({
children: [ children: [
Button({ Button({
className: 'osd-music-controlbtn', className: 'osd-music-controlbtn',
onClicked: () => execAsync('playerctl previous').catch(print),
child: Label({ child: Label({
className: 'icon-material osd-music-controlbtn-txt', className: 'icon-material osd-music-controlbtn-txt',
label: 'skip_previous', label: 'skip_previous',
@ -207,6 +208,9 @@ const TrackControls = ({ player, ...rest }) => Widget.Revealer({
}), }),
Button({ Button({
className: 'osd-music-controlbtn', className: 'osd-music-controlbtn',
onClicked: () => execAsync(['bash', '-c', 'playerctl next || playerctl position `bc <<< "100 * $(playerctl metadata mpris:length) / 1000000 / 100"`'])
.catch(print)
,
child: Label({ child: Label({
className: 'icon-material osd-music-controlbtn-txt', className: 'icon-material osd-music-controlbtn-txt',
label: 'skip_next', label: 'skip_next',
@ -297,9 +301,7 @@ const PlayState = ({ player }) => {
overlays: [ overlays: [
Widget.Button({ Widget.Button({
className: 'osd-music-playstate-btn', className: 'osd-music-playstate-btn',
onClicked: () => { onClicked: () => { console.log('uwu'); execAsync('playerctl play-pause').catch(print) },
Mpris.getPlayer().playPause()
},
child: Widget.Label({ child: Widget.Label({
justification: 'center', justification: 'center',
hpack: 'fill', hpack: 'fill',
@ -380,7 +382,7 @@ export default () => MarginRevealer({
}), }),
connections: [ connections: [
[showMusicControls, (revealer) => { [showMusicControls, (revealer) => {
if(showMusicControls.value) revealer._show(); if (showMusicControls.value) revealer._show();
else revealer._hide(); else revealer._hide();
}], }],
], ],

View file

@ -23,6 +23,7 @@ export const ToggleIconWifi = (props = {}) => Widget.Button({
onClicked: Network.toggleWifi, onClicked: Network.toggleWifi,
onSecondaryClickRelease: () => { onSecondaryClickRelease: () => {
execAsync(['bash', '-c', 'XDG_CURRENT_DESKTOP="gnome" gnome-control-center wifi', '&']); execAsync(['bash', '-c', 'XDG_CURRENT_DESKTOP="gnome" gnome-control-center wifi', '&']);
App.closeWindow('sideright');
}, },
child: NetworkIndicator(), child: NetworkIndicator(),
connections: [ connections: [
@ -49,6 +50,7 @@ export const ToggleIconBluetooth = (props = {}) => Widget.Button({
}, },
onSecondaryClickRelease: () => { onSecondaryClickRelease: () => {
execAsync(['bash', '-c', 'blueberry &']); execAsync(['bash', '-c', 'blueberry &']);
App.closeWindow('sideright');
}, },
child: BluetoothIndicator(), child: BluetoothIndicator(),
connections: [ connections: [