How to automatically start and advance a few steps in an application in background in linux? - linux

I'm using Genymotion to run WhatsApp on Ubuntu 13.04 as I don't own an Android.
To get to Whatsapp everytime I login, I have to
1) open terminal and run ~genymotion/genymotion
2) click a button on the GUI which opens up another new window (play button).
3) wait for about 30s for the device to get ready.
How can I make the computer do these first two steps automatically for me at start up?
Even better if it possible to do them in background, i.e., I shouldn't see the GUI opening. It should perform the steps and be "minimized".
I was thinking if there was a way to record what my click does and then put it in a script.
Something like a strace command.
I hope my question is clear enough. I'm relatively new to Linux.

For now Genymotion allows you to start a VM from the command line, by calling the "player" binary, and passing the VM name as a parameter.
You could write a shell script that:
run: <GENYMOTION PATH>/player --vm-name <VM NAME>,
wait some seconds for the VM to boot: sleep 10,
then use adb to start your Application: adb shell am start -n com.whatsapp/com.whatsapp.Main
Luckily, no need to simulate clicks for this.

Related

How do I grant a cron job webcam access in Mac OSX Mojave?

In OSX Mojave, access to the camera is controlled by pop-up dialogs and the new System Preferences>>Security & Privacy>>Privacy>>camera panel, where apps can be granted (or denied) access to the camera.
I can grant "iterm2" access to the camera, which lets me run imagesnap from the commandline.
I use a cron job to capture a photograph of the cat bed every 60 seconds. This now fails, since upgrade to Mojave, because it does not have permission to access the camera. Is there any way I can give my cron job access? I don't get a pop-up dialog for a cron job.
Using an Automator application wrapper also works. Create the wrapper (run shell script), run in manually and grant it permission. Then the cron job can call the Automator app.
I hacked around this by using a wrapper script that indirects through Applescript to use iTerm, which does have permission, and have cron launch the wrapper.
#!/bin/bash
osascript << EOF 2>&1 | grep -v "window id"
tell application "iTerm"
create window with default profile command "/path/to/capturescript"
end tell
EOF
FWIW - Mojave broke this further, and the Automator app broke.
I lost a lot of time fiddling with it, and then gave up. It seems the security of camera devices changed again. My time is expensive and raspberry pis are cheap; I connected the camera to a pi and now access it from cron with "ssh pi fswebcam - > output.jpg" which works flawlessly.
Open Automator on Mac.
Click New Document.
Choose Application.
In search bar search for Run Shell Script and add to application with click.
Add code for running your desired script (like you would run the script from shell).
On top right click Run.
Allow access to camera.
With installed cronjob you should be fine.

How can i do for run an app when ubuntu start?

Hi i tried in several ways to launch firefox by example at the beginning, obviously my machine enters automatically to ubuntu without ask for user or password, so i made a script like that : firefox url. And i put this script on cron with the parameter : #reboot + path of my script but it doesn't works, because firefox is not launched, is not only firefox i need to will able to launch as well gedit when ubuntu start, i hope that can i help me whit this.
By the way i have ubuntu 14.04
Thanks
Go to Startup Applications via dash
There, add firefox ...
You can specify the URL to open by writing the command:
firefox URL
This will open URL in the browser. No script needed...
you don't need a script for this.
Ubuntu has a GUI for managing startup applications called "startup applications"
Click the Search button at the top of the Unity bar
Search for "Startup applications" and press enter
In the GUI you can press "add" and enter a custom command of your choice
Also look at existing entries to see how it is done.

WindowManger notifies activity

I'm looking for a tiling window manager that support notification of activity.
What I mean for it?
Let's say that I have a terminal command running on workspace 1, because it is a very slow command I would like to be notify when the prompt appears again. When it is running I'm working on workspace 2.
Another example, I usually keep the thunderbird on a workspace. Let's say that it is workspace 4. When I receive a new email, the workspace 4 notifies me. Why not use the thunderbird notification? It is huge and usually take all the space of my terminal when I'm working with 2 or 3 opened.
Someone knows a tile WM that supports this type of notification?
Another good example is the screen command. I can configure it to monitor the terminal and it notifies me when I'm in other terminal.
Thanks.

Need to schedule Cygwin Expect Script with Windows Task Scheduler

I am currently in the process of implementing a backup scheme to run a Cygwin Expect Script. What I would like to do is have task scheduler open Cygwin and run an expect script called Backups.
The issue that I run into is what I believe to be either variable or path based. I have the correct user from Active directory (we'll call it AD/svc_backup) set, and I am currently trying to just see if I can get the task scheduler to open Cygwin.
So far it will only open the program if I have the run only when user is logged on radio button pressed. This will open cygwin, but not let me run any further commands and gives me an error.
For example ls gives me "bash: ls: command not found" When it asks what program I want to start, I simply point it to the shortcut on my desktop and it then fills in the path C:\cygwin\bin\mintty.exe . Task scheduler does not seem like the most intuitive tool IMO but if I can get it to work I will use it. I also know that cygwin can use cron as well. Would cron be a better option?
I figured it out. So what the system means by the button "run only when user is logged on" radio button pressed" means is I want the script to run and I want to see it run with the local usr account. (interactive with the user)
The "run whether the user is logged in or not" button turns whatever script or program you run into a background service that has no user interactivity( you cant see it). By using the full path under the actions tab in cygwin I was able to tell it which script to run. Script path and options are like so:
C:\cygwin\bin\bash.exe -l -c C:/cygwin/home/svc_p_cisco_bkp/
I have been researching the -l and -c arguments and from what I can gather the -l means list the output and the -c means run these commands. This was not listed anywhere but from what I read it is as educated of an answer as I can give. Also I tested and the script will not run correctly without these variables.
I don't see the script start when I check the "run whether the user is logged in or not" button, but I can see the backups going to my destination folder. I do see it when "run only when user is logged on" however. What I did was get the script running the way I wanted while I could see it and then choose the "run whether the user is logged in or not" radio button when I know it was working correctly.
All is up and running and after exhausting reading of pages and pages about Windows task scheduler, and I am fully automated.

Setting Programs on Redhat5 Startup

I have a Redhat 5 OS, a dual monitor setup, and two workspace. When the machine reboots, I want to set the following:
On workspace 1,
* run the thunderbird-client on the left monitor.
* run 3 terminal clients on the right monitor.
On workspace 2,
* run firefox on the right monitor.
Can someone point me as to where I can set these settings? I am sure there is a way since when my machine boots up, couple of terminal clients pops up, my irc chat client pops up as well. I do not know how I did this before.
You could try Devil's Pie (yum install devilspie)
It's a tool for creating rules that will bind specific actions to applications as they are launched (i.e. setting workspace, position, transparency, etc...).
I found some doc here: http://www.foosel.org/linux/devilspie and here: http://live.gnome.org/DevilsPie
Of course, saving your workspace on logout can help too (System > Preferences > More Preferences > Sessions, then check "Automatically save changes to session").
Once you have setup your application rules, you could write a simple Bash script to start them all in sequence, and add that script to the Startup programs in the sessions preferences.

Resources