This repository has been archived by the owner on May 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathkicad.wrapper
executable file
·214 lines (182 loc) · 6.72 KB
/
kicad.wrapper
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#!/bin/bash
# Make kicad configs to be unversioned
export HOME="$SNAP_USER_COMMON"
# Set XDG runtime directory
export XDG_RUNTIME_DIR=/run/shm/snap.$SNAP_NAME.$SNAP_REVISION
mkdir -p $XDG_RUNTIME_DIR
# Setup i18n and locale
export I18NPATH=$SNAP/usr/share/i18n
export LOCPATH=$SNAP_USER_COMMON/.locale
mkdir -p $LOCPATH
# generate a locale
LANG_EN=en_GB.UTF-8
if [ ! -e $LOCPATH/$LANG_EN ]; then
LANG1=$(echo $LANG_EN | cut -f1 -d.)
ENC=$(echo $LANG_EN | cut -f2 -d.)
$SNAP/usr/bin/localedef --prefix=$SNAP_USER_COMMON -f $ENC -i $LANG1 $LOCPATH/$LANG_EN
fi
if [ ! -e $LOCPATH/$LANG ]; then
LANG1=$(echo $LANG | cut -f1 -d.)
ENC=$(echo $LANG | cut -f2 -d.)
$SNAP/usr/bin/localedef --prefix=$SNAP_USER_COMMON -f $ENC -i $LANG1 $LOCPATH/$LANG
fi
#######################################################
# dektop-launch script with $SNAP_USER_{DATA->COMMON} #
#######################################################
###############################################
# Launcher common exports for any desktop app #
###############################################
needs_update=true
. ~/.last_revision 2>/dev/null || true
if [ "$SNAP_DESKTOP_LAST_REVISION" = "$SNAP_REVISION" ]; then
needs_update=false
fi
[ $needs_update = true ] && echo "SNAP_DESKTOP_LAST_REVISION=$SNAP_REVISION" > ~/.last_revision
if [ "$SNAP_ARCH" == "amd64" ]; then
ARCH="x86_64-linux-gnu"
elif [ "$SNAP_ARCH" == "armhf" ]; then
ARCH="arm-linux-gnueabihf"
else
ARCH="$SNAP_ARCH-linux-gnu"
fi
# XKB config
export XKB_CONFIG_ROOT=$SNAP/usr/share/X11/xkb
# Mesa Libs
##export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/mesa:$LD_LIBRARY_PATH
##export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/mesa-egl:$LD_LIBRARY_PATH
# Tell libGL where to find the drivers
export LIBGL_DRIVERS_PATH=$SNAP/usr/lib/$ARCH/dri
export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/dri:$LD_LIBRARY_PATH
# Pulseaudio export
##export LD_LIBRARY_PATH=$SNAP/usr/lib/$ARCH/pulseaudio:$LD_LIBRARY_PATH
# XDG Config
export XDG_CONFIG_DIRS=$SNAP/etc/xdg:$SNAP/usr/xdg:$XDG_CONFIG_DIRS
# Define snaps' own data dir
export XDG_DATA_DIRS=$SNAP_USER_COMMON:$SNAP/usr/share:$XDG_DATA_DIRS
# Set XDG_DATA_HOME to local path
export XDG_DATA_HOME=$SNAP_USER_COMMON/.local/share
export XDG_DATA_DIRS=$XDG_DATA_HOME:$XDG_DATA_DIRS
mkdir -p $XDG_DATA_HOME
# Set cache folder to local path
export XDG_CACHE_HOME=$SNAP_USER_COMMON/.cache
mkdir -p $XDG_CACHE_HOME
# Font Config and themes
export FONTCONFIG_PATH=$SNAP/etc/fonts/conf.d
export FONTCONFIG_FILE=$SNAP/etc/fonts/fonts.conf
if [ $needs_update = true ]; then
rm -rf $XDG_DATA_HOME/{fontconfig,fonts,fonts-*,themes,.themes}
rm -rf $SNAP_USER_COMMON/.themes
ln -sf $SNAP/usr/share/{fontconfig,fonts,fonts-*,themes} $XDG_DATA_HOME
ln -sf $SNAP/usr/share/themes $SNAP_USER_COMMON/.themes
fi
# Build mime.cache
# needed for gtk and qt icon
if [ $needs_update = true ]; then
rm -rf $XDG_DATA_HOME/mime
if [ `which update-mime-database` ]; then
cp --preserve=timestamps -dR $SNAP/usr/share/mime $XDG_DATA_HOME
update-mime-database $XDG_DATA_HOME/mime
fi
fi
##############################
# GTK launcher specific part #
##############################
# select gtk version
. $SNAP/flavor-select
# Gdk-pixbuf loaders
export GDK_PIXBUF_MODULE_FILE=$XDG_CACHE_HOME/gdk-pixbuf-loaders.cache
export GDK_PIXBUF_MODULEDIR=$SNAP/usr/lib/$ARCH/gdk-pixbuf-2.0/2.10.0/loaders
if [ $needs_update = true ]; then
rm -f $GDK_PIXBUF_MODULE_FILE
if [ -f $SNAP/usr/lib/$ARCH/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders ]; then
$SNAP/usr/lib/$ARCH/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders > $GDK_PIXBUF_MODULE_FILE
fi
fi
# Gio modules and cache
export GIO_MODULE_DIR=$XDG_CACHE_HOME/gio-modules
if [ $needs_update = true ]; then
rm -rf $GIO_MODULE_DIR
mkdir -p $GIO_MODULE_DIR
ln -s $SNAP/usr/lib/$ARCH/gio/modules/*.so $GIO_MODULE_DIR
if [ -f $SNAP/usr/lib/$ARCH/glib-2.0/gio-querymodules ]; then
$SNAP/usr/lib/$ARCH/glib-2.0/gio-querymodules $GIO_MODULE_DIR
fi
fi
# GI repository
export GI_TYPELIB_PATH=$SNAP/usr/lib/girepository-1.0:$SNAP/usr/lib/$ARCH/girepository-1.0
if [ "$USE_gtk3" = true ]; then
export GTK_PATH=$SNAP/usr/lib/$ARCH/gtk-3.0
else
export GTK_PATH=$SNAP/usr/lib/$ARCH/gtk-2.0
fi
# ibus and fcitx integration
# with those defintions fcitx works unconfined out of the box, ibus requires
# user config to be copied though, https://launchpad.net/bugs/1580463
GTK_IM_MODULE_DIR=$XDG_CACHE_HOME/immodules
export GTK_IM_MODULE_FILE=$GTK_IM_MODULE_DIR/immodules.cache
if [ $needs_update = true ]; then
rm -rf $GTK_IM_MODULE_DIR
mkdir -p $GTK_IM_MODULE_DIR
if [ "$USE_gtk3" = true ]; then
ln -s $SNAP/usr/lib/$ARCH/gtk-3.0/3.0.0/immodules/*.so $GTK_IM_MODULE_DIR
$SNAP/usr/lib/$ARCH/libgtk-3-0/gtk-query-immodules-3.0 > $GTK_IM_MODULE_FILE
else
ln -s $SNAP/usr/lib/$ARCH/gtk-2.0/2.10.0/immodules/*.so $GTK_IM_MODULE_DIR
$SNAP/usr/lib/$ARCH/libgtk2.0-0/gtk-query-immodules-2.0 > $GTK_IM_MODULE_FILE
fi
fi
# Keep an array of data dirs, for looping through them
IFS=':' read -r -a data_dirs_array <<< "$XDG_DATA_DIRS"
# Setup compiled gsettings schema
GS_SCHEMA_DIR=$XDG_DATA_HOME/glib-2.0/schemas
if [ $needs_update = true ]; then
rm -rf $GS_SCHEMA_DIR
mkdir -p $GS_SCHEMA_DIR
for d in "${data_dirs_array[@]}"; do
schema_dir=$d/glib-2.0/schemas
if [ "$(ls -A $schema_dir/*.xml 2>/dev/null)" ]; then
ln -s $schema_dir/*.xml $GS_SCHEMA_DIR
fi
done
if [ -f $SNAP/usr/lib/$ARCH/glib-2.0/glib-compile-schemas ]; then
$SNAP/usr/lib/$ARCH/glib-2.0/glib-compile-schemas $GS_SCHEMA_DIR
fi
fi
# Enable gsettings user changes
# symlink the dconf file if home plug is connected for read
DCONF_DEST_USER_DIR=$SNAP_USER_COMMON/.config/dconf
if [ ! -f $DCONF_DEST_USER_DIR/user ]; then
if [ -f /home/$USER/.config/dconf/user ]; then
mkdir -p $DCONF_DEST_USER_DIR
ln -s /home/$USER/.config/dconf/user $DCONF_DEST_USER_DIR
fi
fi
# Icon themes cache
if [ $needs_update = true ]; then
rm -rf $XDG_DATA_HOME/icons
mkdir -p $XDG_DATA_HOME/icons
for d in "${data_dirs_array[@]}"; do
for i in $d/icons/*; do
if [ -d "$i" ]; then
theme_dir=$XDG_DATA_HOME/icons/$(basename "$i")
if [ ! -d "$theme_dir" ]; then
mkdir -p "$theme_dir"
ln -s $i/* "$theme_dir"
if [ -f $SNAP/usr/sbin/update-icon-caches ]; then
$SNAP/usr/sbin/update-icon-caches "$theme_dir"
elif [ -f $SNAP/usr/sbin/update-icon-cache.gtk2 ]; then
$SNAP/usr/sbin/update-icon-cache.gtk2 "$theme_dir"
fi
fi
fi
done
done
fi
# Init global FP library table
if [ ! -f $HOME/.config/kicad/fp-lib-table ]; then
mkdir -p $HOME/.config/kicad
cp $SNAP/usr/share/kicad/template/fp-lib-table.for-pretty $HOME/.config/kicad/fp-lib-table
fi
# Set ngspice library directory
export SPICE_LIB_DIR=$SNAP/usr/share/ngspice
exec "$@"