-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbbswitcher.cpp
More file actions
49 lines (45 loc) · 1.16 KB
/
bbswitcher.cpp
File metadata and controls
49 lines (45 loc) · 1.16 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
#include "bbswitcher.hpp"
#include <QProcess>
#include <QDebug>
#include "log.h"
bbswitcher::bbswitcher(QObject *parent) : QObject(parent)
{
f.setFileName("/proc/acpi/bbswitch");
}
void bbswitcher::open()
{
f.open(QFile::WriteOnly);
if (!f.isOpen())
{
QProcess::execute("sudo chmod a+w /proc/acpi/bbswitch");
Log::addLog("ow:INFO:According myself rights to bbswitch");
if (!f.open(QFile::WriteOnly))
Log::addLog("ow:ERROR:COULD NOT OPEN BBSWITCH!");
}
}
void bbswitcher::poweron()
{
if (QFile::exists("/tmp/lockopti_watcher") == false)
{
this->open();
Log::addLog("ow:INFO:Powering on card");
if (this->f.write("ON\n") == -1)
Log::addLog("ow:ERROR:COULD NOT WRITE ON");
this->f.close();
}
else
Log::addLog("ow:INFO:Nothing, locked...");
}
void bbswitcher::poweroff()
{
if (QFile::exists("/tmp/lockopti_watcher") == false)
{
this->open();
Log::addLog("ow:INFO:Powering off card");
if (this->f.write("OFF\n") == -1)
Log::addLog("ow:ERROR:COULD NOT WRITE OFF");
this->f.close();
}
else
Log::addLog("ow:INFO:Nothing, locked...");
}