From 4af990e845aa97bdff8395b7f8218c80d3e73ad2 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Sat, 9 Mar 2024 15:52:23 +0700 Subject: [PATCH] bar music control: bind side button, act immediately on click --- .config/ags/modules/bar/normal/music.js | 10 +++++++--- .config/ags/modules/bar/normal/spaceright.js | 8 ++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.config/ags/modules/bar/normal/music.js b/.config/ags/modules/bar/normal/music.js index d50fa46e6..a14efa74d 100644 --- a/.config/ags/modules/bar/normal/music.js +++ b/.config/ags/modules/bar/normal/music.js @@ -207,9 +207,13 @@ export default () => { return EventBox({ onScrollUp: (self) => switchToRelativeWorkspace(self, -1), onScrollDown: (self) => switchToRelativeWorkspace(self, +1), - onPrimaryClickRelease: () => showMusicControls.setValue(!showMusicControls.value), - onSecondaryClickRelease: () => execAsync(['bash', '-c', 'playerctl next || playerctl position `bc <<< "100 * $(playerctl metadata mpris:length) / 1000000 / 100"` &']).catch(print), - onMiddleClickRelease: () => execAsync('playerctl play-pause').catch(print), + onPrimaryClick: () => showMusicControls.setValue(!showMusicControls.value), + onSecondaryClick: () => execAsync(['bash', '-c', 'playerctl next || playerctl position `bc <<< "100 * $(playerctl metadata mpris:length) / 1000000 / 100"` &']).catch(print), + onMiddleClick: () => execAsync('playerctl play-pause').catch(print), + setup: (self) => self.on('button-press-event', (self, event) => { + if (event.get_button()[1] === 8) // Side button + execAsync('playerctl previous').catch(print) + }), child: Box({ className: 'spacing-h-4', children: [ diff --git a/.config/ags/modules/bar/normal/spaceright.js b/.config/ags/modules/bar/normal/spaceright.js index 8d63e7009..8bca0103f 100644 --- a/.config/ags/modules/bar/normal/spaceright.js +++ b/.config/ags/modules/bar/normal/spaceright.js @@ -71,8 +71,12 @@ export default () => { onHover: () => { barStatusIcons.toggleClassName('bar-statusicons-hover', true) }, onHoverLost: () => { barStatusIcons.toggleClassName('bar-statusicons-hover', false) }, onPrimaryClick: () => App.toggleWindow('sideright'), - onSecondaryClickRelease: () => execAsync(['bash', '-c', 'playerctl next || playerctl position `bc <<< "100 * $(playerctl metadata mpris:length) / 1000000 / 100"` &']).catch(print), - onMiddleClickRelease: () => execAsync('playerctl play-pause').catch(print), + onSecondaryClick: () => execAsync(['bash', '-c', 'playerctl next || playerctl position `bc <<< "100 * $(playerctl metadata mpris:length) / 1000000 / 100"` &']).catch(print), + onMiddleClick: () => execAsync('playerctl play-pause').catch(print), + setup: (self) => self.on('button-press-event', (self, event) => { + if (event.get_button()[1] === 8) + execAsync('playerctl previous').catch(print) + }), child: Widget.Box({ homogeneous: false, children: [