mirror of
				https://github.com/rad4day/Waybar.git
				synced 2025-10-31 07:52:42 +01:00 
			
		
		
		
	 047473e5a4
			
		
	
	047473e5a4
	
	
	
		
			
			I/usr/include/libdbusmenu-glib-0.4 -flto -fdiagnostics-color=always -DNDEBUG -pipe -D_FILE_OFFSET_BITS=64 -std=c++17 -DHAVE_SWAY -DHAVE_LIBPULSE -DHAVE_DBUSMENU -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -D_REENTRANT -pthread -MD -MQ 'waybar@exe/src_modules_sway_ipc_client.cpp.o' -MF 'waybar@exe/src_modules_sway_ipc_client.cpp.o.d' -o 'waybar@exe/src_modules_sway_ipc_client.cpp.o' -c ../src/modules/sway/ipc/client.cpp ../src/modules/sway/ipc/client.cpp: In member function 'int waybar::modules::sway::Ipc::open(const string&) const': ../src/modules/sway/ipc/client.cpp:47:3: error: 'strncpy' was not declared in this scope strncpy(addr.sun_path, socketPath.c_str(), sizeof(addr.sun_path) - 1); ^~~~~~~ ../src/modules/sway/ipc/client.cpp:47:3: note: 'strncpy' is defined in header '<cstring>'; did you forget to '#include <cstring>'? ../src/modules/sway/ipc/client.cpp:2:1: +#include <cstring> ../src/modules/sway/ipc/client.cpp:47:3: strncpy(addr.sun_path, socketPath.c_str(), sizeof(addr.sun_path) - 1); ^~~~~~~ [36/44] Compiling C++ object 'waybar@exe/src_modules_custom.cpp.o'. [37/44] Compiling C++ object 'waybar@exe/src_client.cpp.o'. [38/44] Compiling C++ object 'waybar@exe/src_modules_cpu.cpp.o'. ninja: build stopped: subcommand failed.
		
			
				
	
	
		
			43 lines
		
	
	
		
			902 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			902 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| #pragma once
 | |
| 
 | |
| #include <iostream>
 | |
| #include <cstring>
 | |
| #include <unistd.h>
 | |
| #include <sys/socket.h>
 | |
| #include <sys/un.h>
 | |
| #include "ipc.hpp"
 | |
| 
 | |
| namespace waybar::modules::sway {
 | |
| 
 | |
| class Ipc {
 | |
|   public:
 | |
|     Ipc();
 | |
|     ~Ipc();
 | |
| 
 | |
| 		struct ipc_response {
 | |
| 			uint32_t size;
 | |
| 			uint32_t type;
 | |
| 			std::string payload;
 | |
| 		};
 | |
| 
 | |
| 		void connect();
 | |
| 		struct ipc_response sendCmd(uint32_t type,
 | |
| 			const std::string& payload = "") const;
 | |
| 		void subscribe(const std::string& payload) const;
 | |
| 		struct ipc_response handleEvent() const;
 | |
|   protected:
 | |
| 		static inline const std::string ipc_magic_ = "i3-ipc";
 | |
| 		static inline const size_t ipc_header_size_ = ipc_magic_.size() + 8;
 | |
| 
 | |
| 		const std::string getSocketPath() const;
 | |
| 		int open(const std::string&) const;
 | |
| 		struct ipc_response send(int fd, uint32_t type,
 | |
| 			const std::string& payload = "") const;
 | |
| 		struct ipc_response recv(int fd) const;
 | |
| 
 | |
| 		int fd_;
 | |
| 		int fd_event_;
 | |
| };
 | |
| 
 | |
| }
 |