Skip to content

Comments

feat(#1289): Adds music reading mode and configuration#1486

Open
KorigamiK wants to merge 2 commits intoahrm:developmentfrom
KorigamiK:feat/music
Open

feat(#1289): Adds music reading mode and configuration#1486
KorigamiK wants to merge 2 commits intoahrm:developmentfrom
KorigamiK:feat/music

Conversation

@KorigamiK
Copy link

This shows how it can be used with the following config in user keys:

toggle_music_reading_mode <A-m>
music_reading_speed_up <A-.>
music_reading_speed_down <A-,>
music.mp4

@KorigamiK
Copy link
Author

@ahrm could you please help review this? 😊

@ahrm
Copy link
Owner

ahrm commented Oct 15, 2025

Hi! Thanks, I am impressed by your ability to implement this, I will look at this hopefully in the next few days. However, since this is a very niche yet sizeable feature, I would prefer if it was implemented as an extension (in python or JS), since I don't know much about music and probably can't do a good job of maintaining this feature. The current extension system might not be powerful enough that it can handle such a complex feature, but I am willing to implement the features needed to implement this (off the top of my head, you probably need some way to periodically execute a custom script) so other use cases can also benefit from this.

@ahrm
Copy link
Owner

ahrm commented Oct 17, 2025

Added a periodic_commands config and a new set_fixed_velocity command in 62a0b84, which should help your use-caes. Here is an example of using it, this script moves the page every two seconds some amount.

prefs_user.config (the periodic_commands is probably set dynamically using setconfig commands, I just set it by default here as an example):


new_async_js_command _periodic /path/to/periodic.js
periodic_commands _periodic

periodic.js:

let lastMoveTime = sioyek_api.get_variable('korigamik.last_move_time');

let currentTime = new Date();
const moveEveryMiliseconds = 2000;

if ((lastMoveTime === undefined) || ((currentTime - lastMoveTime) > moveEveryMiliseconds)){

    sioyek.set_fixed_velocity("10000 500");
    sioyek_api.set_variable('korigamik.last_move_time', currentTime);
}


set_fixed_velocity takes two arguments, the first is the velocity and the second is how much to move. In the javascript you can call any sioyek command like this: sioyek.toggle_dark_mode() and there are some special api-specific functions that do not have a sioyek command equivalent (e.g. set_variable). You can call these like so: sioyek_api.set_variable. You can see a list of such commands by searching for Q_INVOKABLE in main_widget.h.

Let me know if there are any more functionality required to implement your use-cases.

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.

2 participants