-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
37 lines (28 loc) · 1.05 KB
/
main.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
#include <iostream>
#include <string>
#include <array>
#include <memory>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <thread>
#include <chrono>
int main() {
system("xterm -xrm 'XTerm.vt100.allowTitleOps: false' -T \"bgterm\" -bg black -fg green &");
std::this_thread::sleep_for(std::chrono::milliseconds(50));
std::array<char, 128> buffer;
std::string windowIdList;
FILE* pipe = popen("wmctrl -l | grep \"bgterm\" | awk '{print $1}'", "r");
while (fgets(buffer.data(), buffer.size(), pipe) != nullptr) {
windowIdList += buffer.data();
}
pclose(pipe);
std::istringstream stream(windowIdList);
std::string lastId;
while (stream >> lastId);
std::stringstream hexStream;
hexStream << "0x" << std::uppercase << std::hex << std::stoul(lastId, nullptr, 16);
std::string windowId = hexStream.str();
system(("wmctrl -i -r " + windowId + " -b add,fullscreen; wmctrl -i -r " + windowId + " -b add,skip_taskbar; wmctrl -i -r " + windowId + " -b add,below").c_str());
return 0;
}