Merge pull request #3 from vaxerski/revert-2-master

Revert "init man documentation"
This commit is contained in:
Vaxry 2022-08-18 14:54:30 +02:00 committed by GitHub
commit 872cd6083d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 0 additions and 205 deletions

View File

@ -1,7 +1,5 @@
#pragma once #pragma once
#define HAVE_HYPR
#include <json/json.h> #include <json/json.h>
#ifdef HAVE_LIBDATE #ifdef HAVE_LIBDATE
#include "modules/clock.hpp" #include "modules/clock.hpp"
@ -27,9 +25,6 @@
#include "modules/hyprland/backend.hpp" #include "modules/hyprland/backend.hpp"
#include "modules/hyprland/window.hpp" #include "modules/hyprland/window.hpp"
#endif #endif
#ifdef HAVE_HYPR
#include "modules/hypr/window.hpp"
#endif
#if defined(__linux__) && !defined(NO_FILESYSTEM) #if defined(__linux__) && !defined(NO_FILESYSTEM)
#include "modules/battery.hpp" #include "modules/battery.hpp"
#endif #endif

View File

@ -1,22 +0,0 @@
#pragma once
#include <fmt/format.h>
#include <sigc++/sigc++.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include <cstring>
#include <fstream>
#include <memory>
#include <mutex>
#include <spdlog/spdlog.h>
#include "bar.hpp"
#include "client.hpp"
namespace waybar::modules::hypr {
std::string makeRequest(std::string);
} // namespace waybar::modules::hypr

View File

@ -1,23 +0,0 @@
#pragma once
#include <fmt/format.h>
#include <fstream>
#include <sys/statvfs.h>
#include "ALabel.hpp"
#include "util/sleeper_thread.hpp"
#include "util/format.hpp"
#include "ipc.hpp"
namespace waybar::modules::hypr {
class Window : public ALabel {
public:
Window(const std::string&, const Json::Value&);
~Window() = default;
auto update() -> void;
private:
util::SleeperThread thread_;
};
} // namespace waybar::modules::hypr

View File

@ -1,31 +0,0 @@
waybar-hyprland-window(5)
# NAME
waybar - hyprland window module
# DESCRIPTION
The *window* module displays the title of the currently focused window in Hyprland.
# CONFIGURATION
Addressed by *hyprland/window*
*format*: ++
typeof: string ++
default: {} ++
The format, how information should be displayed. On {} the current window title is displayed.
# EXAMPLES
```
"hyprland/window": {
"format": "{}"
}
```
# STYLE
- *#window*

View File

@ -187,12 +187,6 @@ src_files += [
'src/modules/sway/workspaces.cpp' 'src/modules/sway/workspaces.cpp'
] ]
add_project_arguments('-DHAVE_HYPR', language: 'cpp')
src_files += [
'src/modules/hypr/ipc.cpp',
'src/modules/hypr/window.cpp',
]
if true if true
add_project_arguments('-DHAVE_WLR', language: 'cpp') add_project_arguments('-DHAVE_WLR', language: 'cpp')
src_files += 'src/modules/wlr/taskbar.cpp' src_files += 'src/modules/wlr/taskbar.cpp'

View File

@ -61,11 +61,6 @@ waybar::AModule* waybar::Factory::makeModule(const std::string& name) const {
if (ref == "hyprland/window") { if (ref == "hyprland/window") {
return new waybar::modules::hyprland::Window(id, bar_, config_[name]); return new waybar::modules::hyprland::Window(id, bar_, config_[name]);
} }
#endif
#ifdef HAVE_HYPR
if (ref == "hypr/window") {
return new waybar::modules::hypr::Window(id, config_[name]);
}
#endif #endif
if (ref == "idle_inhibitor") { if (ref == "idle_inhibitor") {
return new waybar::modules::IdleInhibitor(id, bar_, config_[name]); return new waybar::modules::IdleInhibitor(id, bar_, config_[name]);

View File

@ -1,86 +0,0 @@
#include "modules/hypr/ipc.hpp"
#include <ctype.h>
#include <netdb.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "util/string.hpp"
std::string waybar::modules::hypr::makeRequest(std::string req) {
const auto SERVERSOCKET = socket(AF_INET, SOCK_STREAM, 0);
if (SERVERSOCKET < 0) {
spdlog::error("[Hypr IPC] Couldn't open a socket.");
return "";
}
const auto SERVER = gethostbyname("localhost");
if (!SERVER) {
spdlog::error("[Hypr IPC] Couldn't get localhost.");
return "";
}
sockaddr_in serverAddress = {0};
serverAddress.sin_family = AF_INET;
bcopy((char*)SERVER->h_addr, (char*)&serverAddress.sin_addr.s_addr, SERVER->h_length);
std::ifstream socketPortStream;
socketPortStream.open("/tmp/hypr/.socket");
if (!socketPortStream.good()) {
spdlog::error("[Hypr IPC] No socket file. Is Hyprland running?");
return "";
}
std::string port = "";
std::getline(socketPortStream, port);
socketPortStream.close();
int portInt = 0;
try {
portInt = std::stoi(port.c_str());
} catch (...) {
spdlog::error("[Hypr IPC] Port not an int?!");
return "";
}
if (portInt == 0) {
spdlog::error("[Hypr IPC] Port 0. Aborting.");
return "";
}
serverAddress.sin_port = portInt;
if (connect(SERVERSOCKET, (sockaddr*)&serverAddress, sizeof(serverAddress)) < 0) {
spdlog::error("[Hypr IPC] Couldn't connect to port {} , is Hyprland running?", port);
return "";
}
auto sizeWritten = write(SERVERSOCKET, req.c_str(), req.length());
if (sizeWritten < 0) {
spdlog::error("[Hypr IPC] Couldn't write to the socket.");
return "";
}
char buffer[8192] = {0};
sizeWritten = read(SERVERSOCKET, buffer, 8192);
if (sizeWritten < 0) {
spdlog::error("[Hypr IPC] Couldn't cread from the socket.");
return "";
}
close(SERVERSOCKET);
return std::string(buffer);
}

View File

@ -1,27 +0,0 @@
#include "modules/hypr/window.hpp"
#include "modules/hypr/ipc.hpp"
using namespace waybar::util;
waybar::modules::hypr::Window::Window(const std::string& id, const Json::Value& config) : ALabel(config, "window", id, "{window}", 0.5f) {
thread_ = [this] {
dp.emit();
thread_.sleep_for(interval_);
};
}
auto waybar::modules::hypr::Window::update() -> void {
auto format = format_;
std::string windowName = waybar::modules::hypr::makeRequest("activewindow");
if (windowName != "")
windowName = windowName.substr(windowName.find_first_of('>') + 2, windowName.find_first_of('\n') - windowName.find_first_of('>') - 3);
event_box_.show();
label_.set_markup(fmt::format(format,
fmt::arg("window", windowName)));
// Call parent update
ALabel::update();
}