Skip to content

feat: add mouse scroll to incease/decrease volume#931

Merged
aome510 merged 4 commits intoaome510:masterfrom
Alimedhat000:feat/mouse-scroll-volume
Feb 18, 2026
Merged

feat: add mouse scroll to incease/decrease volume#931
aome510 merged 4 commits intoaome510:masterfrom
Alimedhat000:feat/mouse-scroll-volume

Conversation

@Alimedhat000
Copy link
Contributor

@Alimedhat000 Alimedhat000 commented Feb 13, 2026

Adds mouse scroll support to increase/decrease volume.

Resolves #446.

In app.toml:

enable_mouse_scroll_volume = true # enable mouse scrolling to change volume
volume_scroll_step = 5  # percent to change per scroll (default)

Comment on lines +70 to +77
Keymap {
key_sequence: "m s u".into(),
command: Command::VolumeUp,
},
Keymap {
key_sequence: "m s d".into(),
command: Command::VolumeDown,
},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is already VolumeChange command, why did you add new ones?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh my bad! i will use VolumeChange instead

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds mouse scroll support to control playback volume in response to issue #446, which requested the ability to bind mouse scroll events to volume control. The implementation introduces two new commands (VolumeUp and VolumeDown), adds corresponding player requests, and implements mouse scroll event handling with a configurable volume step.

Changes:

  • Added VolumeUp and VolumeDown commands with default key bindings to "m s u" and "m s d"
  • Implemented mouse scroll event handlers (ScrollUp/ScrollDown) that trigger volume changes
  • Added volume_scroll_step configuration option (default: 5%) to control the volume increment/decrement size

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
spotify_player/src/event/mod.rs Added mouse scroll event handlers and VolumeUp/VolumeDown command handlers
spotify_player/src/config/mod.rs Added volume_scroll_step configuration field with default value of 5
spotify_player/src/config/keymap.rs Added default keymaps for VolumeUp ("m s u") and VolumeDown ("m s d")
spotify_player/src/command.rs Added VolumeUp and VolumeDown command enum variants with descriptions
spotify_player/src/client/request.rs Added VolumeUp and VolumeDown request enum variants
spotify_player/src/client/mod.rs Implemented VolumeUp and VolumeDown request handlers with volume bounds checking

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +74 to +88
if keymap_config
.find_command_or_action_from_key_sequence(&key_sequence)
.is_some()
{
let _ = client_pub.try_send(ClientRequest::Player(PlayerRequest::VolumeUp));
}
}
crossterm::event::MouseEventKind::ScrollDown => {
let key_sequence: KeySequence = "m s d".into();
let keymap_config = &config::get_config().keymap_config;
if keymap_config
.find_command_or_action_from_key_sequence(&key_sequence)
.is_some()
{
let _ = client_pub.try_send(ClientRequest::Player(PlayerRequest::VolumeDown));
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mouse scroll handler hardcodes the key sequences "m s u" and the VolumeUp command. This implementation checks if "m s u" exists in the keymap config but then always sends VolumeUp regardless of what command is actually mapped to that sequence. Instead, the handler should retrieve the command from the keymap using find_command_or_action_from_key_sequence and execute whatever command is mapped to "m s u", similar to how handle_key_event works (lines 149-157). This would allow users to customize what mouse scroll does, not just limit it to volume control.

Suggested change
if keymap_config
.find_command_or_action_from_key_sequence(&key_sequence)
.is_some()
{
let _ = client_pub.try_send(ClientRequest::Player(PlayerRequest::VolumeUp));
}
}
crossterm::event::MouseEventKind::ScrollDown => {
let key_sequence: KeySequence = "m s d".into();
let keymap_config = &config::get_config().keymap_config;
if keymap_config
.find_command_or_action_from_key_sequence(&key_sequence)
.is_some()
{
let _ = client_pub.try_send(ClientRequest::Player(PlayerRequest::VolumeDown));
if let Some(command_or_action) =
keymap_config.find_command_or_action_from_key_sequence(&key_sequence)
{
// Execute whatever command or action is mapped to "m s u"
handle_command_or_action(command_or_action, client_pub, state)?;
}
}
crossterm::event::MouseEventKind::ScrollDown => {
let key_sequence: KeySequence = "m s d".into();
let keymap_config = &config::get_config().keymap_config;
if let Some(command_or_action) =
keymap_config.find_command_or_action_from_key_sequence(&key_sequence)
{
// Execute whatever command or action is mapped to "m s d"
handle_command_or_action(command_or_action, client_pub, state)?;

Copilot uses AI. Check for mistakes.
Comment on lines +74 to +88
if keymap_config
.find_command_or_action_from_key_sequence(&key_sequence)
.is_some()
{
let _ = client_pub.try_send(ClientRequest::Player(PlayerRequest::VolumeUp));
}
}
crossterm::event::MouseEventKind::ScrollDown => {
let key_sequence: KeySequence = "m s d".into();
let keymap_config = &config::get_config().keymap_config;
if keymap_config
.find_command_or_action_from_key_sequence(&key_sequence)
.is_some()
{
let _ = client_pub.try_send(ClientRequest::Player(PlayerRequest::VolumeDown));
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as ScrollUp handler: this hardcodes the key sequence "m s d" and always sends VolumeDown. The handler should retrieve and execute the actual command mapped to "m s d" from the keymap config using find_command_or_action_from_key_sequence, allowing users to customize mouse scroll behavior beyond just volume control.

Suggested change
if keymap_config
.find_command_or_action_from_key_sequence(&key_sequence)
.is_some()
{
let _ = client_pub.try_send(ClientRequest::Player(PlayerRequest::VolumeUp));
}
}
crossterm::event::MouseEventKind::ScrollDown => {
let key_sequence: KeySequence = "m s d".into();
let keymap_config = &config::get_config().keymap_config;
if keymap_config
.find_command_or_action_from_key_sequence(&key_sequence)
.is_some()
{
let _ = client_pub.try_send(ClientRequest::Player(PlayerRequest::VolumeDown));
if let Some(command_or_action) =
keymap_config.find_command_or_action_from_key_sequence(&key_sequence)
{
// Execute the command or action mapped to "m s u" so users can customize
// scroll-up behavior (e.g. volume up or something else).
command::handle_command_or_action(command_or_action, &state, client_pub)?;
}
}
crossterm::event::MouseEventKind::ScrollDown => {
let key_sequence: KeySequence = "m s d".into();
let keymap_config = &config::get_config().keymap_config;
if let Some(command_or_action) =
keymap_config.find_command_or_action_from_key_sequence(&key_sequence)
{
// Execute the command or action mapped to "m s d" so users can customize
// scroll-down behavior (e.g. volume down or something else).
command::handle_command_or_action(command_or_action, &state, client_pub)?;

Copilot uses AI. Check for mistakes.
.find_command_or_action_from_key_sequence(&key_sequence)
.is_some()
{
let _ = client_pub.try_send(ClientRequest::Player(PlayerRequest::VolumeUp));
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error handling is silently discarded with the underscore pattern. This is inconsistent with the rest of the function which uses ? to propagate errors (see line 103-105). If the VolumeUp request fails to send, the user should be notified. Consider using the same error handling pattern as the SeekTrack request below.

Copilot uses AI. Check for mistakes.
.find_command_or_action_from_key_sequence(&key_sequence)
.is_some()
{
let _ = client_pub.try_send(ClientRequest::Player(PlayerRequest::VolumeDown));
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error handling is silently discarded with the underscore pattern. This is inconsistent with the rest of the function which uses ? to propagate errors (see line 103-105). If the VolumeDown request fails to send, the user should be notified. Consider using the same error handling pattern as the SeekTrack request below.

Copilot uses AI. Check for mistakes.
Comment on lines 71 to 89
crossterm::event::MouseEventKind::ScrollUp => {
let key_sequence: KeySequence = "m s u".into();
let keymap_config = &config::get_config().keymap_config;
if keymap_config
.find_command_or_action_from_key_sequence(&key_sequence)
.is_some()
{
let _ = client_pub.try_send(ClientRequest::Player(PlayerRequest::VolumeUp));
}
}
crossterm::event::MouseEventKind::ScrollDown => {
let key_sequence: KeySequence = "m s d".into();
let keymap_config = &config::get_config().keymap_config;
if keymap_config
.find_command_or_action_from_key_sequence(&key_sequence)
.is_some()
{
let _ = client_pub.try_send(ClientRequest::Player(PlayerRequest::VolumeDown));
}
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description states users can configure keymaps in keymap.toml to bind VolumeUp/VolumeDown commands to key sequences "m s u" and "m s d". However, the mouse scroll implementation hardcodes these key sequences and always executes VolumeUp/VolumeDown regardless of what users actually configure. This creates a discrepancy between what the PR description promises (configurability) and what the code delivers (hardcoded behavior). The implementation should honor user-configured keymaps by retrieving and executing the mapped command, not bypassing the keymap system.

Copilot uses AI. Check for mistakes.
@Alimedhat000
Copy link
Contributor Author

would changing it to use a bool like enable_mouse_scroll_volume instead of the keymap option be better?
cause it's a scrolling option why would some one remap that?

@Alimedhat000
Copy link
Contributor Author

one problem i faced is that i had to reuse some of the of VolumeChange logic because it's not accessible from the mouse handler.

A potential fix would be to add a small helper function that the mouse handler could use.
i'm happy to implement this but i'd wait for your approval.

- add `enable_mouse_scroll_volume` to config
- fix error handling to properly propagate errors
- remove `VolumeUp` and `VolumeDown` entirely
@Alimedhat000 Alimedhat000 force-pushed the feat/mouse-scroll-volume branch from 1167478 to 4c68534 Compare February 17, 2026 13:48
@aome510 aome510 merged commit 3fd64eb into aome510:master Feb 18, 2026
5 checks passed
@Alimedhat000 Alimedhat000 deleted the feat/mouse-scroll-volume branch February 18, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Be able to bind keymaps to mouse scroll

3 participants