From 61ce2aec25fb501d391dff2ed48e8844aa0f8f36 Mon Sep 17 00:00:00 2001 From: endotrizine Date: Tue, 19 Nov 2024 08:10:37 +0500 Subject: [PATCH 1/4] New feature: adjust music volume by scrolling the music widget up/down --- .config/ags/modules/bar/normal/music.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.config/ags/modules/bar/normal/music.js b/.config/ags/modules/bar/normal/music.js index 35fb8288d..99cdb589c 100644 --- a/.config/ags/modules/bar/normal/music.js +++ b/.config/ags/modules/bar/normal/music.js @@ -26,6 +26,22 @@ function trimTrackTitle(title) { return title; } +function adjustVolume(direction) { + const step = 0.03; + execAsync(['playerctl', 'volume']) + .then((output) => { + let currentVolume = parseFloat(output.trim()); + let newVolume = direction === 'up' ? currentVolume + step : currentVolume - step; + + if (newVolume > 1.0) newVolume = 1.0; + if (newVolume < 0.0) newVolume = 0.0; + + execAsync(['playerctl', 'volume', newVolume.toFixed(2)]).catch(print); + }) + .catch(print); +} + + const BarGroup = ({ child }) => Box({ className: 'bar-group-margin bar-sides', children: [ @@ -105,6 +121,8 @@ const switchToRelativeWorkspace = async (self, num) => { } } + + export default () => { // TODO: use cairo to make button bounce smaller on click, if that's possible const playingState = Box({ // Wrap a box cuz overlay can't have margins itself @@ -208,8 +226,8 @@ export default () => { }); } return EventBox({ - onScrollUp: (self) => switchToRelativeWorkspace(self, -1), - onScrollDown: (self) => switchToRelativeWorkspace(self, +1), + onScrollUp: () => adjustVolume('up'), + onScrollDown: () => adjustVolume('down'), child: Box({ className: 'spacing-h-4', children: [ @@ -228,3 +246,4 @@ export default () => { }) }); } + From 1ebae52b65413694c82627dc53cf311f91e09532 Mon Sep 17 00:00:00 2001 From: endotrizine Date: Thu, 21 Nov 2024 06:23:46 +0500 Subject: [PATCH 2/4] Added script and keybind to adjust volume --- .config/ags/scripts/music/adjust-volume.sh | 15 +++++++++++++++ .config/hypr/hyprland/keybinds.conf | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100755 .config/ags/scripts/music/adjust-volume.sh diff --git a/.config/ags/scripts/music/adjust-volume.sh b/.config/ags/scripts/music/adjust-volume.sh new file mode 100755 index 000000000..dce141997 --- /dev/null +++ b/.config/ags/scripts/music/adjust-volume.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +change=$1 + +current_volume=$(playerctl volume) + +new_volume=$(echo "$current_volume + $change" | bc) + +if (( $(echo "$new_volume > 1.0" | bc -l) )); then + new_volume=1.0 +elif (( $(echo "$new_volume < 0.0" | bc -l) )); then + new_volume=0.0 +fi + +playerctl volume "$new_volume" diff --git a/.config/hypr/hyprland/keybinds.conf b/.config/hypr/hyprland/keybinds.conf index 005bf09bb..e7a7d32c9 100644 --- a/.config/hypr/hyprland/keybinds.conf +++ b/.config/hypr/hyprland/keybinds.conf @@ -177,9 +177,10 @@ bind = Super+Alt, f12, exec, notify-send 'Test notification' "Here's a really lo bind = Super+Alt, Equal, exec, notify-send "Urgent notification" "Ah hell no" -u critical -a 'Hyprland keybind' # [hidden] ##! Media -bindl= Super+Shift, N, exec, playerctl next || playerctl position `bc <<< "100 * $(playerctl metadata mpris:length) / 1000000 / 100"` # Next track bindl= ,XF86AudioNext, exec, playerctl next || playerctl position `bc <<< "100 * $(playerctl metadata mpris:length) / 1000000 / 100"` # [hidden] bindl= ,XF86AudioPrev, exec, playerctl previous # [hidden] +bindl = Super+Shift, Comma, exec, ~/.config/ags/scripts/music/adjust-volume.sh -0.03 # Raise music volume +bindl = Super+Shift, Period, exec, ~/.config/ags/scripts/music/adjust-volume.sh 0.03 # Lower music volume bind = Super+Shift+Alt, mouse:275, exec, playerctl previous # [hidden] bind = Super+Shift+Alt, mouse:276, exec, playerctl next || playerctl position `bc <<< "100 * $(playerctl metadata mpris:length) / 1000000 / 100"` # [hidden] bindl= Super+Shift, B, exec, playerctl previous # Previous track From 2b7ca5b070df5b87cd641d2c0ad813813a594d35 Mon Sep 17 00:00:00 2001 From: endotrizine Date: Thu, 21 Nov 2024 06:26:01 +0500 Subject: [PATCH 3/4] =?UTF-8?q?for=20some=20reason=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B5=D0=B1=D0=B0=D0=BB=20next=20track=20keybind?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/hypr/hyprland/keybinds.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/.config/hypr/hyprland/keybinds.conf b/.config/hypr/hyprland/keybinds.conf index e7a7d32c9..503e594a5 100644 --- a/.config/hypr/hyprland/keybinds.conf +++ b/.config/hypr/hyprland/keybinds.conf @@ -177,6 +177,7 @@ bind = Super+Alt, f12, exec, notify-send 'Test notification' "Here's a really lo bind = Super+Alt, Equal, exec, notify-send "Urgent notification" "Ah hell no" -u critical -a 'Hyprland keybind' # [hidden] ##! Media +bindl= Super+Shift, N, exec, playerctl next || playerctl position `bc <<< "100 * $(playerctl metadata mpris:length) / 1000000 / 100"` # Next track bindl= ,XF86AudioNext, exec, playerctl next || playerctl position `bc <<< "100 * $(playerctl metadata mpris:length) / 1000000 / 100"` # [hidden] bindl= ,XF86AudioPrev, exec, playerctl previous # [hidden] bindl = Super+Shift, Comma, exec, ~/.config/ags/scripts/music/adjust-volume.sh -0.03 # Raise music volume From 59e971530134d5dbf2849ae727f17cf55ec3a151 Mon Sep 17 00:00:00 2001 From: endotrizine Date: Thu, 21 Nov 2024 06:30:27 +0500 Subject: [PATCH 4/4] make keybinds repeat when held --- .config/hypr/hyprland/keybinds.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/hypr/hyprland/keybinds.conf b/.config/hypr/hyprland/keybinds.conf index 503e594a5..c6b3c286d 100644 --- a/.config/hypr/hyprland/keybinds.conf +++ b/.config/hypr/hyprland/keybinds.conf @@ -180,8 +180,8 @@ bind = Super+Alt, Equal, exec, notify-send "Urgent notification" "Ah hell no" -u bindl= Super+Shift, N, exec, playerctl next || playerctl position `bc <<< "100 * $(playerctl metadata mpris:length) / 1000000 / 100"` # Next track bindl= ,XF86AudioNext, exec, playerctl next || playerctl position `bc <<< "100 * $(playerctl metadata mpris:length) / 1000000 / 100"` # [hidden] bindl= ,XF86AudioPrev, exec, playerctl previous # [hidden] -bindl = Super+Shift, Comma, exec, ~/.config/ags/scripts/music/adjust-volume.sh -0.03 # Raise music volume -bindl = Super+Shift, Period, exec, ~/.config/ags/scripts/music/adjust-volume.sh 0.03 # Lower music volume +bindel = Super+Shift, Comma, exec, ~/.config/ags/scripts/music/adjust-volume.sh -0.03 # Raise music volume +bindel = Super+Shift, Period, exec, ~/.config/ags/scripts/music/adjust-volume.sh 0.03 # Lower music volume bind = Super+Shift+Alt, mouse:275, exec, playerctl previous # [hidden] bind = Super+Shift+Alt, mouse:276, exec, playerctl next || playerctl position `bc <<< "100 * $(playerctl metadata mpris:length) / 1000000 / 100"` # [hidden] bindl= Super+Shift, B, exec, playerctl previous # Previous track