This repository has been archived by the owner on Jun 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathph_mto.cpp
49 lines (48 loc) · 1.54 KB
/
ph_mto.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <string>
using namespace std;
int main() {
cout << "Phitherek_' s MTO - Mic-To-Output for PulseAudio v. 0.1" << endl;
system("echo $HOME > /tmp/ph_mto_homedir");
ifstream home("/tmp/ph_mto_homedir");
string houm;
home >> houm;
remove("/tmp/ph_mto_homedir");
string path = houm + "/.ph_mto/module_id";
ifstream test(path.c_str());
if(test) {
cout << "Disabling PulseAudio microphone output..." << endl;
ifstream in(path.c_str());
string id;
in >> id;
string cmd = "pactl unload-module " + id;
system(cmd.c_str());
cout << "Killing all instances of PAVUControl..." << endl;
system("killall pavucontrol");
cout << "Deleting the module_id data..." << endl;
remove(path.c_str());
cout << "Setting status..." << endl;
path = houm + "/.ph_mto/status";
remove(path.c_str());
ofstream status(path.c_str());
status << 0;
status.close();
in.close();
cout << "Done! Thank you for using MTO!" << endl;
} else {
cout << "Enabling PulseAudio microphone output..." << endl;
system("pactl load-module module-loopback > $HOME/.ph_mto/module_id");
cout << "Starting PAVUControl - don' t exit from it! Exiting will cause delay to microphone output!" << endl;
system("pavucontrol&");
cout << "Setting status..." << endl;
path = houm + "/.ph_mto/status";
ofstream status(path.c_str());
status << 1;
status.close();
cout << "Done! Thank you for using MTO! Run it again to disable PulseAudio microphone output!" << endl;
}
test.close();
return EXIT_SUCCESS;
}