Skip to content
Extraits de code Groupes Projets

lektor mk7

pipeline status coverage report

A Karaoke player made to replace the old bash scripts on Sakura. They will enable one to have a database and make requests over the network.

Building the player

Prerequisites:

  • autotools only if you change the configuration (if you only edit existing files you won't need it)
  • a C compiler with C11 support
  • the sqlite3 development library, version 3.31.0 or newer for generated columns support
  • a POSIX.1-2008 compatible system (i.e. not MS Windows)

For the module sdl2, you will need the folowing prerequisites:

  • the mpv development library
  • the sdl2 development library

For the module repo, you will need the folowing prerequisites:

You will also need the following executables, with their path setted in the configuration file:

  • mkvpropedit from mkvtoolnix
  • the bourn shell again: bash
  • the command line tool xxd, is distributed in the vim and gvim packages on archlinux, seems to be distributed in its own package on debian: xxd

If you use the configure with the --with-depends option (needed on debian 10), you will need the following dependencies:

  • the curl command line utility. It can be replaced by the wget command line utility.
  • the wget command line utility. Can be replaced by curl command line utility.
  • the git command line utility
  • the cmake command line utility (to be deleted when use of json-c is dropped)

Note that because of the use of curl and get, building behind a proxy may be challenging.

The manual way of installing and setting up lektor:

# Setup files
sudo mkdir /home/kara && sudo chown USER:USER /home/kara

# Install
mkdir build && cd build && ../configure
make
sudo make install

# Config and run
lektord

The sqlite database and the config file will be created automatically if needed, i.e. on the first run. If you are upgrading lektor, the config might not be correct. You can delete the config file or use the lkt admin config to generate the config file again.

If you are using special modules or are compiling lektor without static modules, you may set their absolute path inside the lektor's config file.

On archlinux, you need only to install the package:

makepkg -si

Important note: if you are building using WSL, lektord will likely not launch, because XDG_RUNTIME_DIR is not defined here. This folder is important, this is where most of your deamons are puttings theirs sockets and so. Blame Microsoft for that. A workaround is to export one: export WDG_RUNTIME_DIR=$(mktemp -d) before launching lektord. Be aware that you will have issues with sound and videos becouse you will need to set up a X server...

Currently, supported compilers are: icc 19.1.2.254 and above, gcc 8.3.0 and above, clang 7.0.1 and above. It compiles on debian, thus it must compiles on your system (apport from CentOS, because I never tested on it).

Preparing a kara for lektor

A karamaker needs mkvpropedit (often installed with the mkvtoolnix-gui package in distributions). The path to these programs must be setted in the lektor.ini config file.

As a karamaker, you need to add necessary information to your kara so that lektor can store it in its database. This information is to be directly written in the .mkv file.

/some/directory/$CAT/$LANG/$AUTH/$SOURCE - $TYPE$NUM - $TITLE.mkv

The ideal way of populating lektor is using Kurisu. The update and rescan commands are here for that.

How to launch lektor

To run lektor, you can simply run the binary like: ./lektord.

If lektord did not exited normally (i.e. without the lkt adm kill command), the database will still store the fact that lektord is running. To by-pass it, you will need to launch lektord with the -F (forced) option, like:

lektord -F

It is not recommended to launch always lektord with the -F option, because that way you could launch multiple instances of the lektod daemon, which could results in undefined behaviours.

Lektor will use specialized software (hwdec set to yes), if you have an nvidia card with optimus (in almose every laptop), please use optirun or primusrun:

optirun ./lektord

How to use lektor

Lektor is compatible with mpd, which means that you can use any client (only mpc is tested) to interact with lektor. Some functions are not really compatible (somme work to be done) because mpc really makes some assumptions.

The ideal way is to use lkt.

How to configure lektor

Lektor configuration is done with an INI file. Modules' configuration is also done by the same INI file using diferent sections.

Lektor searches for the configuration file in that order:

  • $(pwd)/lektor.ini
  • if XDG_CONFIG_HOME defined then $XDG_CONFIG_HOME/lektor/lektor.ini else $HOME/.config/lektor/lektor.ini
  • /opt/lektor/lektor.ini
  • /usr/local/etc/lektor.ini
  • /etc/lektor.ini

The first one to be found is picked up by lektor. Note that if the environment variable XDG_CONFIG_HOME is not defined, it is replaced by HOME/.config.

To get the default config file, you can use the lkt adm conf command.

Be aware that if the home directory or the XDG_CONFIG_HOME are too long they will be ignored and truncated.

Modules

Modules are .so files (i.e. dynamic libraries) loaded by lektors using a function named module_set_function which takes a void * and a struct lkt_option * in argument and must return an int (may return an uint16_t in the future). This function must initialize correctly the module. The name of this function can be defined in the INI file.

The functions of a modules are stored in a register. This register can be registered in the lektor's global register or exported inside .so file. Only one register can be exported by .so file. The macros are here to help you do so.

Some functions are mendatory for a module:

  • The new(void **) function creates the module
  • The free(void **) release the module, it can't be used after
  • The close(void **) close the module, it can be used after

All exported functions must take a va_list. The first argument of the va_list is a void **, which point to the pointer used to access the module's defined structure. The rest is up to you, no checks will be done. All functions must return an int in a POSIX way: 0 if everything is ok, an other value if something went wrong.

MPD

Lektor is almost MPD compatible, at least it uses the same protocol, which can be gotten here.