diff options
| author | krolxon <krolyxon@tutanota.com> | 2024-06-11 21:49:35 +0530 |
|---|---|---|
| committer | krolxon <krolyxon@tutanota.com> | 2024-06-11 21:49:35 +0530 |
| commit | a6fa8add79f4d67ef1d4cb904eb0c0166c96b107 (patch) | |
| tree | 6438a77933a69f968641b5c01f434b7623589ba2 /src/event/handler.rs | |
| parent | 3e3ae64c72c8906513eda4e208c85bbf0e487482 (diff) | |
add toggle mute keymap
Diffstat (limited to 'src/event/handler.rs')
| -rwxr-xr-x | src/event/handler.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/event/handler.rs b/src/event/handler.rs index fcd1416..02bdb14 100755 --- a/src/event/handler.rs +++ b/src/event/handler.rs @@ -1,5 +1,6 @@ use crate::{ app::{App, AppResult, SelectedTab}, + connection::VolumeStatus, ui::InputMode, }; use crossterm::event::{KeyCode, KeyEvent, KeyModifiers, MouseEvent, MouseEventKind}; @@ -138,6 +139,22 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { app.conn.update_status(); } + // Toggle Mute + KeyCode::Char('m') => { + match app.conn.volume_status { + VolumeStatus::Muted(v) => { + app.conn.conn.volume(v)?; + app.conn.volume_status = VolumeStatus::Unmuted; + } + VolumeStatus::Unmuted => { + let current_volume = app.conn.status.volume; + app.conn.conn.volume(0)?; + app.conn.volume_status = VolumeStatus::Muted(current_volume); + } + } + app.conn.update_status(); + } + // Update MPD database KeyCode::Char('U') => { app.conn.conn.rescan()?; |
