Git Product home page Git Product logo

Comments (5)

ccgauche avatar ccgauche commented on July 22, 2024

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?

from ytermusic.

ZeroByter avatar ZeroByter commented on July 22, 2024

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 MediaKeyCodes 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.

from ytermusic.

ccgauche avatar ccgauche commented on July 22, 2024

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!

from ytermusic.

ZeroByter avatar ZeroByter commented on July 22, 2024

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

from ytermusic.

ZeroByter avatar ZeroByter commented on July 22, 2024

Created a crossterm bug report about this: crossterm-rs/crossterm#897

from ytermusic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.