executable by double click in Ubuntu

3,834 views
Skip to first unread message

tgu...@broadsoft.com

unread,
Aug 11, 2016, 8:12:26 AM8/11/16
to nw.js
The question is how to make nw.js app as executable so that the end user can simply double click on the "app" file and run it, instead of writing

./app

from terminal. 

My issue is that the executable file doesn't run in Ubuntu (or Linux in general) but the same works fine in Windows and Mac OSX.

I tried a lot of methods:

  1. Using simple command approach --->
cat `which nw` app.nw > app && chmod +x app

I zip this app file with along with nw.pak and try to run it through terminal in Ubuntu and it works fine. But when I try to run it by double clicking, it doesn't run.

       2. I used using Web2Executable and then tried to run that app in Ubuntu.
       3. I used grunt-nw-builder and tried running that executable in Ubuntu.

The solution given on Internet is to create .desktop file and use

chmod a+x app

which I have tried. None of this has worked as yet.

My environment:
Ubuntu 16.04 x64
nw.js 0.16.1 x64 sdk

Anybody got any ideas? Please help.




kailn...@gmail.com

unread,
Aug 12, 2016, 9:04:57 AM8/12/16
to nw.js, tgu...@broadsoft.com
I also tried to do the same but i could not figure it out how to create a proper .desktop file, for an alternative try to create an .sh file which runs the nw process (like in terminal) and create a .desktop file to the sh executeable.

tgu...@broadsoft.com

unread,
Aug 17, 2016, 2:56:08 AM8/17/16
to nw.js, kailn...@gmail.com
Yes, this is what looks to be a workaround... I am still trying to find  a good way to simply make a deb or rpm package using nwjs executable. The closest I have come to is using fpm.

Thanks a ton.

cong...@gmail.com

unread,
Aug 22, 2016, 11:26:01 PM8/22/16
to nw.js, tgu...@broadsoft.com
This issue seems to be related to http://bugs.gw.com/view.php?id=404. When Nautilus file manager opening nw, it detected it as shared library (application/x-sharedlib), rather than executable (application/x-executable). So it refused to execute it.

在 2016年8月11日星期四 UTC+8下午8:12:26,tgu...@broadsoft.com写道:

bhavya...@oodlestechnologies.com

unread,
Aug 23, 2016, 1:16:38 AM8/23/16
to nw.js, tgu...@broadsoft.com, cong...@gmail.com
I was able to get this working.

Going through the nwjs docs i figured that in linux platform ( esp. ubuntu ) we have to create a .desktop file in order to double click and run the application. Actually clicking on .desktop file runs a shell script which then runs our application.


My .desktop file looks like this : 

[Desktop Entry]
Name=Your App Name
Exec=sh -c "`dirname %k`/nwScript.sh `dirname %k`"
Terminal=false
Type=Application

Important Points regarding .desktop file:

  1. Terminal key value has to be false
  2. In Exec Field you have to mention the name of your shell script which is responsible for running the app

           Exec Command Explaination :

    1. http://askubuntu.com/questions/496367/desktop-file-running-sh-script-there-was-an-error-launching-the-application
    2. https://askubuntu.com/questions/47775/how-can-i-set-the-path-variable-in-a-desktop-file-to-be-relative-to-the-locat/345123#345123

My shellScript file looks like this :

#!/bin/bash

cd $1
&& ./nwAppName 2>>$1/error.log


Important points regarding the shell script file :

  1. We recieve $1 from the desktop file i.e path of the .desktop file
  2. We log errors in a error.log file in case we get any error while opening the app.

Lets me know if you need any further information regarding it.

Thanks.

david cee

unread,
Oct 28, 2016, 9:56:08 AM10/28/16
to nw.js, tgu...@broadsoft.com, cong...@gmail.com, bhavya...@oodlestechnologies.com
Hi,

i get error in log :

/home/david/Desktop/nwjs-v0.18.3-linux-x64/nwScript.sh: line 5: ./package.nw: Is a directory
ATTENTION: default value of option force_s3tc_enable overridden by environment.

extensions::sendRequest:154
  return natives.StartRequestSync(functionName,
                 ^

ATTENTION: default value of option force_s3tc_enable overridden by environment.

tested on Ubuntu 16, right-clicked on .desktop file to allow  executing file as program,
clicked on it, app launch but crash after few sec.
have no idea how to fix .
thanks
d.

d

unread,
Oct 28, 2016, 12:56:26 PM10/28/16
to nw.js, tgu...@broadsoft.com, cong...@gmail.com, bhavya...@oodlestechnologies.com
well, 
i just updated Ubuntu with software updater app and rebooted,
now nw app launch correctly

error.log still has :
ATTENTION: default value of option force_s3tc_enable overridden by environment.

extensions::sendRequest:154
  return natives.StartRequestSync(functionName,

but my app works fine now. 

d

d

unread,
Nov 17, 2016, 9:54:08 AM11/17/16
to nw.js, tgu...@broadsoft.com, cong...@gmail.com, bhavya...@oodlestechnologies.com
it will be nice to package the App with AppimageKit (appimage.org) to get a single distributable file,
but may be there some modifs to do as my generated app not launch,


any advices welcome

d
Reply all
Reply to author
Forward
0 new messages