Skip to content

Commit

Permalink
Merge pull request #2 from Cris70/master
Browse files Browse the repository at this point in the history
Corrected a few errors
  • Loading branch information
alxlg committed Apr 30, 2017
2 parents b94b0e2 + 5c60119 commit 9dde2b2
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 13 deletions.
65 changes: 56 additions & 9 deletions nativefier-freedesktop
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/bash

if [[ $# -eq 0 ]] ; then
webapp=`kdialog --getopenfilename ~ .webapp`;
Expand All @@ -8,20 +8,41 @@ if [[ $# -eq 0 ]] ; then
exit 0;
fi
else
webapp="$1";
if [[ "$1" == "--help" ]] ; then
echo "
Usage: nativefier-freedesktop [options] [<file.webapp>]
Options:
--help shows this helps message
<file.webapp>: a .webapp file used as a guide to create the application;
if not specified, a file dialog will popup to ask for a
.webapp file;
use the url2webapp script to create a .webapp file from
an url
"
exit 0;
else
webapp="$1";
fi
fi

# make temp folder:
mkdir .nf_temp;

# resolve absolute path if relative, otherwise cp on line 219 will fail
webapp=`readlink -f "$webapp"`;

# copy the .webapp into it:
cp "$webapp" .nf_temp/"$webapp"
cp "$webapp" ".nf_temp/${webapp##*/}"

# move to it:
cd .nf_temp;

# extract .webapp:
tar -zxvf "$webapp";
tar -zxvf "${webapp##*/}";

# check if "name" file exists:
if [ -f name ]; then
Expand All @@ -32,6 +53,11 @@ else
# (useful for self-hosted apps with custom domain)
# as convention use reverse URL, i.e. org.kde.webapp:
name=`kdialog --inputbox "Name, i.e. org.kde.webapp:" | tr ' ' '_'`
if [ -z $name ]; then
echo "File name is empty"
rm -rf .nf_temp;
exit 0;
fi
fi

# read launcher name:
Expand All @@ -51,6 +77,28 @@ else
fi


# support flash?:
flash=1;
kdialog --title "Install Web App" --yesno "Does $lname need flash support?" || flash=0;
if [ "$flash" -eq 1 ]; then
fp=`locate -e -L -l 1 -b '\libpepflashplayer.so'`;
case "$?" in
1)
echo 'No flash plugin available'
flash=0
;;
127)
echo 'locate command not installed'
flash=0
;;
esac
fi
if [ "$flash" -eq "1" ]; then
fcmd="--flash --flash-path $fp";
else
fcmd='';
fi


# copy the icon and the launcher to respective paths:
cp "$name".png ~/.local/share/icons/"$name".png;
Expand Down Expand Up @@ -91,12 +139,12 @@ if [ "$cssn" -gt "1" ]; then
rm -rf .tempfile

style=`kdialog --radiolist "Select a theme:" $kd_arg 0 None off`

if [ "$style" -eq 0 ]; then
touch nostyle.css
style=nostyle.css
fi

#for i in *.css
#do
# declare style_$k=`echo "${i%.*}" | tr ' ' '_'`;
Expand Down Expand Up @@ -147,11 +195,10 @@ kdialog --msgbox "The installation has begun and may take a few minutes.\nYou wi
# check if the PNG icon file exists:
if [ -f "$name".png ]; then
# exec nativefier using the icon and injecting style.css and script.js
nativefier -n "$name" -i "$name".png --inject "$style" --inject "$script" "$url" ~/.webapps/;
nativefier -n "$name" -i "$name".png $fcmd --inject "$style" --inject "$script" "$url" ~/.webapps/;
else
# exec nativefier without icon and injecting style.css and script.js
nativefier -n "$name" --inject "$style" --inject "$script" "$url" ~/.webapps/;

nativefier -n "$name" $fcmd --inject "$style" --inject "$script" "$url" ~/.webapps/;
fi


Expand Down
8 changes: 4 additions & 4 deletions url2webapp
Expand Up @@ -13,7 +13,7 @@ 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),
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 ' ' '_'`;
Expand Down Expand Up @@ -41,11 +41,11 @@ Actions=in-browser;reinstall;uninstall;
[Desktop Action reinstall]
Name=Reinstall
Exec=kdialog --title Reinstall --warningyesno 'Are you sure?' && nativefier-freedesktop ~/.webapps/$NAME/$NAME.webapp
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/$NAME/$NAME.webapp
Exec[it]=kdialog --title Reinstalla --warningyesno 'Sei sicuro?' && nativefier-freedesktop ~/.webapps/installers/$NAME.webapp
[Desktop Action uninstall]
Expand Down Expand Up @@ -75,7 +75,7 @@ for i in *.css
do
mv -f "$i" "`echo $i | tr ' ' '_'`"
done;

for i in *.js
do
mv -f "$i" "`echo $i | tr ' ' '_'`"
Expand Down

0 comments on commit 9dde2b2

Please sign in to comment.