16

Are there any apps for creating a home screen shortcut for a shell script (so I will need just to click on it to run the script)?

It would be great if the app will be open source, and will allow me to save scripts to the internal storage of a rooted device.

zero2cx
  • 482
  • 6
  • 19
Equidamoid
  • 1,447
  • 1
  • 13
  • 24
  • Possible duplicate of [Create a shortcut in the homescreen](http://stackoverflow.com/questions/8546885/create-a-shortcut-in-the-homescreen) – ivan_pozdeev Mar 09 '16 at 06:01

5 Answers5

17

Answer: The answer to your question should be GScript (open source and "save anywhere" on rooted devices), but who wants to stare at that modal terminal output screen when the script completes? Details follow below.

  • SManager (free version) will let you store your custom script anywhere on the device, even your internal storage if you're using a rooted device. It will let you set different auto-launch triggers: Boot (of course), Network up/down, etc. Notifications can be triggered to keep you informed of your script's running and/or exit status, etc. But, it won't let you create a homescreen shortcut that will directly execute your script. It first launches to its own UI, and from there you may execute your script. SManager (no ads version) does let you execute your script from a homescreen shortcut cleanly and in the background, though for some scripts I construct GUI pop-up Views. I script shell and python (see SL4A/android-scripting) using this app.

  • GScript Lite (also Gscript (donate version)) is an open-source solution. You may wish to sync with the source repo and re-code/improve it to better fit your need. As it is now (v1.1.2), it needs a little improvement for ICS+, as its UI exits with a harmless error (a popup that limits its usefulness). This solution will let you directly launch scripts via homescreen shortcut (both versions), but you'll have to stare at a gratuitous terminal output screen for 20 full seconds afterword or until you manually close/dismiss it.

  • SL4A/android-scripting is mentioned in another answer. Creating homescreen shortcuts for your scripts is easily done. This is an open source solution, but it will not let you save scripts to the internal storage of your device. This solution has language support for Lua, BeanShell(Java), Bash shell, Python, Perl, JRuby, Tcl, and JavaScript using modular apk add-ons.

  • SL4A Script Launcher is an add-on to the TaskBomb automation/scheduling utility. The script execution triggers that TaskBomb provides encompasses basically every Content Provider the Android API exposes, and that is a lot. Full SL4A language support applies to this app. If all you need is simple shell scripting, you may find that it has a measure of bloat. Your script can be launched via homescreen shortcut, but this is not an open source solution.

zero2cx
  • 482
  • 6
  • 19
  • Thank you for complete answer! My choice is to use patched ( http://code.google.com/p/gscript-android/issues/detail?id=4 ) version of GScript. – Equidamoid Jul 14 '13 at 08:47
  • @Equidamoid:Thank you for the patch. Can you share a binary blob? If not how can I compile it myself? I would be more then happy for a solution!? – Micromega Nov 18 '13 at 10:28
  • @Phpdna try this: https://bitbucket.org/Equidamoid/gscript/downloads Feel free to create issues in tracker if any =) (PS: sorry for delay) – Equidamoid Dec 02 '13 at 12:49
  • @Equidamoid:Thanks,awesome.But I need to run the script with Gscript,right?I cannot tell Gscript to start a specific script? – Micromega Dec 13 '13 at 12:42
  • @Phpdna Gscript provides a homescreen widget to launch certain script (so you dont need to launch the app and then select the script, just click the widget and script will be launched). You will be asked to select the script when you add the widget. – Equidamoid Dec 14 '13 at 13:40
  • @Equidamoid:RTFM, Awesome, +1 point and great patch :). – Micromega Dec 14 '13 at 14:45
5

So the best option I've found is a GScript.

The GScript version on G.Play was broken, I've sent a patch to the bugtracker but I dont' see any actiivity. The project seems abandoned so I've made a fork here: https://bitbucket.org/Equidamoid/gscript . The apk is available under Downloads section.

Equidamoid
  • 1,447
  • 1
  • 13
  • 24
  • Friends and I with rooted Kindle Fire HDs are happily using your patched GScript to block, unblock and start system apps from launcher shortcuts. Just great! – sjoy Feb 23 '15 at 05:29
  • 1
    GScript didn't work for me under Android 4.4.2. It displayed a title line, but black screen only below the title. – winerd Jul 29 '15 at 16:34
4

Maybe somebody find useful the way I do: I use ConnectBot (available on Play Store, and open source https://code.google.com/p/connectbot/). It is an SSH client that allows to connect to phone itself. You can make a shortcut to a local script doing this:

  • Create a new connection "local". You just need to introduce an alias (your script name, for example)
  • Then, edit the connection, and there is an option like "Sesion start after automatization" (I don't know the exact English words because I see Spanish locales)
  • If your script is simple enough, you just issue your commands in the input box (is multiline): if not, put the path/name of your actual file script on your phone (don't forget the 'newline'!)
  • Now, you can add a shorcut on your home screen of that connection (I have an option on Nova Launcher: long press on home screen, "add shortcut", select Connect Bot, and you will see all the connections in the app. Different launchers may differ.
user2868521
  • 56
  • 1
  • 2
  • Thanks, after messing around with Busybox SSH, I had connectbot this whole time without knowing this feature! – Kevin Oct 14 '14 at 03:49
2

I've discovered SL4A project that allows to create that shortcuts. Unfortunately all scripts must be placed on sdcard.

Equidamoid
  • 1,447
  • 1
  • 13
  • 24
2

The terminal emulator app itself (comes bundled with cyanogenmod etc) lets you create a shortcut (through the widgets window) which opens a terminal window runs a given command (entered when creating the shortcut).

It is quite easy to use this facility to execute a script (use an alias; use && to chain commands; actually create and execute a script).

This can be considered the built in option.

Nathan Tuggy
  • 2,237
  • 27
  • 30
  • 38