Open ZeroByter opened 3 months ago
Hello thanks for your feedback! Are you talking about DBus controls or shortcuts in the app ? What terminal are you using? Can you send the ytermusic log?
Not sure what is DBus controls, I'm referring to physical keyboard buttons (sometimes fn+key buttons) to pause/play, next track and previous track.
I actually cloned your repo and tried to implement this myself but couldn't get it to work, even though I think it should work, here is what I tried:
Added line PushKeyboardEnhancementFlags(KeyboardEnhancementFlags::DISAMBIGUATE_ESCAPE_CODES);
in mod.rs
pub fn run(&mut self, updater: &Receiver<ManagerMessage>) -> Result<(), io::Error> {
// setup terminal
enable_raw_mode()?;
let mut stdout = io::stdout();
execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?;
let backend = CrosstermBackend::new(stdout);
let mut terminal = Terminal::new(backend)?;
// create app and run it
let tick_rate = Duration::from_millis(250);
// V Added this line here V
PushKeyboardEnhancementFlags(KeyboardEnhancementFlags::DISAMBIGUATE_ESCAPE_CODES);
// ^ Added this line here ^
let mut last_tick = Instant::now();
'a: loop {
Added lines in music_player.rs
fn on_key_press(&mut self, key: KeyEvent, _: &ratatui::layout::Rect) -> EventResponse {
match key.code {
KeyCode::Media(media_key) => match media_key {
MediaKeyCode::PlayPause => {
SoundAction::PlayPause.apply_sound_action(self);
EventResponse::None
}
_ => EventResponse::None,
},
...
I'm actually not that familiar with Rust, so I tried making a new empty Rust project just to see if I could at all capture these MediaKeyCode
s but I couldn't, perhaps it's a problem with crossterm
? Or with Linux? I haven't tried on Windows yet.
Where is the log file? I'll happily send it.
I don't know how FN + FX keys are handled but it think they should use DBus too (A linux protocol for media actions cross-desktop). To confirm I've been using souvlaki underneath so maybe you should look there. Thanks for the investigation!
I just googled souvlaki and it looks promising, I'll give it a try later today and if I hopefully get it to work, will send a PR :) Thanks for the help!
Edited update: I just found the souvlaki code in the project and messed around with it and I just now realized what is the DBus protocol that you are talking about, but that is not what I am referring to.
I am referring to these keyboard buttons:
I confirmed in a new standalone project, kebyoard media buttons are not captured by souvlaki
Created a crossterm
bug report about this: https://github.com/crossterm-rs/crossterm/issues/897
While playing a song, trying to pause/play songs, skip forward to the next stop, or going back to the start of the song (or last song if pressed twice quickly) via keyboard buttons doesn't work. I'm on Ubuntu.