Hi all,
I've done a simple script in /system/bin/ that executes two commands and then exit from the terminal (killing the process, since 'exit' command doesn't work).
I execute the script using a terminal shortcut that executes 'su -c myscript': it opens the terminal windows, executes the two commands I want and then exit as expected.
The problem is: if I launch this shortcut when I'm in another app e.g. YouTube, after closing the terminal windows it comes back to the homescreen, while I wanted it to stay on YouTube.
Is there a command that I can use to switch to previous app before killing the terminal?
I searched but I cannot find anything of useful
Thanks
Little up
:fingers-crossed:
Related
2013-05-17 ( 1.0.0-alpha3 )
New features:
* Basic terminal emulation ( input handling, color support, cursor control ) etc.
The terminal has 2 gesture modes ( scroll, cursor ) and additional soft-input methods for keys like ctrl, escape etc.
Scroll-mode:
Normal scrolling, auto-scrolling and fast-scrolling (right-edge), double tap on top/bottom to jump.
Cursor-mode:
Edges of the screen will send d-pad (up/down/left/right) keys ( multiple pointers/fingers to control speed of repetition ).
Swipe up/down for page-up, page-down and swipe left/right for home and end keys.
Currently the emulator has no utf-8 support and some other features might be missing.
* The ability to start a terminal/process directly.
* The ability to create aliases directly to a profile.
Enabling an alias will add a shortcut in the launcher directly to the selected profile.
Currently 3 aliases can be set (terminal, su, sh). Sadly android is pretty limited in this area and it only allows enabled/disabling of components so there is no way to change titles, but i guess these 3 are most common. Be aware that you might need to re-start your launcher/phone before changes are visible ( this also depends on the launcher active ).
* Updated icon.
Notice:
Because of major changes happening during the alpha-state it is required to do a reinstall instead of an upgrade ( because of possible database/preference changes ).
2013-04-12 ( 1.0.0-alpha2 )
- Cleanup of list items in the history tab ( date/time added ).
- Basic history view which shows the history transcript and allows to email it.
- Ability to create desktop shortcuts from library items added ( contextual actionbar of an item ).
- If a input dialog (gscript-input) is dismissed it now shows a notification that there is a input request pending and clicking it will bring the user straight back to the dialog.
2013-04-10 ( 1.0.0-alpha1 )
Gscript is currently in an alpha state so features might be missing or broken.
The current progress:
Basics of the new library interface.
Scripts are no longer stored within gscript but instead access is now handled through libraries.
Basically the library decides how to browse through files and get their content and the only thing
that is stored within gscript are the additional item attributes and conditions.
Currently this is limited to a LocalStorage library type, but other options might come later on.
Basic process / history management.
Processes now run in a background service and can be accessed through the 'active'-tab in gscript or
by clicking on their notification (if enabled).
Custom shell profiles ( editable in settings )
Instead of a fixed option for sh / su you can now create Shell Profiles which allow changing of the actual
command including color schemes and additional extras like path appending etc.
Launching scripts directly from most file managers ( if they handle files the way they should... Astro works for me )
Launching scripts from anywhere else (terminal, adb etc) using gscript-exec ( found in /data/data/org.gscript/bin )
First start on the dialog framework to allow graphical user input from shell using gscript-input, which should also work outside gscript.
Very minimal console view ( output only and no input methods yet )
What is WIP:
A lot...
A decent console view which will allow user input
History tab only shows the files that have been executed but no way to see the output, time etc
Additional features to the library interface to edit scripts etc
Additional features to the dialog framework ( to allow file selection etc, numeric input )
Additional item conditions like schedules ( now only has a boot condition )
Desktop shortcuts / widget
Backwards compatibility to android 2.2 ( now 2.3 )
More...
Who should install this?
Users who want to help make this better and can live with the fact that things might not be 100% finished
How to start?
Install
Within Gscript click the + sign in the action bar to add a new library.
Select Local Storage
Give the Library a name
And set the path to a folder you want as the root view ( It does not create the folder so make sure it exists ).
Browse the folder from within Gscript and click an item to execute or long click an item to set attributes/condtions ( shell, boot etc )
In settings new Shell profiles can be created or deleted and a default can be set.
The command-line of a shell profile can have %path% in it. If this is the case it will replace this with the final executable script.
If it does not have a %path% argument the script will be send as input.
The binaries gscript-exec, gscript-input can be found in /data/data/org.gscript/bin ( if everything went right and it is a supported ABI )
Usage
gscript-exec filename
gscript-input types
will list available input types
gscript-input [type]
will list the expected arguments
Sample script which uses gscript-input
Code:
# items are ; seperated key:value pairs
# keys with a * prefix are pre-selected
# in case of radiobuttons only the first
# selected item will actually get selected
RESULT=$(gscript-input \
list \
"Choose" \
"Select multiple" \
"0:The first option;
*1:The second option;
*2:The third option;
*3:The last option;")
gscript-input \
toast \
"Selected items: $RESULT"
echo "Selected: $RESULT"
SELECTED=$(gscript-input \
list \
"Choose" \
"Select single" \
"0:The first option;
*1:The second option;
2:The third option;
3:The last option;" \
radio)
if [ $? -eq 1 ]; then
gscript-input \
toast \
"You selected $SELECTED"
fi
echo "Selected: $SELECTED"
NAME=$(gscript-input \
text-entry \
"Name" \
"Please enter your name")
if [ $? -eq 1 ]; then
gscript-input \
dialog-info \
"Welcome" \
"Welcome back $NAME"
echo "$NAME"
fi
gscript-input \
dialog-message \
"Finished" \
"Finished processing script.. do you want to exit now?" \
yesno
if [ $? -eq 1 ]; then
gscript-input \
toast \
"Goodbye $NAME"
exit
fi
* In case of issues please be clear and give as many details as possible.
* During the alpha-state i will keep multiple versions available for download ( so be sure to check version numbers ).
* During the alpha-state it is required to do a re-install instead of an upgrade ( because of possible breaking changes ).
Fantastic, you got my full support ^^;
Very cool. I was going to make something similar to this for mounting\unmounting debian but I don't need to now.
Already uploaded the source... ill create an apk as soon as I have the time.
Link to source repository
Ok ive created an apk.. Ill update the first post with the zip-file attached.
Please be aware that its still beta and that executing scripts without knowing what they do could harm your system!
I just use it to execute "reboot", "tether start/stop", but you can use it to just execute any shell script either as normal shell or as su.
Let me know if it works and if its usefull for anyone.. thanks.
Exactly what I was trying to find time to write!
Great idea.
Thanks!
awesome
perfect for backing up ALL apps thanks
I must be missing something. I put in the script to launch Debian but it dosent appear to launch. Its just a simple command-
cd /sdcard/debian
su
modprobe ext2
su ./bootdeb
Any suggestions?
you shouldnt need the su commands as you are executing it as su... havent tested multilines a lot other then a few simple calls, but maybe thats where it goes wrong.
Can you try making one .sh file and execute that from within the script field?
That actually how i intended it... that way you can easy backup your larger scripts without having to rely on the database used in my app.
So i just use the commands "tether start" and "tether stop" and leave the actual scripts intact.
Or try it without the su commands and do something like this:
/sdcard/debian/modprobe ext2
/sdcard/debian/bootdeb
Let me know if it works else ill look further into it.
Any chance of adding support for shortcuts to run these commands on the desktop?
Already was thinking about that feature..
I'll try to add an option "Create shortcut" that will create a desktop shortcut to run the selected script.
Ok ive been thinking a bit last night and ill add the following features:
Load from file ( from sdcard .sh files )
Create shortcut ( will create a shortcut to the specified script on the home screen )
Save to file ( will save specified script to sdcard )
Ill also change some things in how things are executed to make it more stable ( im going to save the selected script into a temporary .sh file and execute that one ).
Ok ive made some changes:
* Added ability to create a shortcut to a script from the home screen ( long press home screen -> shortcut -> gscript and then select the script you want to create a shortcut of )
* Added ability to save the selected script to sdcard as .sh file
* Changed the way scripts are executed. The script is now first saved to /sdcard/gscript_tmp.sh and then executed using either sh or su.
Todo:
Load .sh files from sd.
Ill update the first post with a new zip and the latest changes.
New zip file in the first post... and also added some screenshots so people know what it does.
New code is also committed to the source repository.
Let me know if all is working ok.
rogro82 said:
Hi all,
Ive created a small application, for people like me who dont like typing the same thing over and over. I use it for things like tethering and reboot.
Its basically a small database in which you can save your scripts and run them easily from within Android ( either with normal shell or su ).
Ive decided to make it open source ( project can be found on google code, a link is listed below ), so people don't have to be afraid something else is executed as root.
[/URL]
Click to expand...
Click to collapse
Damn you beat me to it! I've been working on this exact same thing but I've not had much free time lately (I have a two month old at home). I think the only thing that I'd planned that I'm not sure if you've integrated is the abaility to import scripts, so a *nix guru could write a script and share it with others, and for other applications to call a script via this application. Still AWSOME!
Damn you beat me to it! I've been working on this exact same thing but I've not had much free time lately (I have a two month old at home). I think the only thing that I'd planned that I'm not sure if you've integrated is the abaility to import scripts, so a *nix guru could write a script and share it with others, and for other applications to call a script via this application. Still AWSOME!
Click to expand...
Click to collapse
Todo:
Load .sh files from sd.
Click to expand...
Click to collapse
Ill add that feature tonight or tomorrow but its coming soon... the shortcut feature took most of my time so didnt had time to complete loading ( although I already started some work on it )
About the calling script from within other applications. I dont know if people would like having other apps running script and as other apps dont know what script a user has its almost impossible to create a solid solution. So yes it is possible, but if its actually workable is another thing.
Glad you like it!
package file
Can someone just upload the package file so we can load this from our android devices?
oops sorry
When I downloaded gscript.zip on my iMac it unpacked it as a folder. Stupid Mac...
Anyway here is the link to the .apk file for people on their androids....
Thanks for posting a link for people to use straight from there mobile. Ill add it to the first post.
Added the ability to load .sh files from the sdcard.
Just put your .sh file in the root of the sdcard and add or edit a script and select "Load file". You will now see the file. Click it and the content of the file will be used as the script.
This way you can easily create .sh files on your pc or share them and eventually execute them as shortcuts
Update is in the first post... About to upload the source to the repository
Note: You will be deleting files from your phone so do this at your own risk. To the best of my knowledge these are waste/unreleased files caused by the bluetooth hanging in connecting mode but I take no responsibility if they are actually important and result in any damage(s).
This workaround requires that your root your phone. You will need to have super user access (su) where you see the # sign. We will simply be executing the following commands to list and delete the core.xxxx that we assume are the unreleased/waste files taking up space:
lists:
su
ls -al /data/btips
deletes:
su
rm /data/btips/core*
1. You will also need to install Better Terminal Emulator -Free from the apps store. Note: This app crashes on me when in landscape mode, so you might only be able to use it in portrait.
2. Open up Better Terminal. Press Menu > Preferences
3.(Optional) Turn on Volume Up shortcut and assign: su (enter key) ls -al /data/btips (enter key)
This will give you the ability to quickly list your files in the data/btips directory. Most of them will have 0 - 1002 beside them. This is the size. If you see something significantly larger it is probably an unreleased file waste file. This is only for your reference to view the files and is not really necessary for recovering your space. Next come the part where we actually delete them!
4. Turn on Volume Down shortcut and assign: su (enter key) rm /data/btips/core* (enter key)
5. Try it out. Go to Terminal screen. Press up to activate shortcut to list files(optional). Press down to delete them. If you don't have any unreleased/ waste files it will give you no such file notice obviously. My notice is cut off in portrait mode. These shortcuts will be active when you open the terminal app for quick list and delete. This allows you to manually but quickly recover your storage space.
Thanks to jonnythan for finding the diectory and files:
http://community.sprint.com/baw/thread/23854?tstart=0
I love how these things make the rounds on all the forums!
http://forum.xda-developers.com/showthread.php?t=582823
Tell me about it! I like to keep an eye on all the forums, each one offers something a bit different. My bluetooth thanks you for your help, finally it's no longer sitting in the corner! Now hopefully we get a fix for that pesky connecting issue, it seems to actually be connecting but just hanging somewhere.
elguapo76 said:
Note: This app crashes on me when in landscape mode, so you might only be able to use it in portrait.
Click to expand...
Click to collapse
This only happens to me when I attempt to rotate to landscape mode with the software keyboard already open.
If I close the software keyboard, rotate to landscape, and reopen the keyboard then the application never crashes on me.
Package this up into an app that executes with a button press.
Treefallingquietly said:
Package this up into an app that executes with a button press.
Click to expand...
Click to collapse
Better, package it into a Locale add-on so I can make it run whenever I enable/disable BT!
elguapo76 said:
Note: You will be deleting files from your phone so do this at your own risk. To the best of my knowledge these are waste/unreleased files caused by the bluetooth hanging in connecting mode but I take no responsibility if they are actually important and result in any damage(s).
This workaround requires that your root your phone. You will need to have super user access (su) where you see the # sign. We will simply be executing the following commands to list and delete the core.xxxx that we assume are the unreleased/waste files taking up space:
lists:
su
ls -al /data/btips
deletes:
su
rm /data/btips/core*
1. You will also need to install Better Terminal Emulator -Free from the apps store. Note: This app crashes on me when in landscape mode, so you might only be able to use it in portrait.
2. Open up Better Terminal. Press Menu > Preferences
3.(Optional) Turn on Volume Up shortcut and assign: su (enter key) ls -al /data/btips (enter key)
This will give you the ability to quickly list your files in the data/btips directory. Most of them will have 0 - 1002 beside them. This is the size. If you see something significantly larger it is probably an unreleased file waste file. This is only for your reference to view the files and is not really necessary for recovering your space. Next come the part where we actually delete them!
4. Turn on Volume Down shortcut and assign: su (enter key) rm /data/btips/core* (enter key)
5. Try it out. Go to Terminal screen. Press up to activate shortcut to list files(optional). Press down to delete them. If you don't have any unreleased/ waste files it will give you no such file notice obviously. My notice is cut off in portrait mode. These shortcuts will be active when you open the terminal app for quick list and delete. This allows you to manually but quickly recover your storage space.
Thanks to jonnythan for finding the diectory and files:
http://community.sprint.com/baw/thread/23854?tstart=0
Click to expand...
Click to collapse
This is a life saver. Im the OP from the Sprint forums. Ill give it a try tonight.
I've tried this a couple of times and I keep getting: cannot remove '/data/btips/core*' : No such file or directory. Has this happened to anyone else? I really would like to use the bluetooth on this phone. Any help is appreciated.
ejqr5 said:
I've tried this a couple of times and I keep getting: cannot remove '/data/btips/core*' : No such file or directory. Has this happened to anyone else? I really would like to use the bluetooth on this phone. Any help is appreciated.
Click to expand...
Click to collapse
Not 100 percent sure but I believe that message means there are no waste files created yet. The reason the op instructs to create the shortcut actions in better terminal, is so you can use your Bluetooth and while using it, these files will build up and with the shortcuts it gives you a fast way to delete them, successfully "working around" the memory leak, until a fix is found/released.
[Q] terminal command "touch ./*" doesn't work; only when I specify a single file
Here's a background of my problem. I copied an audio book from my computer to my phone (galaxy s2 i777 with AOKP jellybean). I import it into BeyondPod to play, but it tries to play the files by date rather than alphanumeric order. Apparently when the files are copied over it isn't done in any kind of order, so the modified dates are all out of order.
I figured an easy solution would be to use a terminal app and just do a
touch ./*
in the proper directories. However, when I try that I get the error
touch: usage: touch [-alm] [-t time_t] <file>
If I specify a single file, or even use wildcards that only match a single file, then touch works properly. Is there an easy way to get it to touch every file without doing each one manually? I tried using two different terminal apps, "Android terminal emulator" and "Terminal IDE", and both had the same problem.
I don't need to use touch of course, any solution wold work so that sorting by modified date matches the alphanumeric order.
bjgood said:
Here's a background of my problem. I copied an audio book from my computer to my phone (galaxy s2 i777 with AOKP jellybean). I import it into BeyondPod to play, but it tries to play the files by date rather than alphanumeric order. Apparently when the files are copied over it isn't done in any kind of order, so the modified dates are all out of order.
I figured an easy solution would be to use a terminal app and just do a
touch ./*
in the proper directories. However, when I try that I get the error
touch: usage: touch [-alm] [-t time_t] <file>
If I specify a single file, or even use wildcards that only match a single file, then touch works properly. Is there an easy way to get it to touch every file without doing each one manually? I tried using two different terminal apps, "Android terminal emulator" and "Terminal IDE", and both had the same problem.
I don't need to use touch of course, any solution wold work so that sorting by modified date matches the alphanumeric order.
Click to expand...
Click to collapse
I was able to work around this by using
find . -exec touch -m {} \;
in case anyone else has this same problem (good luck searching for "touch" relating to cell phones though)
By installing "Debian noroot" and "WINE" you can run StarCraft natively in x86 Android device. No cpu emulation is needed.
This guide is for x86 (Intel) based tablet only. This should not require a rooted device. You will need enough free space in the internal storage to hold Debian noroot+wine+StarCraft CD. I am guessing about 1.5GB. It will be much easier to set up if you use a Bluetooth keyboard as some typing is needed in the Debian terminal. Update:Feb-5-2015 Fix choppy audio for Starcraft (at http : // androidforums.com / threads / guide-run-starcraft-in-x86-android-tablet.893425 / )
1. Install "Debian noroot" [by Pelya] from Google Play
** I am not allow to post outside link, just search for debian noroot in Google Play
- recoommand also install the hacker's pc keryboard
2. In app list find "Debian" app and run it, it will download 600MB of Debian image. Once it is done you will see a Xfce desktop Environment.
3. double tap on "Enable Audio" icon to install pulseaudio package, this will download another 100MB
4. double tap on "Root Terminal" icon to launch privilige user terminal. the device back button show/hide the soft keyboard.
type "apt-get install wine"
type "apt-get install libgl1-mesa-swx11-i686" (software-based OpenGL)
5. Connect android device to Windows host. Have your Starcraft CD in CD drive. I assume CD drive is at D:
6. Android Debian have no HW openGL support, we need to tell WINE not to use opengl. Create a text file in Windows host named it something like no_opengl.reg, put following lines in it:
REGEDIT4
[HKEY_CURRENT_USER\Software\Wine\Direct3D]
"DirectDrawRenderer"="gdi"
"OffscreenRenderingMode"="backbuffer"
"RenderTargetLockMode"="disabled"
7. Download Starcarft 1.16.1 (SC-1161.exe) patch from Battle.Net support. Open a windows cmd prompt, type:
adb shell mkdir /sdcard/SCCD
-this will copy all StarCraft CD files to /sdcard/SCCD/
adb push D: /sdcard/SCCD/
adb push SC-1161.exe /sdcard/SCCD/
-copy reg file too
adb push no_opengl.reg /sdcard/SCCD/
8. Back to device Android Debian, double tap on the terminal icon (not root terminal) to open a terminal
- to disable opengl for wine type this
regedit /sdcard/SCCD/no_opengl.reg
- now install StarCraft from SCCD
wine /sdcard/SCCD/setup.exe
- the StarCraft setup will run , install game as usual, I put game under c:\StarCraft\ for easy access
wine /sdcard/SCCD/SC-1161.exe // patch SC to latest version
- StarCraft.exe will not look for CD if you copy install.exe and put it in C:\StarCraft\StarCraft.mpq
cd .wine/drive_c/StarCraft
ln -s /sdcard/SCCD/install.exe StarCraft.mpq // symblic link works, no need to copy
9. Now shutdown Android Debian, (tap on the red arrow under "Menu" side bar)
10. Start "Debian" again , select device configuration
under video Settings -> enable 4:3 aspect ratio
- if you want mouse pointer track your touch point
under Mouse Emulation -> advance features-> disable Relative Mouse Movement
tap ok to continue
tap the screen again when you see resolution change message
tap the word "custom" and give 640 width and 480 height.
select your prefer font scale, continue to desktop
11. double tap on terminal, type "wine C:/StarCraft/StarCraft,exe" to launch StarCraft
12. If all goes well you will see the main menu and touch should works. Try start a new game. You will hear choppy or no audio. That is an known issue of Debian noroot. I have no fix for the audio at this time.
13. You can create a Xfce desktop launch icon to run game later.
P.S this process should works for other 2D Windows games that don't require CD to play.
Hi,
I have tryied your method here http://androidforums.com/threads/guide-run-starcraft-in-x86-android-tablet.893425/ in order to avoid chop sound at wine, but when i make ./wine-audio it says "no such file or directory"... what may im doing wrong? Is it normal?
Thanks!
I want to automate (using Automate app) on Nougat 7.0 rooted Nexus 5X :
screen capture
open FiiNote
paste it by sending Ctrl+V
I have tried :
Ctrl+V tasker plugins (doesnt work),
Autoinput plugin (works but require to touch the page to focus then paste which messes up with the editing page)
Hacker’s Keyboard GUI automation (works but very slow it takes around 5 seconds to switch keyboard, show keyboard, press ctrl press v then switch keyboard again).
test external keyboard Ctrl+V; works but it is not what I intend using just wanted to know whether the paste works on FiiNote
but it means that if there is a workaround using root shell command it can work.
maybe is it possible to capture the Ctrl+V command from external keyboard and use that?