-
Notifications
You must be signed in to change notification settings - Fork 15
/
linuxlauncher.sh
62 lines (53 loc) · 1.4 KB
/
linuxlauncher.sh
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
#!/bin/bash
DIR=$(dirname "${BASH_SOURCE[0]}") # Relative
DIR=$(realpath "${DIR}") # Absolute
APP_NAME=modbusmechanic.desktop
cd $DIR
DIR_DESK=~/.local/share/applications
function run_disown() {
"$@" & disown
}
function run_disown_silence(){
run_disown "$@" 1>/dev/null 2>/dev/null
}
if [ "$1" = "--install" ] ; then
if [[ -f "$DIR_DESK/$APP_NAME" ]]; then
echo Link "$DIR_DESK/$APP_NAME exists."
rm $DIR_DESK/$APP_NAME
else
echo Link "$DIR_DESK/$APP_NAME does not exist."
fi
if [[ -f "$DIR/$APP_NAME" ]]; then
echo Launcher "$DIR/$APP_NAME exists."
rm $DIR/$APP_NAME
else
echo Launcher "$DIR/$APP_NAME does not exist."
fi
echo \
"[Desktop Entry]
Encoding=UTF-8
Type=Application
NoDisplay=false
Terminal=false
Icon=
Comment=
Categories=
Exec="$DIR/linuxlauncher.sh --launch"
Name=ModbusMechanic" \
>> $APP_NAME
ln -s $DIR/$APP_NAME $DIR_DESK/$APP_NAME
chmod +x $DIR/linuxlauncher.sh
elif [ "$1" = "--uninstall" ] ; then
rm -f $DIR/$APP_NAME $DIR_DESK/$APP_NAME
elif [ "$1" = "--launch" ] ; then
DIR=$(dirname "${BASH_SOURCE[0]}") # Relative
cd $DIR
run_disown_silence java -jar ModbusMechanic.jar
else
echo "ModbusMechanic Linux launcher
Linux launcher related script
Options:
--install Installs the launcher icon
--uninstall Removes the launcher icon
--launch Invoked by the launcher icon to start ModbusMechanic"
fi