-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpotifyController.cpp
More file actions
61 lines (54 loc) · 1.35 KB
/
Copy pathSpotifyController.cpp
File metadata and controls
61 lines (54 loc) · 1.35 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
/*
* SpotifyController.cpp
*
* Created on: 26.12.2016
* Author: oliver
*/
#include <SpotifyController.h>
SpotifyController::SpotifyController() {
// TODO Auto-generated constructor stub
mainPage = true;
spotifyPid = -1;
}
SpotifyController::~SpotifyController() {
// TODO Auto-generated constructor stub
killSpotify();
}
void SpotifyController::startSpotify() {
logline("startSpotify", true);
killSpotify();
execToString(
"rm .config/spotify/Users/lazybean93-user/*.bnk >/dev/null 2>&1 &");
spotifyPid =
atoi(
execToString(
"spotify 1>/dev/null 2>" + Variables::instance().getTempLogFile()
+ " & echo $!").c_str());
mainPage = true;
}
void SpotifyController::killSpotify() {
bool success = true;
if (spotifyPid == -1)
spotifyPid = getProcIdByName("/usr/share/spotify/spotify");
while (success && spotifyPid != -1) {
kill(spotifyPid, SIGTERM);
readFile(
"/proc/" + numToString(spotifyPid)
+ "/stat", &success);
usleep(0.1 * 1000000);
}
spotifyPid = -1;
deleteFolder(Variables::instance().getHomeDir() + "/.cache/spotify");
}
void SpotifyController::setMainPage(bool mainPage) {
this->mainPage = mainPage;
}
bool SpotifyController::getMainPage() {
return mainPage;
}
int SpotifyController::getSpotifyPid() {
return spotifyPid;
}
void SpotifyController::setSpotifyPid(int pid) {
spotifyPid = pid;
}