summarylogtreecommitdiffstats
path: root/microsip
blob: c55fc9e0da1410f200606e06c7fbb51519dc6475 (plain)
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
#!/usr/bin/env bash

__APPNAME=$(basename $0)
__WINEPREFIX="${XDG_DATA_HOME:-$HOME/.local}/wine/${__APPNAME}"
__APPDIR="${__WINEPREFIX}/dosdevices/c:/${__APPNAME}"
__APPCFG="${XDG_CONFIG_HOME:-$HOME/.config}/${__APPNAME}"
__APPLOG="${XDG_CACHE_HOME:-$HOME/.cache}/${__APPNAME}"
__REGFILE="${__APPDIR}/${__APPNAME}.reg"
__TMPREGFILE=$(mktemp)
__DPI=$(xdpyinfo -display $DISPLAY | grep -A 2 "screen #0:" | grep "resolution:" | grep -oE '[0-9]+x[0-9]+' | cut -d 'x' -f 1)
__DPIX=$(printf %08x ${__DPI})

__symlink() {
	ln -sf "$1" "${__APPDIR}/${1##*/}"
}

mkdir -p "${__APPDIR}"

__symlink "/usr/share/licenses/${__APPNAME}/License.txt"
__symlink "/usr/share/doc/${__APPNAME}/MicroSIP Website.url"
__symlink "/usr/share/${__APPNAME}/hangup.wav"
__symlink "/usr/share/${__APPNAME}/messagein.wav"
__symlink "/usr/share/${__APPNAME}/messageout.wav"
__symlink "/usr/share/${__APPNAME}/ringin.wav"
__symlink "/usr/share/${__APPNAME}/ringin2.wav"
__symlink "/usr/share/${__APPNAME}/ringout.wav"
__symlink "/usr/lib/${__APPNAME}/SDL2.dll"
__symlink "/usr/lib/${__APPNAME}/avcodec-57.dll"
__symlink "/usr/lib/${__APPNAME}/avformat-57.dll"
__symlink "/usr/lib/${__APPNAME}/avutil-55.dll"
__symlink "/usr/lib/${__APPNAME}/microsip.exe"
__symlink "/usr/lib/${__APPNAME}/swscale-4.dll"

cp "/usr/share/${__APPNAME}/${__APPNAME}.reg" "${__TMPREGFILE}"
sed -i "s/{DPI}/${__DPIX}/g" "${__TMPREGFILE}"
iconv -f utf-8 -t utf-16le "${__TMPREGFILE}" >"${__REGFILE}"
rm -f "${__TMPREGFILE}"
WINEPREFIX="${__WINEPREFIX}" regedit "${__REGFILE}"
rm -f "${__REGFILE}"

mkdir -p "${__APPCFG}"
touch "${__APPCFG}/Contacts.xml"
touch "${__APPCFG}/microsip.ini"
__symlink "${__APPCFG}/Contacts.xml"
__symlink "${__APPCFG}/microsip.ini"

mkdir -p "${__APPLOG}"
touch "${__APPLOG}/microsip_log.txt"
__symlink "${__APPLOG}/microsip_log.txt"

WINEPREFIX="${__WINEPREFIX}" wine "${__APPDIR}/microsip.exe"