Don't you find that bit of a struggle when you are sitting comfortable watching a movie on your laptop and someone disturbs you and you have to reach to your keyboard to pause/rewind the movie?
Or maybe your are working on some pretty important task with VLC/youtube running in the background, and isn't it annoying when you have to switch windows in order to change the music?
Not a music or movie lover? But we're sure it is always a discomfort to reach out to keyboard to go to the next page of a document or a presentation.
This was our motivation behind building this project Shake to Switch
. We want people to use gestures to interact with their conputers and believe it or not, your mobile device already contains a dozen sensors in it. So we made an application that uses the accelerometer in your mobile to detect flicks and send them over a socket connection to a server running on your computer.
In simple words:-
- Shake your device softly to the left/right (X axis) for
backwards/forward
signal. - Give a hard shake to left/right for (X axis)
previous/next
signal. - Shake your device towards you or away from you (Z axis) for a
play/pause
signal.
- The server is a python3 script which requires some modules. You can install them inside a virtual environment as follows:
git clone https://github.com/mayanksingh2298/shake-to-switch
cd shake-to-switch
python -m venv venv
source venv/bin/activate
pip install requirements.txt (for linux and mac)
pip install requirements_win.txt (for windows)
- Install
ShakeToSwitch.apk
on your phone.
- Activate the virtual environment on your system.
source venv/bin/activate
- Start the server on your computer.
python server-detect.py
- Open the application on your device.
- Enter the
IP
of your system in the application and click onConnect
. The IP is logged on the terminal when you run the server. - That's it. You can give your device a flick to convey signals to the server.
- Upon receiving a signal from the phone, the server scans the applications running on your system for the supported applications and select the one with the highest priority.
- If that application is not a focussed or active window, we bring that into focus, perform the action and then minimize it.
- If that application was already in focus, we simply do the required task.
- On the app's home screen there is a button which says, "enable this if gestures aren't perfect". You can try that. It basically switches between the Accelerometer senosor and the Linear Acceleration sensor, which rules out gravitational acceleration from measurements.
- In the android app's settings, you can enable or disable specific gestures.
- You can change the threshold for each gesture, i.e. how strong flick is required for the gesture to be detected.
- You can edit the server file to change the priorities, which is line 28 for windows users and line 30 for linux and mac users.
- Linux
- evince or better known as the document reader
- vlc
- chrome (youtube)
- firefox (youtube)
- Windows
- powerpoint
- acrobat reader
- vlc
- chrome (youtube)
- firefox (youtube)
- Avoid controlling 32 bit apps from 64 bit python and vice versa, for non focus mod only, on windows. (works sometimes, sometimes don't, gives warning on terminal always)
- Restart browsers like chrome which start multiple processes on startup because sometimes they open a background invisible window which screws up code.
- If some gesture isn't working, try switching that gesture off and then back on.
- While controlling youtube on chrome/firefox, make sure the tab for youtube is in focus.