From a6fa8add79f4d67ef1d4cb904eb0c0166c96b107 Mon Sep 17 00:00:00 2001 From: krolxon Date: Tue, 11 Jun 2024 21:49:35 +0530 Subject: add toggle mute keymap --- src/event/handler.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/event/handler.rs') 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()?; -- cgit v1.2.3