diff --git a/.electron-react/webpack.renderer.config.js b/.electron-react/webpack.renderer.config.js index b036f02b..79409164 100644 --- a/.electron-react/webpack.renderer.config.js +++ b/.electron-react/webpack.renderer.config.js @@ -244,7 +244,8 @@ if (isProd) { rendererConfig.plugins.push( new SentryCliPlugin({ release: appVersion, - include: [path.join(__dirname, '../dist/electron')] + include: [path.join(__dirname, '../dist/electron')], + urlPrefix: 'app:///dist/electron/' }) ); } diff --git a/build/icons/128x128.png b/build/icons/128x128.png old mode 100755 new mode 100644 diff --git a/build/icons/16x16.png b/build/icons/16x16.png old mode 100755 new mode 100644 diff --git a/build/icons/24x24.png b/build/icons/24x24.png old mode 100755 new mode 100644 diff --git a/build/icons/256x256.png b/build/icons/256x256.png old mode 100755 new mode 100644 diff --git a/build/icons/32x32.png b/build/icons/32x32.png old mode 100755 new mode 100644 diff --git a/build/icons/48x48.png b/build/icons/48x48.png old mode 100755 new mode 100644 diff --git a/build/icons/512x512.png b/build/icons/512x512.png old mode 100755 new mode 100644 diff --git a/build/icons/64x64.png b/build/icons/64x64.png old mode 100755 new mode 100644 diff --git a/build/icons/96x96.png b/build/icons/96x96.png old mode 100755 new mode 100644 diff --git a/package.json b/package.json index ad627f0f..5cd58485 100755 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "repository": "Superjo149/auryo", "homepage": "http://auryo.com", "productName": "Auryo", - "version": "2.5.1", + "version": "2.5.2", "author": { "name": "Jonas Snellinckx", "email": "jonas.snellinckx@gmail.com" @@ -28,7 +28,7 @@ "package:dir": "npm run build && electron-builder --dir", "package:win": "electron-builder --win --x64", "package:mac": "electron-builder --mac", - "package:linux": "electron-builder --linux", + "package:linux": "electron-builder --linux deb", "package:all": "electron-builder -mwl", "release": "electron-builder -wl --ia32 --x64 --publish onTagOrDraft", "release:win": "electron-builder -w --ia32 --x64 --publish onTagOrDraft", diff --git a/scripts/command.sh b/scripts/command.sh new file mode 100755 index 00000000..148015e9 --- /dev/null +++ b/scripts/command.sh @@ -0,0 +1,2 @@ +#!/bin/bash -e +exec "$SNAP/desktop-init.sh" "$SNAP/desktop-common.sh" "$SNAP/desktop-gnome-specific.sh" "$SNAP/opt/Auryo/auryo" "$@" --no-sandbox \ No newline at end of file diff --git a/scripts/desktop-common.sh b/scripts/desktop-common.sh new file mode 100755 index 00000000..22c4db19 --- /dev/null +++ b/scripts/desktop-common.sh @@ -0,0 +1,439 @@ +#!/bin/bash -e + +############################################### +# Launcher common exports for any desktop app # +############################################### + +function prepend_dir() { + local var="$1" + local dir="$2" + if [ -d "$dir" ]; then + eval "export $var=\"\$dir\${$var:+:\$$var}\"" + fi +} + +function append_dir() { + local var="$1" + local dir="$2" + if [ -d "$dir" ]; then + eval "export $var=\"\${$var:+\$$var:}\$dir\"" + fi +} + +function can_open_file() { + head -c0 "$1" &> /dev/null +} + +function update_xdg_dirs_values() { + local save_initial_values=false + local XDG_DIRS="DOCUMENTS DESKTOP DOWNLOAD MUSIC PICTURES VIDEOS PUBLICSHARE TEMPLATES" + unset XDG_SPECIAL_DIRS_PATHS + + if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/user-dirs.dirs" ]; then + # shellcheck source=/dev/null + source "${XDG_CONFIG_HOME:-$HOME/.config}/user-dirs.dirs" + fi + + if [ -z ${XDG_SPECIAL_DIRS+x} ]; then + save_initial_values=true + fi + + for d in $XDG_DIRS; do + var="XDG_${d}_DIR" + value="${!var}" + + if [ "$save_initial_values" = true ]; then + XDG_SPECIAL_DIRS+=("$var") + if [ -n "$value" ]; then + XDG_SPECIAL_DIRS_INITIAL_PATHS+=("$value") + fi + fi + + if [ -n "$value" ]; then + XDG_SPECIAL_DIRS_PATHS+=("$value") + fi + done +} + +function is_subpath() { + dir="$(realpath "$1")" + parent="$(realpath "$2")" + [ "${dir##$parent/}" != "$dir" ] && return 0 || return 1 +} + +if [ -n "$SNAP_DESKTOP_RUNTIME" ]; then + # add general paths not added by snapcraft due to runtime snap + append_dir LD_LIBRARY_PATH "$SNAP_DESKTOP_RUNTIME/lib/$SNAP_DESKTOP_ARCH_TRIPLET" + append_dir LD_LIBRARY_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET" + append_dir PATH "$SNAP_DESKTOP_RUNTIME/usr/bin" +fi + +# XKB config +export XKB_CONFIG_ROOT="$SNAP_DESKTOP_RUNTIME/usr/share/X11/xkb" + +# Give XOpenIM a chance to locate locale data. +# This is required for text input to work in SDL2 games. +export XLOCALEDIR="$SNAP_DESKTOP_RUNTIME/usr/share/X11/locale" + +# Set XCursors path +export XCURSOR_PATH="$SNAP_DESKTOP_RUNTIME/usr/share/icons" +prepend_dir XCURSOR_PATH "$SNAP/data-dir/icons" + +# Mesa Libs for OpenGL support +append_dir LD_LIBRARY_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/mesa" +append_dir LD_LIBRARY_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/mesa-egl" + +# Tell libGL where to find the drivers +export LIBGL_DRIVERS_PATH="$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/dri" +append_dir LD_LIBRARY_PATH "$LIBGL_DRIVERS_PATH" +export LIBVA_DRIVERS_PATH=$SNAP_DESKTOP_RUNTIME/usr/lib/$ARCH/dri + +# Workaround in snapd for proprietary nVidia drivers mounts the drivers in +# /var/lib/snapd/lib/gl that needs to be in LD_LIBRARY_PATH +# Without that OpenGL using apps do not work with the nVidia drivers. +# Ref.: https://bugs.launchpad.net/snappy/+bug/1588192 +append_dir LD_LIBRARY_PATH /var/lib/snapd/lib/gl + +# Unity7 export (workaround for https://launchpad.net/bugs/1638405) +append_dir LD_LIBRARY_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/libunity" + +# Pulseaudio export +append_dir LD_LIBRARY_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/pulseaudio" + +# EGL vendor files on glvnd enabled systems +[ -d /var/lib/snapd/lib/glvnd/egl_vendor.d ] && \ + append_dir __EGL_VENDOR_LIBRARY_DIRS /var/lib/snapd/lib/glvnd/egl_vendor.d + +# Tell GStreamer where to find its plugins +export GST_PLUGIN_PATH="$SNAP/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/gstreamer-1.0" +export GST_PLUGIN_SYSTEM_PATH="$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/gstreamer-1.0" +# gst plugin scanner doesn't install in the correct path: https://github.com/ubuntu/snapcraft-desktop-helpers/issues/43 +export GST_PLUGIN_SCANNER="$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/gstreamer1.0/gstreamer-1.0/gst-plugin-scanner" + +# XDG Config +[ -n "$SNAP_DESKTOP_RUNTIME" ] && prepend_dir XDG_CONFIG_DIRS "$SNAP_DESKTOP_RUNTIME/etc/xdg" +prepend_dir XDG_CONFIG_DIRS "$SNAP/etc/xdg" + +# Define snaps' own data dir +[ -n "$SNAP_DESKTOP_RUNTIME" ] && prepend_dir XDG_DATA_DIRS "$SNAP_DESKTOP_RUNTIME/usr/share" +prepend_dir XDG_DATA_DIRS "$SNAP/usr/share" +prepend_dir XDG_DATA_DIRS "$SNAP/share" +prepend_dir XDG_DATA_DIRS "$SNAP/data-dir" +prepend_dir XDG_DATA_DIRS "$SNAP_USER_DATA" + +# Set XDG_DATA_HOME to local path +export XDG_DATA_HOME="$SNAP_USER_DATA/.local/share" +mkdir -p "$XDG_DATA_HOME" + +# Workaround for GLib < 2.53.2 not searching for schemas in $XDG_DATA_HOME: +# https://bugzilla.gnome.org/show_bug.cgi?id=741335 +prepend_dir XDG_DATA_DIRS "$XDG_DATA_HOME" + +# Set cache folder to local path +export XDG_CACHE_HOME="$SNAP_USER_COMMON/.cache" +if [[ -d "$SNAP_USER_DATA/.cache" && ! -e "$XDG_CACHE_HOME" ]]; then + # the .cache directory used to be stored under $SNAP_USER_DATA, migrate it + mv "$SNAP_USER_DATA/.cache" "$SNAP_USER_COMMON/" +fi +mkdir -p "$XDG_CACHE_HOME" + +# Set config folder to local path +export XDG_CONFIG_HOME="$SNAP_USER_DATA/.config" +mkdir -p "$XDG_CONFIG_HOME" + +# Create $XDG_RUNTIME_DIR if not exists (to be removed when LP: #1656340 is fixed) +if [ -n "$XDG_RUNTIME_DIR" ]; then + mkdir -p "$XDG_RUNTIME_DIR" + chmod 700 "$XDG_RUNTIME_DIR" +fi + +# Ensure the app finds locale definitions (requires locales-all to be installed) +append_dir LOCPATH "$SNAP_DESKTOP_RUNTIME/usr/lib/locale" + +# If any, keep track of where XDG dirs were so we can potentially migrate the content later +update_xdg_dirs_values + +# Setup user-dirs.* or run xdg-user-dirs-update if needed +needs_xdg_update=false +needs_xdg_reload=false +needs_xdg_links=false + +if [ "$HOME" != "$SNAP_USER_DATA" ] && ! is_subpath "$XDG_CONFIG_HOME" "$HOME"; then + for f in user-dirs.dirs user-dirs.locale; do + if [ -f "$HOME/.config/$f" ]; then + mv "$HOME/.config/$f" "$XDG_CONFIG_HOME" + needs_xdg_reload=true + fi + done +fi + +if can_open_file "$REALHOME/.config/user-dirs.dirs" && can_open_file "$REALHOME/.config/user-dirs.locale"; then + if [ "$SNAP_DESKTOP_COMPONENTS_NEED_UPDATE" = "true" ] || [ $needs_xdg_reload = true ]; then + sed "/^#/!s#\$HOME#${REALHOME}#g" "$REALHOME/.config/user-dirs.dirs" > "$XDG_CONFIG_HOME/user-dirs.dirs" + cp -a "$REALHOME/.config/user-dirs.locale" "$XDG_CONFIG_HOME" + for f in user-dirs.dirs user-dirs.locale; do + md5sum < "$REALHOME/.config/$f" > "$XDG_CONFIG_HOME/$f.md5sum" + done + needs_xdg_reload=true + fi +else + needs_xdg_update=true + needs_xdg_links=true +fi + +if [ $needs_xdg_reload = true ]; then + update_xdg_dirs_values + needs_xdg_reload=false +fi + +# Check if we can actually read the contents of each xdg dir +for ((i = 0; i < ${#XDG_SPECIAL_DIRS_PATHS[@]}; i++)); do + if ! can_open_file "${XDG_SPECIAL_DIRS_PATHS[$i]}"; then + needs_xdg_update=true + needs_xdg_links=true + break + fi +done + +# If needs XDG update and xdg-user-dirs-update exists in $PATH, run it +if [ $needs_xdg_update = true ] && command -v xdg-user-dirs-update >/dev/null; then + xdg-user-dirs-update + update_xdg_dirs_values +fi + +# Create links for user-dirs.dirs +if [ $needs_xdg_links = true ]; then + for ((i = 0; i < ${#XDG_SPECIAL_DIRS_PATHS[@]}; i++)); do + b="$(realpath "${XDG_SPECIAL_DIRS_PATHS[$i]}" --relative-to="$HOME")" + if [ -e "$REALHOME/$b" ]; then + if [ -d "$HOME/$b" ]; then + rmdir "$HOME/$b" 2> /dev/null + fi + if [ ! -e "$HOME/$b" ]; then + ln -s "$REALHOME/$b" "$HOME/$b" + fi + fi + done +else + # If we aren't creating new links, check if we have content saved in old locations and move it + for ((i = 0; i < ${#XDG_SPECIAL_DIRS[@]}; i++)); do + old="${XDG_SPECIAL_DIRS_INITIAL_PATHS[$i]}" + new="${XDG_SPECIAL_DIRS_PATHS[$i]}" + if [ -L "$old" ] && [ -d "$new" ] && [ "$(readlink "$old")" != "$new" ]; then + mv -vn "$old"/* "$new"/ 2>/dev/null + elif [ -d "$old" ] && [ -d "$new" ] && [ "$old" != "$new" ] && + (is_subpath "$old" "$SNAP_USER_DATA" || is_subpath "$old" "$SNAP_USER_COMMON"); then + mv -vn "$old"/* "$new"/ 2>/dev/null + fi + done +fi + +# If detect wayland server socket, then set environment so applications prefer +# wayland, and setup compat symlink (until we use user mounts. Remember, +# XDG_RUNTIME_DIR is /run/user//snap.$SNAP so look in the parent directory +# for the socket. For details: +# https://forum.snapcraft.io/t/wayland-dconf-and-xdg-runtime-dir/186/10 +# Applications that don't support wayland natively may define DISABLE_WAYLAND +# (to any non-empty value) to skip that logic entirely. +SNAP_DESKTOP_WAYLAND_AVAILABLE=false +if [[ -n "$XDG_RUNTIME_DIR" && -z "$DISABLE_WAYLAND" ]]; then + wdisplay="wayland-0" + if [ -n "$WAYLAND_DISPLAY" ]; then + wdisplay="$WAYLAND_DISPLAY" + fi + wayland_sockpath="$XDG_RUNTIME_DIR/../$wdisplay" + wayland_snappath="$XDG_RUNTIME_DIR/$wdisplay" + if [ -S "$wayland_sockpath" ]; then + # if running under wayland, use it + #export WAYLAND_DEBUG=1 + SNAP_DESKTOP_WAYLAND_AVAILABLE=true + # create the compat symlink for now + if [ ! -e "$wayland_snappath" ]; then + ln -s "$wayland_sockpath" "$wayland_snappath" + fi + fi +fi + +# Make PulseAudio socket available inside the snap-specific $XDG_RUNTIME_DIR +if [ -n "$XDG_RUNTIME_DIR" ]; then + pulsenative="pulse/native" + pulseaudio_sockpath="$XDG_RUNTIME_DIR/../$pulsenative" + if [ -S "$pulseaudio_sockpath" ]; then + export PULSE_SERVER="unix:${pulseaudio_sockpath}" + fi +fi + +# GI repository +[ -n "$SNAP_DESKTOP_RUNTIME" ] && prepend_dir GI_TYPELIB_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/girepository-1.0" +[ -n "$SNAP_DESKTOP_RUNTIME" ] && prepend_dir GI_TYPELIB_PATH "$SNAP_DESKTOP_RUNTIME/usr/lib/girepository-1.0" +prepend_dir GI_TYPELIB_PATH "$SNAP/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/girepository-1.0" +prepend_dir GI_TYPELIB_PATH "$SNAP/usr/lib/girepository-1.0" +prepend_dir GI_TYPELIB_PATH "$SNAP/usr/lib/gjs/girepository-1.0" + +# Keep an array of data dirs, for looping through them +IFS=':' read -r -a data_dirs_array <<< "$XDG_DATA_DIRS" + +# Font Config and themes +export FONTCONFIG_PATH="$SNAP_DESKTOP_RUNTIME/etc/fonts" +export FONTCONFIG_FILE="$SNAP_DESKTOP_RUNTIME/etc/fonts/fonts.conf" + +function make_user_fontconfig { + echo "" + if [ -d "$REALHOME/.local/share/fonts" ]; then + echo " $REALHOME/.local/share/fonts" + fi + if [ -d "$REALHOME/.fonts" ]; then + echo " $REALHOME/.fonts" + fi + for ((i = 0; i < ${#data_dirs_array[@]}; i++)); do + if [ -d "${data_dirs_array[$i]}/fonts" ]; then + echo " ${data_dirs_array[$i]}/fonts" + fi + done + echo ' conf.d' + # We need to include this default cachedir first so that caching + # works: without it, fontconfig will try to write to the real user home + # cachedir and be blocked by AppArmor. + echo ' fontconfig' + if [ -d "$REALHOME/.cache/fontconfig" ]; then + echo " $REALHOME/.cache/fontconfig" + fi + echo "" +} + +if [ "$SNAP_DESKTOP_COMPONENTS_NEED_UPDATE" = "true" ]; then + rm -rf "$XDG_DATA_HOME"/{fontconfig,fonts,fonts-*,themes,.themes} + + # This fontconfig fragment is installed in a location that is + # included by the system fontconfig configuration: namely the + # etc/fonts/conf.d/50-user.conf file. + mkdir -p "$XDG_CONFIG_HOME/fontconfig" + make_user_fontconfig > "$XDG_CONFIG_HOME/fontconfig/fonts.conf" + + # the themes symlink are needed for GTK 3.18 when the prefix isn't changed + # GTK 3.20 looks into XDG_DATA_DIR which has connected themes. + ln -sf "$SNAP/data-dir/themes" "$XDG_DATA_HOME" + ln -sfn "$SNAP/data-dir/themes" "$SNAP_USER_DATA/.themes" +fi + +# Build mime.cache +# needed for gtk and qt icon +if [ "$SNAP_DESKTOP_COMPONENTS_NEED_UPDATE" = "true" ]; then + rm -rf "$XDG_DATA_HOME/mime" + if [ ! -f "$SNAP_DESKTOP_RUNTIME/usr/share/mime/mime.cache" ]; then + if command -v update-mime-database >/dev/null; then + cp --preserve=timestamps -dR "$SNAP_DESKTOP_RUNTIME/usr/share/mime" "$XDG_DATA_HOME" + update-mime-database "$XDG_DATA_HOME/mime" + fi + fi +fi + +# Gio modules and cache (including gsettings module) +export GIO_MODULE_DIR="$XDG_CACHE_HOME/gio-modules" +if [ "$SNAP_DESKTOP_COMPONENTS_NEED_UPDATE" = "true" ]; then + if [ -f "$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/glib-2.0/gio-querymodules" ]; then + rm -rf "$GIO_MODULE_DIR" + mkdir -p "$GIO_MODULE_DIR" + ln -sf "$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/gio/modules/"*.so "$GIO_MODULE_DIR" + ln -sf "$SNAP/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/gio/modules/"*.so "$GIO_MODULE_DIR" + "$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/glib-2.0/gio-querymodules" "$GIO_MODULE_DIR" + fi +fi + +# Setup compiled gsettings schema +GS_SCHEMA_DIR="$XDG_DATA_HOME/glib-2.0/schemas" +function compile_schemas { + if [ -f "$1" ]; then + rm -rf "$GS_SCHEMA_DIR" + mkdir -p "$GS_SCHEMA_DIR" + for ((i = 0; i < ${#data_dirs_array[@]}; i++)); do + schema_dir="${data_dirs_array[$i]}/glib-2.0/schemas" + if [ -f "$schema_dir/gschemas.compiled" ]; then + # This directory already has compiled schemas + continue + fi + if [ -n "$(ls -A "$schema_dir"/*.xml 2>/dev/null)" ]; then + ln -s "$schema_dir"/*.xml "$GS_SCHEMA_DIR" + fi + if [ -n "$(ls -A "$schema_dir"/*.override 2>/dev/null)" ]; then + ln -s "$schema_dir"/*.override "$GS_SCHEMA_DIR" + fi + done + # Only compile schemas if we copied anything + if [ -n "$(ls -A "$GS_SCHEMA_DIR"/*.xml "$GS_SCHEMA_DIR"/*.override 2>/dev/null)" ]; then + "$1" "$GS_SCHEMA_DIR" + fi + fi +} +if [ "$SNAP_DESKTOP_COMPONENTS_NEED_UPDATE" = "true" ]; then + compile_schemas "$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/glib-2.0/glib-compile-schemas" +fi + +# Enable gsettings user changes +# symlink the dconf file if home plug is connected for read +DCONF_DEST_USER_DIR="$SNAP_USER_DATA/.config/dconf" +if [ ! -f "$DCONF_DEST_USER_DIR/user" ]; then + if [ -f "$REALHOME/.config/dconf/user" ]; then + mkdir -p "$DCONF_DEST_USER_DIR" + ln -s "$REALHOME/.config/dconf/user" "$DCONF_DEST_USER_DIR" + fi +fi + +# Testability support +append_dir LD_LIBRARY_PATH "$SNAP/testability" +append_dir LD_LIBRARY_PATH "$SNAP/testability/$SNAP_DESKTOP_ARCH_TRIPLET" +append_dir LD_LIBRARY_PATH "$SNAP/testability/$SNAP_DESKTOP_ARCH_TRIPLET/mesa" + +# Gdk-pixbuf loaders +export GDK_PIXBUF_MODULE_FILE=$XDG_CACHE_HOME/gdk-pixbuf-loaders.cache +export GDK_PIXBUF_MODULEDIR=$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/gdk-pixbuf-2.0/2.10.0/loaders +if [ "$SNAP_DESKTOP_COMPONENTS_NEED_UPDATE" = "true" ]; then + rm -f "$GDK_PIXBUF_MODULE_FILE" + if [ -f "$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders" ]; then + "$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders" > "$GDK_PIXBUF_MODULE_FILE" + fi +fi + +# Icon themes cache +if [ "$SNAP_DESKTOP_COMPONENTS_NEED_UPDATE" = "true" ]; then + rm -rf "$XDG_DATA_HOME/icons" + mkdir -p "$XDG_DATA_HOME/icons" + for ((i = 0; i < ${#data_dirs_array[@]}; i++)); do + for theme in "${data_dirs_array[$i]}/icons/"*; do + if [ -f "$theme/index.theme" ] && [ ! -f "$theme/icon-theme.cache" ]; then + theme_dir="$XDG_DATA_HOME/icons/$(basename "$theme")" + if [ ! -d "$theme_dir" ]; then + mkdir -p "$theme_dir" + ln -s "$theme"/* "$theme_dir" + if [ -f "$SNAP_DESKTOP_RUNTIME/usr/sbin/update-icon-caches" ]; then + "$SNAP_DESKTOP_RUNTIME/usr/sbin/update-icon-caches" "$theme_dir" + elif [ -f "$SNAP_DESKTOP_RUNTIME/usr/sbin/update-icon-cache.gtk2" ]; then + "$SNAP_DESKTOP_RUNTIME/usr/sbin/update-icon-cache.gtk2" "$theme_dir" + fi + fi + fi + done + done +fi + +# GTK theme and behavior modifier +# Those can impact the theme engine used by Qt as well +gtk_configs=(gtk-3.0/settings.ini gtk-3.0/bookmarks gtk-2.0/gtkfilechooser.ini) +for f in "${gtk_configs[@]}"; do + dest="$XDG_CONFIG_HOME/$f" + if [ ! -L "$dest" ]; then + mkdir -p "$(dirname "$dest")" + ln -s "$REALHOME/.config/$f" "$dest" + fi +done + +# create symbolic link to ibus socket path for ibus to look up its socket files +# (see comments #3 and #6 on https://launchpad.net/bugs/1580463) +IBUS_CONFIG_PATH="$XDG_CONFIG_HOME/ibus" +mkdir -p "$IBUS_CONFIG_PATH" +[ -d "$IBUS_CONFIG_PATH/bus" ] && rm -rf "$IBUS_CONFIG_PATH/bus" +ln -sfn "$REALHOME/.config/ibus/bus" "$IBUS_CONFIG_PATH" + +export SNAP_DESKTOP_WAYLAND_AVAILABLE + +exec "$@" \ No newline at end of file diff --git a/scripts/desktop-gnome-specific.sh b/scripts/desktop-gnome-specific.sh new file mode 100755 index 00000000..523778f4 --- /dev/null +++ b/scripts/desktop-gnome-specific.sh @@ -0,0 +1,31 @@ +#!/bin/bash -e + +############################## +# GTK launcher specific part # +############################## + +if [ "$SNAP_DESKTOP_WAYLAND_AVAILABLE" = "true" ]; then + export GDK_BACKEND="wayland" + export CLUTTER_BACKEND="wayland" + # Does not hurt to specify this as well, just in case + export QT_QPA_PLATFORM=wayland-egl +fi + +export GTK_PATH="$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/gtk-3.0" + +# ibus and fcitx integration +GTK_IM_MODULE_DIR=$XDG_CACHE_HOME/immodules +export GTK_IM_MODULE_FILE=$GTK_IM_MODULE_DIR/immodules.cache +if [ "$SNAP_DESKTOP_COMPONENTS_NEED_UPDATE" = "true" ]; then + rm -rf "$GTK_IM_MODULE_DIR" + mkdir -p "$GTK_IM_MODULE_DIR" + if [ -x "$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/libgtk-3-0/gtk-query-immodules-3.0" ]; then + ln -sf "$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/gtk-3.0/3.0.0/immodules"/*.so "$GTK_IM_MODULE_DIR" + "$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/libgtk-3-0/gtk-query-immodules-3.0" > "$GTK_IM_MODULE_FILE" + elif [ -x "$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/libgtk2.0-0/gtk-query-immodules-2.0" ]; then + ln -sf "$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/gtk-2.0/2.10.0/immodules"/*.so "$GTK_IM_MODULE_DIR" + "$SNAP_DESKTOP_RUNTIME/usr/lib/$SNAP_DESKTOP_ARCH_TRIPLET/libgtk2.0-0/gtk-query-immodules-2.0" > "$GTK_IM_MODULE_FILE" + fi +fi + +exec "$@" \ No newline at end of file diff --git a/scripts/desktop-init.sh b/scripts/desktop-init.sh new file mode 100755 index 00000000..cccb22d2 --- /dev/null +++ b/scripts/desktop-init.sh @@ -0,0 +1,50 @@ +#!/bin/bash -e + +################# +# Launcher init # +################# + +SNAP_DESKTOP_COMPONENTS_NEED_UPDATE="true" + +# shellcheck source=/dev/null +. "$SNAP_USER_DATA/.last_revision" 2>/dev/null || true +if [ "$SNAP_DESKTOP_LAST_REVISION" = "$SNAP_REVISION" ]; then + SNAP_DESKTOP_COMPONENTS_NEED_UPDATE="false" +else + echo "SNAP_DESKTOP_LAST_REVISION=$SNAP_REVISION" > "$SNAP_USER_DATA/.last_revision" +fi + +# Set $REALHOME to the users real home directory +REALHOME="$(getent passwd $UID | cut -d ':' -f 6)" + +# If the user has modified their user-dirs settings, force an update +if [[ -f "$XDG_CONFIG_HOME/user-dirs.dirs.md5sum" && -f "$XDG_CONFIG_HOME/user-dirs.locale.md5sum" ]]; then + if [[ "$(md5sum < "$REALHOME/.config/user-dirs.dirs")" != "$(cat "$XDG_CONFIG_HOME/user-dirs.dirs.md5sum")" || + "$(md5sum < "$REALHOME/.config/user-dirs.locale")" != "$(cat "$XDG_CONFIG_HOME/user-dirs.locale.md5sum")" ]]; then + SNAP_DESKTOP_COMPONENTS_NEED_UPDATE="true" + fi +fi + +if [ "$SNAP_ARCH" == "amd64" ]; then + ARCH="x86_64-linux-gnu" +elif [ "$SNAP_ARCH" == "armhf" ]; then + ARCH="arm-linux-gnueabihf" +elif [ "$SNAP_ARCH" == "arm64" ]; then + ARCH="aarch64-linux-gnu" +elif [ "$SNAP_ARCH" == "ppc64el" ]; then + ARCH="powerpc64le-linux-gnu" +else + ARCH="$SNAP_ARCH-linux-gnu" +fi + +SNAP_DESKTOP_ARCH_TRIPLET="$ARCH" + +if [ -f "$SNAP/lib/bindtextdomain.so" ]; then + export LD_PRELOAD="$LD_PRELOAD:$SNAP/lib/bindtextdomain.so" +fi + +export REALHOME +export SNAP_DESKTOP_COMPONENTS_NEED_UPDATE +export SNAP_DESKTOP_ARCH_TRIPLET + +exec "$@" \ No newline at end of file diff --git a/snap/gui/auryo.desktop b/snap/gui/auryo.desktop new file mode 100644 index 00000000..98f6b42c --- /dev/null +++ b/snap/gui/auryo.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=Auryo +Exec=auryo +Terminal=false +Type=Application +Icon=${SNAP}/meta/gui/icon.png +StartupWMClass=Auryo +Comment=Listen to SoundCloud® from the comfort of your desktop. Use keyboard shortcuts to navigate through your music. Be more productive. +MimeType=x-scheme-handler/auryo; +Categories=Audio; diff --git a/snap/gui/icon.png b/snap/gui/icon.png new file mode 100644 index 00000000..0286ebff Binary files /dev/null and b/snap/gui/icon.png differ diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 00000000..57e8769d --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,179 @@ +base: core18 +grade: stable +confinement: strict +parts: + launch-scripts: + plugin: dump + source: scripts + gnome-platform-empty-dirs: + plugin: nil + override-build: | + mkdir -p "$SNAPCRAFT_PART_INSTALL/data-dir/themes" mkdir -p "$SNAPCRAFT_PART_INSTALL/data-dir/icons" mkdir -p "$SNAPCRAFT_PART_INSTALL/data-dir/sounds" mkdir $SNAPCRAFT_PART_INSTALL/gnome-platform + app-files: + plugin: dump + source: https://github.com/Superjo149/auryo/releases/download/v2.5.1/Auryo_2.5.1_amd64.deb + source-type: deb + app: + plugin: nil + stage: + - '-usr/lib/python*' + - '-usr/bin/python*' + - '-var/lib/ucf' + - '-usr/include' + - '-usr/lib/X11' + - '-usr/share' + - '-usr/sbin' + - '-usr/bin' + - '-usr/lib/*/libicudata.*' + - '-usr/lib/*/libicui18n.*' + - '-usr/lib/*/libgtk-*' + - '-usr/lib/*/libgdk-*' + - '-usr/lib/*/glib-*' + - '-usr/lib/*/gtk-*' + - '-usr/lib/*/gdk-*' + - '-usr/lib/*/krb5' + - '-usr/lib/systemd' + - '-usr/lib/glib-networking' + - '-usr/lib/dconf' + - '-usr/lib/*/avahi' + - '-usr/lib/*/gio' + - '-usr/lib/*/libatk*' + - '-usr/lib/*/libatspi*' + - '-usr/lib/*/libavahi*' + - '-usr/lib/*/libcairo*' + - '-usr/lib/*/libcolordprivate*' + - '-usr/lib/*/libcolord*' + - '-usr/lib/*/libcroco*' + - '-usr/lib/*/libcups*' + - '-usr/lib/*/libdatrie*' + - '-usr/lib/*/libdconf*' + - '-usr/lib/*/libepoxy*' + - '-usr/lib/*/libexpatw*' + - '-usr/lib/*/libffi*' + - '-usr/lib/*/libfontconfig*' + - '-usr/lib/*/libfreetype*' + - '-usr/lib/*/libgdk_pixbuf*' + - '-usr/lib/*/libgdk_pixbuf_xlib*' + - '-usr/lib/*/libgio*' + - '-usr/lib/*/libglib*' + - '-usr/lib/*/libgmodule*' + - '-usr/lib/*/libgmp*' + - '-usr/lib/*/libgnutls*' + - '-usr/lib/*/libgobject*' + - '-usr/lib/*/libgraphite2*' + - '-usr/lib/*/libgssapi_krb5*' + - '-usr/lib/*/libgthread*' + - '-usr/lib/*/libharfbuzz*' + - '-usr/lib/*/libhogweed*' + - '-usr/lib/*/libicuio*' + - '-usr/lib/*/libicutest*' + - '-usr/lib/*/libicutu*' + - '-usr/lib/*/libicuuc*' + - '-usr/lib/*/libidn2*' + - '-usr/lib/*/libjbig*' + - '-usr/lib/*/libjpeg*' + - '-usr/lib/*/libjson*' + - '-usr/lib/*/libk5crypto*' + - '-usr/lib/*/libkrb5*' + - '-usr/lib/*/libkrb5support*' + - '-usr/lib/*/liblcms2*' + - '-usr/lib/*/libnettle*' + - '-usr/lib/*/libp11*' + - '-usr/lib/*/libpango*' + - '-usr/lib/*/libpangocairo*' + - '-usr/lib/*/libpangoft2*' + - '-usr/lib/*/libpixman*' + - '-usr/lib/*/libpng16*' + - '-usr/lib/*/libproxy*' + - '-usr/lib/*/librest*' + - '-usr/lib/*/librsvg*' + - '-usr/lib/*/libsecret*' + - '-usr/lib/*/libsoup*' + - '-usr/lib/*/libsqlite3*' + - '-usr/lib/*/libtasn1*' + - '-usr/lib/*/libthai*' + - '-usr/lib/*/libtiff*' + - '-usr/lib/*/libunistring*' + - '-usr/lib/*/libwayland*' + - '-usr/lib/*/libX11*' + - '-usr/lib/*/libXau*' + - '-usr/lib/*/libxcb*' + - '-usr/lib/*/libXcomposite*' + - '-usr/lib/*/libXcursor*' + - '-usr/lib/*/libXdamage*' + - '-usr/lib/*/libXdmcp*' + - '-usr/lib/*/libXext*' + - '-usr/lib/*/libXfixes*' + - '-usr/lib/*/libXinerama*' + - '-usr/lib/*/libXi*' + - '-usr/lib/*/libxkbcommon*' + - '-usr/lib/*/libxml2*' + - '-usr/lib/*/libXrandr*' + - '-usr/lib/*/libXrender*' + stage-packages: + - libasound2 + - libgconf2-4 + - libnotify4 + - libnspr4 + - libnss3 + - libpcre3 + - libpulse0 + - libxss1 + - libxtst6 + build-packages: + - execstack +plugs: + gnome-3-28-1804: + interface: content + target: $SNAP/gnome-platform + default-provider: gnome-3-28-1804 + gtk-3-themes: + interface: content + target: $SNAP/data-dir/themes + default-provider: gtk-common-themes + icon-themes: + interface: content + target: $SNAP/data-dir/icons + default-provider: gtk-common-themes + sound-themes: + interface: content + target: $SNAP/data-dir/sounds + default-provider: gtk-common-themes +name: auryo +version: 2.5.1 +summary: A SoundCloud client for your desktop +description: Listen to SoundCloud® from the comfort of your desktop. Use keyboard shortcuts to navigate through your music. Be more productive. +architectures: + - amd64 +apps: + auryo: + command: command.sh + plugs: + - bluez + - browser-support + - gsettings + - home + - mount-observe + - network + - opengl + - pulseaudio + - unity7 + - x11 + - mpris + slots: + - auryo-player-mpris + + adapter: none + environment: + DISABLE_WAYLAND: '1' + TMPDIR: $XDG_RUNTIME_DIR + PATH: '$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH' + SNAP_DESKTOP_RUNTIME: $SNAP/gnome-platform + LD_LIBRARY_PATH: '$SNAP_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu' +icon: snap/gui/icon.png + +slots: + auryo-player-mpris: + interface: mpris + name: auryo_player + diff --git a/snap/snapcraft.yaml-e b/snap/snapcraft.yaml-e new file mode 100644 index 00000000..dc38f286 --- /dev/null +++ b/snap/snapcraft.yaml-e @@ -0,0 +1,55 @@ +name: auryo +version: {VERSION} +summary: A SoundCloud client for your desktop +description: | + Listen to SoundCloud® from the comfort of your desktop. Use keyboard + shortcuts to navigate through your music. Be more productive. +grade: stable +confinement: strict + +parts: + auryo: + plugin: dump + source: https://github.com/Superjo149/auryo/releases/download/v{VERSION}/Auryo_{VERSION}_amd64.deb + source-type: deb + after: + - desktop-gtk3 + # Correct path to icon. + # Clear the execstack - https://forum.snapcraft.io/t/snap-and-executable-stacks/1812 + prepare: | + sed -i 's|Icon=auryo|Icon=/usr/share/icons/hicolor/256x256/apps/auryo\.png|' usr/share/applications/auryo.desktop + execstack --clear-execstack opt/Auryo/auryo + build-packages: + - execstack + stage-packages: + - libasound2 + - libgconf2-4 + - libnotify4 + - libnspr4 + - libnss3 + - libpcre3 + - libpulse0 + - libxss1 + - libxtst6 + +apps: + auryo: + command: bin/desktop-launch $SNAP/opt/Auryo/auryo --no-sandbox + environment: + TMPDIR: $XDG_RUNTIME_DIR + plugs: + - bluez + - browser-support + - gsettings + - home + - mount-observe + - network + - opengl + - pulseaudio + - unity7 + - x11 + +slots: + auryo-player-mpris: + interface: mpris + name: auryo_player \ No newline at end of file diff --git a/src/main/app.ts b/src/main/app.ts index 43f95022..b7173d61 100755 --- a/src/main/app.ts +++ b/src/main/app.ts @@ -5,7 +5,16 @@ import { EVENTS } from '@common/constants/events'; import { StoreState } from '@common/store'; import { addToast, setConfigKey } from '@common/store/actions'; // eslint-disable-next-line import/no-extraneous-dependencies -import { app, BrowserWindow, BrowserWindowConstructorOptions, Menu, nativeImage, protocol, shell } from 'electron'; +import { + app, + BrowserWindow, + BrowserWindowConstructorOptions, + Menu, + nativeImage, + protocol, + shell, + Event +} from 'electron'; import is from 'electron-is'; import windowStateKeeper from 'electron-window-state'; import _ from 'lodash'; @@ -44,7 +53,18 @@ export class Auryo { app.setAppUserModelId('com.auryo.core'); - app.requestSingleInstanceLock(); + app.on('before-quit', () => { + this.logger.info('Application exiting...'); + this.quitting = true; + }); + + const isPrimaryInstance = app.requestSingleInstanceLock(); + + if (!isPrimaryInstance) { + this.logger.debug(`Not the first instance - quit`); + app.quit(); + return; + } app.on('second-instance', () => { // handle protocol for windows @@ -53,33 +73,15 @@ export class Auryo { this.handleProtocolUrl(arg); }); } - - app.exit(); - }); - - app.on('before-quit', () => { - this.logger.info('Application exiting...'); - this.quitting = true; }); } public async start() { - app.setAsDefaultProtocolClient('auryo'); - - protocol.registerHttpProtocol('stream', async (request, callback) => { - const { - config: { - app: { overrideClientId } - } - } = this.store.getState(); - const trackId = request.url.substr(9); - const mp3Url = await this.getPlayingTrackStreamUrl(trackId, overrideClientId || CONFIG.CLIENT_ID || ''); + if (this.quitting) { + return; + } - callback({ - url: mp3Url, - method: 'GET' - }); - }); + app.setAsDefaultProtocolClient('auryo'); app.on('open-url', (event, data) => { event.preventDefault(); @@ -245,25 +247,8 @@ export class Auryo { } }); - this.mainWindow.webContents.session.webRequest.onBeforeRequest( - { - urls: ['https://local.stream/*'] - }, - async (details, callback) => { - const { - config: { - app: { overrideClientId } - } - } = this.store.getState(); - const { 1: trackId } = details.url.split('https://local.stream/'); - const mp3Url = await this.getPlayingTrackStreamUrl(trackId, overrideClientId || CONFIG.CLIENT_ID || ''); - - callback({ - redirectURL: mp3Url - }); - } - ); - + // SoundCloud's API gave a lot of 401s using the /stream to get the audio file + // This is a hacky way to circumvent this :) this.mainWindow.webContents.session.webRequest.onBeforeRequest( { urls: ['http://localhost:8888/stream/*'] @@ -338,11 +323,11 @@ export class Auryo { private readonly registerListeners = () => { if (this.mainWindow) { - this.mainWindow.webContents.on('crashed', (event: any) => { - this.logger.fatal(JSON.stringify(event), 'App Crashed'); + this.mainWindow.webContents.on('crashed', (event: Event) => { + this.logger.fatal(event, 'App Crashed'); }); - this.mainWindow.on('unresponsive', (event: any) => { + this.mainWindow.on('unresponsive', (event: Event) => { this.logger.fatal(event, 'App unresponsive'); }); diff --git a/src/main/utils/logger.ts b/src/main/utils/logger.ts index ec2535bf..c1dcef79 100644 --- a/src/main/utils/logger.ts +++ b/src/main/utils/logger.ts @@ -3,7 +3,7 @@ import rfs from 'rotating-file-stream'; // eslint-disable-next-line import/no-cycle import { Utils } from './utils'; -const isProd = false; // process.env.NODE_ENV === "production" && process.env.ENV !== "development"; +const isProd = process.env.NODE_ENV === 'production' && process.env.ENV !== 'development'; let stream: pino.DestinationStream;