diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..a2b7f58f --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +# meson/ninja +build/ +install/ +builddir/ diff --git a/README.md b/README.md index 3e4c6e5a..cb75987e 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,9 @@ A GNOME media player built using [GJS](https://gitlab.gnome.org/GNOME/gjs) and p ### WORK IN PROGRESS This is still early WIP. Many features are not implemented yet and quite a few are still unstable. Right now Clapper can only play single file. So if you want to test it, start it from terminal like this: ```shell -clapper video.mp4 +com.github.rafostar.Clapper "video.mp4" ``` + ## Requirements Clapper uses `GStreamer` bindings from `GI` repository, so if your repo ships them as separate package, they must be installed first. Additionally Clapper requires these `GStreamer` elements: @@ -16,10 +17,10 @@ Other required plugins (codecs) depend on video format. ## Installation Run in terminal: -```sh -sudo ./install.sh +```shell +meson builddir --prefix=/usr/local +sudo meson install -C builddir ``` -I know that this should be done using some sort of build system (like `meson`), but the player is still far from finished and a basic install script should be sufficient for the time being, if anyone wishes to test it. ## Hardware acceleration Using hardware acceleration is highly recommended. As stated in `GStreamer` wiki: diff --git a/bin/clapper b/bin/clapper deleted file mode 100755 index 7238d51c..00000000 --- a/bin/clapper +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/gjs - -const Package = imports.package; - -Package.init({ - name: "clapper", - version: "0.0.0", - prefix: "/usr/local", - libdir: "/usr/local/lib", - datadir: "/usr/local/share", -}); -Package.run(imports.main); diff --git a/bin/com.github.rafostar.Clapper.in b/bin/com.github.rafostar.Clapper.in new file mode 100644 index 00000000..b62c9a2d --- /dev/null +++ b/bin/com.github.rafostar.Clapper.in @@ -0,0 +1,12 @@ +#!@GJS@ + +const Package = imports.package; + +Package.init({ + name: '@PACKAGE_NAME@', + version: '@PACKAGE_VERSION@', + prefix: '@prefix@', + libdir: '@libdir@', + datadir: '@datadir@', +}); +Package.run(imports.main); diff --git a/bin/meson.build b/bin/meson.build new file mode 100644 index 00000000..2cdf501d --- /dev/null +++ b/bin/meson.build @@ -0,0 +1,16 @@ +bin_conf = configuration_data() +bin_conf.set('GJS', find_program('gjs').path()) +bin_conf.set('PACKAGE_VERSION', meson.project_version()) +bin_conf.set('PACKAGE_NAME', meson.project_name()) +bin_conf.set('prefix', get_option('prefix')) +bin_conf.set('libdir', join_paths(get_option('prefix'), get_option('libdir'))) +bin_conf.set('datadir', join_paths(get_option('prefix'), get_option('datadir'))) + +configure_file( + input: 'com.github.rafostar.Clapper.in', + output: 'com.github.rafostar.Clapper', + configuration: bin_conf, + install: true, + install_dir: get_option('bindir'), + install_mode: 'rwxr-xr-x' +) diff --git a/build-aux/meson/postinstall.py b/build-aux/meson/postinstall.py new file mode 100755 index 00000000..cd3924d8 --- /dev/null +++ b/build-aux/meson/postinstall.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +from os import environ, path +from subprocess import call + +prefix = environ.get('MESON_INSTALL_PREFIX', '/usr/local') +datadir = path.join(prefix, 'share') +destdir = environ.get('DESTDIR', '') + +# Package managers set this so we don't need to run +#if not destdir: + # NO CLAPPER ICON YET + #print('Updating icon cache...') + #call(['gtk-update-icon-cache', '-qtf', path.join(datadir, 'icons', 'hicolor')]) + + # NO CLAPPER DESKTOP FILES YET + #print('Updating desktop database...') + #call(['update-desktop-database', '-q', path.join(datadir, 'applications')]) + + # NO CLAPPER SCHEMAS YET + #print('Compiling GSettings schemas...') + #call(['glib-compile-schemas', path.join(datadir, 'glib-2.0', 'schemas')]) diff --git a/clapper_src/app.js b/clapper_src/app.js index e82913d7..163e6e3d 100644 --- a/clapper_src/app.js +++ b/clapper_src/app.js @@ -4,8 +4,9 @@ const { Interface } = imports.clapper_src.interface; const { Player } = imports.clapper_src.player; const { Window } = imports.clapper_src.window; -const APP_NAME = 'Clapper'; -const APP_ID = `com.github.rafostar.${APP_NAME}`; +const APP_NAME = pkg.name.substring( + pkg.name.lastIndexOf('.') + 1 +); let { debug } = Debug; @@ -22,7 +23,7 @@ var App = GObject.registerClass({ GLib.set_prgname(APP_NAME); super._init({ - application_id: APP_ID + application_id: pkg.name }); let defaults = { diff --git a/gjs-1.0/clapper.js b/gjs-1.0/clapper.js.in similarity index 81% rename from gjs-1.0/clapper.js rename to gjs-1.0/clapper.js.in index 3e756ef7..91dabb16 100644 --- a/gjs-1.0/clapper.js +++ b/gjs-1.0/clapper.js.in @@ -1,6 +1,6 @@ imports.gi.versions.Gdk = '3.0'; imports.gi.versions.Gtk = '3.0'; -imports.searchPath.unshift('/usr/local/share/clapper'); +imports.searchPath.unshift('@importspath@'); const ClapperSrc = imports.clapper_src; diff --git a/gjs-1.0/meson.build b/gjs-1.0/meson.build new file mode 100644 index 00000000..88b55ae6 --- /dev/null +++ b/gjs-1.0/meson.build @@ -0,0 +1,14 @@ +sharedir = join_paths(get_option('prefix'), 'share') +gjsdir = join_paths(sharedir, 'gjs-1.0') +importspath = join_paths(sharedir, meson.project_name()) + +gjs_conf = configuration_data() +gjs_conf.set('importspath', importspath) + +configure_file( + input: 'clapper.js.in', + output: 'clapper.js', + configuration: gjs_conf, + install: true, + install_dir: gjsdir +) diff --git a/install.sh b/install.sh deleted file mode 100755 index 44dc0d8e..00000000 --- a/install.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -LICENSES_DIR="/usr/local/share/licenses/clapper" -DOC_DIR="/usr/local/share/doc/clapper" -MAIN_DIR="/usr/local/share/clapper" -BIN_DIR="/usr/local/bin" -GJS_DIR="/usr/local/share/gjs-1.0" - -SCRIPT_ERR="Error: this script must be" - -if [ ! -d "./clapper_src" ]; then - echo "$SCRIPT_ERR run from clapper directory!" 1>&2 - exit 1 -elif [ "$EUID" -ne 0 ]; then - echo "$SCRIPT_ERR run as root!" 1>&2 - exit 1 -fi - -echo "Creating directories..." -mkdir -p "$LICENSES_DIR" -mkdir -p "$DOC_DIR" -mkdir -p "$MAIN_DIR" -mkdir -p "$GJS_DIR" -mkdir -p "$BIN_DIR" - -echo "Copying files..." -cp -f "./COPYING" "$LICENSES_DIR/" -cp -f "./README.md" "$DOC_DIR/" -cp -rf "./clapper_src" "$MAIN_DIR/" -cp -rf "./css" "$MAIN_DIR/" -cp -f "./main.js" "$MAIN_DIR/" -cp -f "./gjs-1.0/clapper.js" "$GJS_DIR/" -cp -f "./bin/clapper" "$BIN_DIR/" - -echo "Creating executables..." -chmod +x "$BIN_DIR/clapper" - -echo "Install finished" diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..f97a5d0f --- /dev/null +++ b/meson.build @@ -0,0 +1,26 @@ +project('com.github.rafostar.Clapper', + version: '0.0.0', + meson_version: '>= 0.47.0', + license: 'GPL3', + default_options: [ 'warning_level=2' ] +) + +python = import('python3') +python_bin = python.find_python() + +if not python_bin.found() + error('No valid python3 binary found') +endif + +conf = configuration_data() +conf.set('bindir', join_paths(get_option('prefix'), 'bin')) + +subdir('bin') +subdir('gjs-1.0') + +installdir = join_paths(get_option('prefix'), 'share', meson.project_name()) +install_subdir('clapper_src', install_dir : installdir) +install_subdir('css', install_dir : installdir) +install_data('main.js', install_dir : installdir) + +meson.add_install_script('build-aux/meson/postinstall.py')