feat(#1289): Adds music reading mode and configuration
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-,>
https://github.com/user-attachments/assets/20adcdd2-469a-44ed-982f-28acbea61d5a
@ahrm could you please help review this? 😊
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.
Added a periodic_commands config and a new set_fixed_velocity command in https://github.com/ahrm/sioyek/commit/62a0b8482fd19bf59ed7e8a55899ddb8bd512809, 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.