~ahayzen/music-app/snapcraft-001

« back to all changes in this revision

Viewing changes to music-app-service.wrapper

  • Committer: Andrew Hayzen
  • Date: 2016-10-25 11:52:26 UTC
  • Revision ID: ahayzen@gmail.com-20161025115226-prvxrm5vz1a4fj7y
* Run mediascanner inside the music-app and many other fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
if [ "$SNAP_ARCH" = "amd64" ]; then
 
4
    ARCH="x86_64-linux-gnu"
 
5
elif [ "$SNAP_ARCH" = "armhf" ]; then
 
6
    ARCH="arm-linux-gnueabihf"
 
7
else
 
8
    ARCH="$SNAP_ARCH-linux-gnu"
 
9
fi
 
10
 
 
11
 
 
12
# FIXME: this is a workaround for XDG variables
 
13
# not being set adequately
 
14
# Ref.: https://bugs.launchpad.net/snappy/+bug/1577471
 
15
MUSIC_DIR=$(HOME=/home/$USER xdg-user-dir MUSIC)
 
16
SNAP_MUSIC_DIR=$HOME/`basename $MUSIC_DIR`
 
17
 
 
18
if [ ! -h $SNAP_MUSIC_DIR ]; then
 
19
    if [ -e $SNAP_MUSIC_DIR ]; then
 
20
        rm $SNAP_MUSIC_DIR
 
21
    fi
 
22
 
 
23
    ln -s "$MUSIC_DIR" "$SNAP_MUSIC_DIR"
 
24
fi
 
25
 
 
26
 
 
27
# Set XDG_MUSIC_DIR in user-dirs.dirs otherwise mediascanner won't find it
 
28
export XDG_MUSIC_DIR=$SNAP_MUSIC_DIR
 
29
 
 
30
mkdir -p $SNAP_USER_DATA/.config
 
31
 
 
32
echo """
 
33
XDG_MUSIC_DIR=\"$SNAP_MUSIC_DIR\"
 
34
""" > $SNAP_USER_DATA/.config/user-dirs.dirs
 
35
 
 
36
 
 
37
# Gio modules and cache
 
38
export GIO_MODULE_DIR=$SNAP_USER_DATA/.cache/gio-modules
 
39
 
 
40
if [ ! -d $GIO_MODULE_DIR ]; then
 
41
    mkdir -p $GIO_MODULE_DIR
 
42
    ln -s $SNAP/usr/lib/$ARCH/gio/modules/*.so $GIO_MODULE_DIR
 
43
    $SNAP/usr/lib/$ARCH/glib-2.0/gio-querymodules $GIO_MODULE_DIR
 
44
fi
 
45
 
 
46
 
 
47
# Build mime.cache
 
48
if [ ! -d $SNAP_USER_DATA/.local/share/mime ]; then
 
49
    mkdir -p $SNAP_USER_DATA/.local/share/mime/packages
 
50
    cp -a $SNAP/usr/share/mime $SNAP_USER_DATA/.local/share
 
51
    update-mime-database $SNAP_USER_DATA/.local/share/mime
 
52
fi
 
53
 
 
54
 
 
55
# Start the mediascanner2 service
 
56
exec "$SNAP/usr/bin/mediascanner-service-2.0" "$@"
 
57