-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathurl2webapp
executable file
·93 lines (69 loc) · 2.37 KB
/
url2webapp
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
#!/bin/bash
if [[ $# -eq 0 ]] ; then
URL=`kdialog --title "URL" --inputbox "
Insert the URL:
"` || exit 0;
else
URL=$1;
SAVE="/home/$USER";
fi
LNAME=`kdialog --title "Launcher" --inputbox "
Define the launcher name (i.e. My App):
"`|| exit 0;
temp_NAME=`kdialog --title "App ID" --inputbox "
Define an app ID (i.e. reverse URL like com.domain.subdomain),
so icon themes can identify it and ship a custom icon:
" ` || exit 0;
NAME=`echo "$temp_NAME" | tr ' ' '_'`;
mkdir .u2w_temp;
cd .u2w_temp;
touch url;
echo "$URL" > url;
touch name;
echo "$NAME" > name;
touch "$NAME".desktop;
echo "[Desktop Entry]
Name=$LNAME
Categories=Network;
Exec=~/.webapps/$NAME/$NAME
Icon=$NAME
Path=
StartupNotify=true
Terminal=false
Type=Application
Version=1.0
Actions=in-browser;reinstall;uninstall;
[Desktop Action reinstall]
Name=Reinstall
Exec=kdialog --title Reinstall --warningyesno 'Are you sure?' && nativefier-freedesktop ~/.webapps/installers/$NAME.webapp
Icon=view-refresh
Name[it]=Reinstalla
Exec[it]=kdialog --title Reinstalla --warningyesno 'Sei sicuro?' && nativefier-freedesktop ~/.webapps/installers/$NAME.webapp
[Desktop Action uninstall]
Name=Uninstall
Exec=kdialog --title Uninstall --warningyesno 'Are you sure?' && rm -rf ~/.webapps/$NAME/ && rm -rf ~/.local/share/applications/$NAME.desktop
Icon=edit-delete
Name[it]=Disinstalla
Exec[it]=kdialog --title Disinstalla --warningyesno 'Sei sicuro?' && rm -rf ~/.webapps/$NAME/ && rm -rf ~/.local/share/applications/$NAME.desktop
[Desktop Action in-browser]
Name=Open in the browser
Exec=xdg-open $URL
Icon=internet-web-browser
Name[it]=Apri nel browser
" > "$NAME".desktop;
kdialog --title "Icon" --yesno "Do you want to include a PNG icon in the package?" && ICON=`kdialog --getopenfilename ~ .png` && cp "$ICON" "$NAME".png;
kdialog --title "Stylesheet" --yesno "Do you want to include a custom CSS stylesheet in the package?" && CSS=`kdialog --getopenfilename ~ .css` && cp "$CSS" .;
kdialog --title "Script" --yesno "Do you want to include a custom JavaScript code in the package?" && JS=`kdialog --getopenfilename ~ .js` && cp "$CSS" .;
for i in *.css
do
mv -f "$i" "`echo $i | tr ' ' '_'`"
done;
for i in *.js
do
mv -f "$i" "`echo $i | tr ' ' '_'`"
done;
tar -czvf "$NAME".webapp *;
SAVE=`kdialog --getsavefilename ~ .webapp` || exit 0;
cp -f "$NAME".webapp "$SAVE".webapp;
cd ..;
rm -rf .u2w_temp;