Skip to content

Commit 40538f9

Browse files
committed
Added: Command Line Interface
1 parent 1809584 commit 40538f9

File tree

2 files changed

+28
-26
lines changed

2 files changed

+28
-26
lines changed

README.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,24 @@
1-
21
# _Peripheral Killing System_
32

43
Peripheral Killing System is a Python project designed to eliminate the use of mouse and keyboard by allowing users to control their computer's input functions using hand gestures. The project utilizes OpenCV and MediaPipe libraries to detect and track hand movements, enabling users to interact with their computer in a more intuitive and hands-free manner.
54

6-
7-
8-
95
[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/pythonicforge/Peripheral-Killing-System/blob/v0.1.2/LICENSE)
106

11-
12-
13-
147
### _Acknowledgements_
158

169
_This project is built upon the excellent libraries and resources provided by the open-source community. The following resources were used in the development of the Peripheral Killing System:_
1710

1811
- _OpenCV_
1912
- _MediaPipe_
20-
_Special thanks to the developers and contributors of these libraries._
21-
13+
_Special thanks to the developers and contributors of these libraries._
2214

2315
### _Features_
2416

2517
- _Volume Control: Perform a zoom-in gesture (bringing your thumb and little finger together) to increase the volume and a zoom-out gesture (spreading your thumb and little finger apart) to decrease the volume._
26-
- _Brightness Control: Similar to volume control, perform a zoom-in gesture to increase brightness and a zoom-out gesture to decrease brightness._
18+
- _Brightness Control: Similar to volume control, perform a zoom-in gesture to increase brightness and a zoom-out gesture to decrease brightness._
2719
- _Mouse Control: Use your index finger to control the mouse cursor's movement. Perform a left-click by closing your thumb and index finger together._
2820
- _Air Keyboard: Simulate keyboard input using air keyboard gestures. The specific gestures for keyboard input can be implemented based on your requirements._
2921

30-
3122
### _Run Locally_
3223

3324
_Clone the project_
@@ -58,15 +49,14 @@ _Read instructions [here](https://github.com/pythonicforge/Peripheral-Killing-Sy
5849

5950
_*Note: Make sure to install `Python 3.8.5` and setup a `virtualenv` before running this project.*_
6051

61-
6252
### _Contributions_
6353

6454
_Contributions to the Peripheral Killing System project are welcome! If you encounter any issues or have suggestions for improvements, please open an issue on the GitHub repository. Feel free to submit pull requests to contribute your enhancements to the project._
6555

6656
_Before contributing, please review the contribution guidelines._
57+
6758
### _Tech Stack_
6859

6960
_**Client:** Python Tkinter_
7061

7162
_**Server:** Python, OpenCV, Mediapipe_
72-

utils/brain.py

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import multiprocessing as mp
2+
import os
3+
import platform
24
import struct
35
import sys
46
import time
@@ -22,6 +24,15 @@ def check_internet(self):
2224
return True
2325
except requests.ConnectionError:
2426
return False
27+
28+
def clear_terminal(self):
29+
PLATFORM = platform.system()
30+
if PLATFORM == "Windows":
31+
os.system('cls')
32+
elif PLATFORM == "Linux" or PLATFORM == "Darwin":
33+
os.system('clear')
34+
35+
print(colored(f'PERIPHERAL KILLING SYSTEM [0.1.2 release]\nCurrent machine platform: {PLATFORM}\tCurrent mqchine time: {time.ctime()}', color="red"))
2536

2637
def run(self) -> None:
2738
"""
@@ -42,6 +53,7 @@ def run(self) -> None:
4253
"data/no_internet.mp3", "No internet connection available! Please connect to the internet in order to run this software!")
4354
sys.exit()
4455
else:
56+
self.clear_terminal()
4557
self.speaker.say("data/init/1.mp3", "Initializing system!")
4658

4759
audioOBJ = Hear()
@@ -91,17 +103,10 @@ def run(self) -> None:
91103
if (response["transcription"] != None):
92104
query = query.lower().strip()
93105
print(
94-
colored(f"User: {query}", color="blue"))
106+
colored(f"User: {query}", color="yellow"))
95107

96108
if "exit" in query or "stop" in query:
97109
done = True
98-
if (is_brightness_turned_on == True):
99-
is_brightness_turned_on, is_mode_active = False, False
100-
brightness_controller.terminate()
101-
102-
if (is_volume_turned_on == True):
103-
is_volume_turned_on, is_mode_active = False, False
104-
volume_controller.terminate()
105110

106111
self.speaker.say("data/killSystem.mp3",
107112
"Peripheral Killing System terminated. All systems are offline now!")
@@ -123,11 +128,14 @@ def run(self) -> None:
123128
if (is_keyboard_turned_on == True):
124129
is_keyboard_turned_on, is_mode_active = False, False
125130
keyboard_controller.terminate()
131+
132+
self.clear_terminal()
126133
self.speaker.say(
127134
"data/hibernating_system.mp3", "Hibernating now! Call me when you need me!")
128135
break
129136

130137
elif "turn on brightness mode" in query or "turn on brightness control mode" in query:
138+
131139
if (is_mode_active == False):
132140
if (is_brightness_turned_on == False):
133141
is_brightness_turned_on, is_mode_active = True, True
@@ -137,9 +145,11 @@ def run(self) -> None:
137145
else:
138146
self.speaker.say("data/brightness/brightness_already_on.mp3",
139147
"Brightness control mode is already turned on")
148+
140149
else:
141150
self.speaker.say("data/other_system_on.mp3",
142151
"Some other instances of control system are currently running! Please turn them off and try again later!")
152+
self.clear_terminal()
143153

144154
elif "turn off brightness mode" in query or "turn off brightness control mode" in query:
145155
if (is_brightness_turned_on == True):
@@ -152,7 +162,7 @@ def run(self) -> None:
152162
else:
153163
self.speaker.say("data/brightness/no_brightness.mp3",
154164
"No brightness control console is currently turned on. No actions taken!")
155-
165+
self.clear_terminal()
156166
elif "turn on volume mode" in query or "turn on volume control mode" in query:
157167
if (is_mode_active == False):
158168
if (is_volume_turned_on == False):
@@ -166,7 +176,7 @@ def run(self) -> None:
166176
else:
167177
self.speaker.say("data/other_system_on.mp3",
168178
"Some other instances of control system are currently running! Please turn them off and try again later!")
169-
179+
self.clear_terminal()
170180
elif "turn off volume mode" in query or "turn off volume control mode" in query:
171181
if (is_volume_turned_on == True):
172182
is_volume_turned_on, is_mode_active = False, False
@@ -178,7 +188,7 @@ def run(self) -> None:
178188
else:
179189
self.speaker.say("data/volume/no_volume.mp3",
180190
"No volume control console is currently turned on. No actions taken")
181-
191+
self.clear_terminal()
182192
elif "turn on mouse mode" in query or "turn on mouse control mode" in query:
183193
if (is_mode_active == False):
184194
if (is_mouse_turned_on == False):
@@ -192,7 +202,7 @@ def run(self) -> None:
192202
else:
193203
self.speaker.say("data/other_system_on.mp3",
194204
"Some other instances of control system are currently running! Please turn them off and try again later!")
195-
205+
self.clear_terminal()
196206
elif "turn off mouse mode" in query or "turn off mouse control mode" in query:
197207
if (is_mouse_turned_on == True):
198208
is_mouse_turned_on, is_mode_active = False, False
@@ -204,6 +214,7 @@ def run(self) -> None:
204214
else:
205215
self.speaker.say("data/mouse/no_mouse.mp3",
206216
"No mouse control console is currently turned on. No actions taken!")
217+
self.clear_terminal()
207218
elif "turn on keyboard mode" in query or "turn on keyboard control mode" in query:
208219
if (is_mode_active == False):
209220
if (is_keyboard_turned_on == False):
@@ -217,7 +228,7 @@ def run(self) -> None:
217228
else:
218229
self.speaker.say("data/other_system_on.mp3",
219230
"Some other instances of control system are currently running! Please turn them off and try again later!")
220-
231+
self.clear_terminal()
221232
elif "turn off keyboard mode" in query or "turn off keyboard control mode" in query:
222233
if (is_keyboard_turned_on == True):
223234
is_keyboard_turned_on, is_mode_active = False, False
@@ -229,6 +240,7 @@ def run(self) -> None:
229240
else:
230241
self.speaker.say("data/keyboard/no_keyboard.mp3",
231242
"No keyboard control console is currently turned on. No actions taken!")
243+
self.clear_terminal()
232244
else:
233245
pass
234246
elif query == None:

0 commit comments

Comments
 (0)