This commit is contained in:
Mars 2024-10-19 01:16:21 -04:00
parent 4121e724ed
commit 02d24f4fd1
Signed by: pupbrained
GPG key ID: 0FF5B8826803F895
4 changed files with 116 additions and 245 deletions

View file

@ -6,11 +6,11 @@
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
"lastModified": 1714765312, "lastModified": 1727497393,
"narHash": "sha256-WqZX4PMw4raTRXUliz2cr5yZeIERLq4rjB3DUoxdWn8=", "narHash": "sha256-AHL2qezvAAZtOP61cHtnB0RtqPej4LqtGkvXNOAESNw=",
"owner": "jcdickinson", "owner": "jcdickinson",
"repo": "codeium.nvim", "repo": "codeium.nvim",
"rev": "d3b88eb3aa1de6da33d325c196b8a41da2bcc825", "rev": "17bbefff02be8fd66931f366bd4ed76a76e4a57e",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -21,7 +21,6 @@
}, },
"devshell": { "devshell": {
"inputs": { "inputs": {
"flake-utils": "flake-utils_3",
"nixpkgs": [ "nixpkgs": [
"nixvim", "nixvim",
"nixvim", "nixvim",
@ -29,11 +28,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1717408969, "lastModified": 1722113426,
"narHash": "sha256-Q0OEFqe35fZbbRPPRdrjTUUChKVhhWXz3T9ZSKmaoVY=", "narHash": "sha256-Yo/3loq572A8Su6aY5GP56knpuKYRvM2a1meP9oJZCw=",
"owner": "numtide", "owner": "numtide",
"repo": "devshell", "repo": "devshell",
"rev": "1ebbe68d57457c8cae98145410b164b5477761f4", "rev": "67cce7359e4cd3c45296fb4aaf6a19e2a9c757ae",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -56,22 +55,6 @@
"url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"
} }
}, },
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": { "flake-parts": {
"inputs": { "inputs": {
"nixpkgs-lib": [ "nixpkgs-lib": [
@ -81,11 +64,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1717285511, "lastModified": 1726153070,
"narHash": "sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw=", "narHash": "sha256-HO4zgY0ekfwO5bX0QH/3kJ/h4KvUDFZg8YpkNwIbg1U=",
"owner": "hercules-ci", "owner": "hercules-ci",
"repo": "flake-parts", "repo": "flake-parts",
"rev": "2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8", "rev": "bcef6817a8b2aa20a5a6dbb19b43e63c5bf8619a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -117,11 +100,11 @@
"systems": "systems_2" "systems": "systems_2"
}, },
"locked": { "locked": {
"lastModified": 1710146030, "lastModified": 1726560853,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -135,11 +118,11 @@
"systems": "systems_3" "systems": "systems_3"
}, },
"locked": { "locked": {
"lastModified": 1701680307, "lastModified": 1726560853,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725", "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -150,7 +133,11 @@
}, },
"git-hooks": { "git-hooks": {
"inputs": { "inputs": {
"flake-compat": "flake-compat_2", "flake-compat": [
"nixvim",
"nixvim",
"flake-compat"
],
"gitignore": "gitignore", "gitignore": "gitignore",
"nixpkgs": [ "nixpkgs": [
"nixvim", "nixvim",
@ -164,11 +151,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1719259945, "lastModified": 1727514110,
"narHash": "sha256-F1h+XIsGKT9TkGO3omxDLEb/9jOOsI6NnzsXFsZhry4=", "narHash": "sha256-0YRcOxJG12VGDFH8iS8pJ0aYQQUAgo/r3ZAL+cSh9nk=",
"owner": "cachix", "owner": "cachix",
"repo": "git-hooks.nix", "repo": "git-hooks.nix",
"rev": "0ff4381bbb8f7a52ca4a851660fc7a437a4c6e07", "rev": "85f7a7177c678de68224af3402ab8ee1bcee25c8",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -209,11 +196,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1719180626, "lastModified": 1727383923,
"narHash": "sha256-vZAzm5KQpR6RGple1dzmSJw5kPivES2heCFM+ZWkt0I=", "narHash": "sha256-4/vacp3CwdGoPf8U4e/N8OsGYtO09WTcQK5FqYfJbKs=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "6b1f90a8ff92e81638ae6eb48cd62349c3e387bb", "rev": "ffe2d07e771580a005e675108212597e5b367d2d",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -231,11 +218,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1719128254, "lastModified": 1727507295,
"narHash": "sha256-I7jMpq0CAOZA/i70+HDQO/ulLttyQu/K70cSESiMX7A=", "narHash": "sha256-I/FrX1peu4URoj5T5odfuKR2rm4GjYJJpCGF9c0/lDA=",
"owner": "lnl7", "owner": "lnl7",
"repo": "nix-darwin", "repo": "nix-darwin",
"rev": "50581970f37f06a4719001735828519925ef8310", "rev": "f2e1c4aa29fc211947c3a7113cba1dd707433b70",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -246,11 +233,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1722885831, "lastModified": 1729311994,
"narHash": "sha256-LZ2AUNCIsp8Sr5cTELR1VmdrWCzuq8B9t24dGWqQs9w=", "narHash": "sha256-qbXHPupmSGjSJkPmmaOSRd6b2kRgAk+CH/FMRWiYdUM=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "6696fd5d8cf6c25387f02327941d2e6e47df6947", "rev": "7e2eb4642f7ca9c4ee2c069d65a48575068b4f57",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -277,11 +264,11 @@
}, },
"nixpkgs_3": { "nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1719444225, "lastModified": 1727742380,
"narHash": "sha256-tSTqQB0C1D4frFJI0ASXW0OWYHwqwcvLGxh9i9ieL40=", "narHash": "sha256-5lFzlmiwrl3OHrw7QhZn/ZpZtygzx1UspKOaZqpxXSQ=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "4c0e0424411ef3bd1f55f5e1025e0934c63bfbff", "rev": "9dc3c339a2aecbd61ab2549248d8b64ba1c28af5",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -292,11 +279,11 @@
}, },
"nixpkgs_4": { "nixpkgs_4": {
"locked": { "locked": {
"lastModified": 1719254875, "lastModified": 1727348695,
"narHash": "sha256-ECni+IkwXjusHsm9Sexdtq8weAq/yUyt1TWIemXt3Ko=", "narHash": "sha256-J+PeFKSDV+pHL7ukkfpVzCOO7mBSrrpJ3svwBFABbhI=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "2893f56de08021cffd9b6b6dfc70fd9ccd51eb60", "rev": "1925c603f17fc89f4c8f6bf6f631a802ad85d784",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -308,32 +295,32 @@
}, },
"nixpkgs_5": { "nixpkgs_5": {
"locked": { "locked": {
"lastModified": 1708475490, "lastModified": 1726871744,
"narHash": "sha256-g1v0TsWBQPX97ziznfJdWhgMyMGtoBFs102xSYO4syU=", "narHash": "sha256-V5LpfdHyQkUF7RfOaDPrZDP+oqz88lTJrMT1+stXNwo=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "0e74ca98a74bc7270d28838369593635a5db3260", "rev": "a1d92660c6b3b7c26fb883500a80ea9d33321be2",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nixos", "owner": "nixos",
"ref": "nixos-unstable", "ref": "nixpkgs-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
}, },
"nixpkgs_6": { "nixpkgs_6": {
"locked": { "locked": {
"lastModified": 1720957393, "lastModified": 1726871744,
"narHash": "sha256-oedh2RwpjEa+TNxhg5Je9Ch6d3W1NKi7DbRO1ziHemA=", "narHash": "sha256-V5LpfdHyQkUF7RfOaDPrZDP+oqz88lTJrMT1+stXNwo=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "693bc46d169f5af9c992095736e82c3488bf7dbb", "rev": "a1d92660c6b3b7c26fb883500a80ea9d33321be2",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nixos", "owner": "nixos",
"ref": "nixos-unstable", "ref": "nixpkgs-unstable",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
@ -347,11 +334,11 @@
"treefmt-nix": "treefmt-nix_2" "treefmt-nix": "treefmt-nix_2"
}, },
"locked": { "locked": {
"lastModified": 1719450216, "lastModified": 1728515236,
"narHash": "sha256-u/nnOqyS7agFU51JqnWZZmdMP+8NxrvA7bgby081bSU=", "narHash": "sha256-gYObAkD39KbYdeSxOxPFaVVgfbRPPgG470E8sFMaQDM=",
"owner": "pupbrained", "owner": "pupbrained",
"repo": "nvim-config", "repo": "nvim-config",
"rev": "6e9c79b8253997c56075f56d291fce35a2ab7095", "rev": "584a15c6dcf5bea4a9ab3c804b86324b128d3b67",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -369,14 +356,15 @@
"home-manager": "home-manager", "home-manager": "home-manager",
"nix-darwin": "nix-darwin", "nix-darwin": "nix-darwin",
"nixpkgs": "nixpkgs_4", "nixpkgs": "nixpkgs_4",
"nuschtosSearch": "nuschtosSearch",
"treefmt-nix": "treefmt-nix" "treefmt-nix": "treefmt-nix"
}, },
"locked": { "locked": {
"lastModified": 1719401747, "lastModified": 1727645871,
"narHash": "sha256-GuY035SXf/wv685mhXsHv/syYh3XT9U8ZDdxr1pGgts=", "narHash": "sha256-Os3PAThU5XliKkKa+SHsFyV/EsCHogHcYONmpzb6500=",
"owner": "nix-community", "owner": "nix-community",
"repo": "nixvim", "repo": "nixvim",
"rev": "53a9599cc4da4f7557995b8611e5dba831261eef", "rev": "5f4a4b47597d3b9ac26c41ff4e8da28fa662f200",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -385,6 +373,29 @@
"type": "github" "type": "github"
} }
}, },
"nuschtosSearch": {
"inputs": {
"flake-utils": "flake-utils_3",
"nixpkgs": [
"nixvim",
"nixvim",
"nixpkgs"
]
},
"locked": {
"lastModified": 1727452028,
"narHash": "sha256-ehl/A4HQFRyqj1Fk7cl+dgSf/2Fb1jLwWJtZaMU6RfU=",
"owner": "NuschtOS",
"repo": "search",
"rev": "9f7426e532ef8dfc839c4a3fcc567b13a20a70d3",
"type": "github"
},
"original": {
"owner": "NuschtOS",
"repo": "search",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
@ -462,11 +473,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1719243788, "lastModified": 1727431250,
"narHash": "sha256-9T9mSY35EZSM1KAwb7K9zwQ78qTlLjosZgtUGnw4rn4=", "narHash": "sha256-uGRlRT47ecicF9iLD1G3g43jn2e+b5KaMptb59LHnvM=",
"owner": "numtide", "owner": "numtide",
"repo": "treefmt-nix", "repo": "treefmt-nix",
"rev": "065a23edceff48f948816b795ea8cc6c0dee7cdf", "rev": "879b29ae9a0378904fbbefe0dadaed43c8905754",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -480,11 +491,11 @@
"nixpkgs": "nixpkgs_5" "nixpkgs": "nixpkgs_5"
}, },
"locked": { "locked": {
"lastModified": 1719243788, "lastModified": 1727431250,
"narHash": "sha256-9T9mSY35EZSM1KAwb7K9zwQ78qTlLjosZgtUGnw4rn4=", "narHash": "sha256-uGRlRT47ecicF9iLD1G3g43jn2e+b5KaMptb59LHnvM=",
"owner": "numtide", "owner": "numtide",
"repo": "treefmt-nix", "repo": "treefmt-nix",
"rev": "065a23edceff48f948816b795ea8cc6c0dee7cdf", "rev": "879b29ae9a0378904fbbefe0dadaed43c8905754",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -498,11 +509,11 @@
"nixpkgs": "nixpkgs_6" "nixpkgs": "nixpkgs_6"
}, },
"locked": { "locked": {
"lastModified": 1722330636, "lastModified": 1729242555,
"narHash": "sha256-uru7JzOa33YlSRwf9sfXpJG+UAV+bnBEYMjrzKrQZFw=", "narHash": "sha256-6jWSWxv2crIXmYSEb3LEVsFkCkyVHNllk61X4uhqfCs=",
"owner": "numtide", "owner": "numtide",
"repo": "treefmt-nix", "repo": "treefmt-nix",
"rev": "768acdb06968e53aa1ee8de207fd955335c754b7", "rev": "d986489c1c757f6921a48c1439f19bfb9b8ecab5",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -516,11 +527,11 @@
"systems": "systems_4" "systems": "systems_4"
}, },
"locked": { "locked": {
"lastModified": 1710146030, "lastModified": 1726560853,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -71,7 +71,6 @@
systemdLibs systemdLibs
sdbus-cpp sdbus-cpp
valgrind valgrind
xorg.libX11
]); ]);
darwinPkgs = nixpkgs.lib.optionals stdenv.isDarwin (with pkgs.pkgsStatic.darwin.apple_sdk.frameworks; [ darwinPkgs = nixpkgs.lib.optionals stdenv.isDarwin (with pkgs.pkgsStatic.darwin.apple_sdk.frameworks; [

View file

@ -57,8 +57,8 @@ fn WriteCacheToFile(const WeatherOutput& data) -> Result<u8> {
return 0; return 0;
} }
fn WriteCallback(void* contents, const size_t size, const size_t nmemb, string* str) -> size_t { fn WriteCallback(void* contents, const usize size, const usize nmemb, string* str) -> usize {
const size_t totalSize = size * nmemb; const usize totalSize = size * nmemb;
str->append(static_cast<char*>(contents), totalSize); str->append(static_cast<char*>(contents), totalSize);
return totalSize; return totalSize;
} }

View file

@ -1,11 +1,9 @@
#ifdef __linux__ #ifdef __linux__
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <cstring> #include <cstring>
#include <filesystem>
#include <fmt/format.h> #include <fmt/format.h>
#include <fstream> #include <fstream>
#include <iostream>
#include <sdbus-c++/sdbus-c++.h> #include <sdbus-c++/sdbus-c++.h>
#include <vector> #include <vector>
@ -13,58 +11,54 @@
enum SessionType { Wayland, X11, TTY, Unknown }; enum SessionType { Wayland, X11, TTY, Unknown };
fn ParseLineAsNumber(const string& input) -> u64 { fn ParseLineAsNumber(const std::string& input) -> u64 {
// Find the first number usize start = input.find_first_of("0123456789");
string::size_type start = 0;
// Skip leading non-numbers if (start == std::string::npos)
while (!isdigit(input[++start])); throw std::runtime_error("No number found in input");
// Start searching from the start of the number usize end = input.find_first_not_of("0123456789", start);
string::size_type end = start;
// Increment to the end of the number return std::stoull(input.substr(start, end - start));
while (isdigit(input[++end]));
// Return the substring containing the number
return std::stoul(input.substr(start, end - start));
} }
fn MeminfoParse(std::ifstream input) -> u64 { fn MeminfoParse(const std::filesystem::path& filepath) -> u64 {
string line; std::ifstream input(filepath);
// Skip every line before the one that starts with "MemTotal" if (!input.is_open())
while (std::getline(input, line) && !line.starts_with("MemTotal")); throw std::runtime_error("Failed to open " + filepath.string());
std::string line;
while (std::getline(input, line))
if (line.starts_with("MemTotal"))
return ParseLineAsNumber(line); return ParseLineAsNumber(line);
throw std::runtime_error("MemTotal line not found in " + filepath.string());
} }
fn GetMemInfo() -> u64 { return MeminfoParse(std::ifstream("/proc/meminfo")) * 1024; } fn GetMemInfo() -> u64 { return MeminfoParse("/proc/meminfo") * 1024; }
fn GetOSVersion() -> string { fn GetOSVersion() -> std::string {
std::ifstream file("/etc/os-release"); std::ifstream file("/etc/os-release");
if (!file.is_open()) { if (!file.is_open())
std::cerr << "Failed to open /etc/os-release" << std::endl; throw std::runtime_error("Failed to open /etc/os-release");
return ""; // Return empty string indicating failure
}
string line; string line;
const string prefix = "PRETTY_NAME="; const string prefix = "PRETTY_NAME=";
while (std::getline(file, line)) { while (std::getline(file, line))
if (line.find(prefix) == 0) { if (line.starts_with(prefix)) {
string prettyName = line.substr(prefix.size()); string prettyName = line.substr(prefix.size());
// Remove surrounding quotes if present
if (!prettyName.empty() && prettyName.front() == '"' && prettyName.back() == '"') if (!prettyName.empty() && prettyName.front() == '"' && prettyName.back() == '"')
prettyName = prettyName.substr(1, prettyName.size() - 2); return prettyName.substr(1, prettyName.size() - 2);
return prettyName; return prettyName;
} }
}
return ""; // Return empty string if PRETTY_NAME= line not found throw std::runtime_error("PRETTY_NAME line not found in /etc/os-release");
} }
fn GetMprisPlayers(sdbus::IConnection& connection) -> std::vector<string> { fn GetMprisPlayers(sdbus::IConnection& connection) -> std::vector<string> {
@ -138,137 +132,4 @@ fn GetNowPlaying() -> string {
return ""; return "";
} }
fn GetDesktopEnvironment() -> string {
const char* xdgCurrentDesktop = std::getenv("XDG_CURRENT_DESKTOP");
if (xdgCurrentDesktop)
return xdgCurrentDesktop;
return std::getenv("DESKTOP_SESSION");
}
fn GetSessionType() -> SessionType {
string xdgSessionType = std::getenv("XDG_SESSION_TYPE");
if (xdgSessionType == "wayland")
return Wayland;
if (xdgSessionType == "x11")
return X11;
if (xdgSessionType == "tty")
return TTY;
return Unknown;
}
fn Exec(const char* cmd) -> string {
std::array<char, 128> buffer;
std::string result;
std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
if (!pipe) {
throw std::runtime_error("popen() failed!");
}
while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) { result += buffer.data(); }
return result;
}
fn GetWindowManager() -> string {
string xdgSessionType = std::getenv("XDG_SESSION_TYPE");
if (xdgSessionType == "wayland") {
// TODO implement wayland window manager
}
if (xdgSessionType == "x11") {
Display* display = XOpenDisplay(nullptr);
Atom wmCheckAtom = XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", True);
if (wmCheckAtom == None) {
return "Unknown (no _NET_SUPPORTING_WM_CHECK)";
}
Window root = DefaultRootWindow(display);
Atom actualType = 0;
int actualFormat = 0;
unsigned long itemCount = 0, bytesAfter = 0;
unsigned char* data = nullptr;
int status = XGetWindowProperty(
display,
root,
wmCheckAtom,
0,
1,
False,
XA_WINDOW,
&actualType,
&actualFormat,
&itemCount,
&bytesAfter,
&data
);
if (status != Success || !data) {
return "Unknown (failed to get _NET_SUPPORTING_WM_CHECK)";
}
Window wmWindow = *(Window*)(data);
XFree(data);
status = XGetWindowProperty(
display,
wmWindow,
wmCheckAtom,
0,
1,
False,
XA_WINDOW,
&actualType,
&actualFormat,
&itemCount,
&bytesAfter,
&data
);
if (status != Success || !data) {
return "Unknown (failed to get supporting window)";
}
wmWindow = *(reinterpret_cast<Window*>(data));
XFree(data);
Atom wmNameAtom = XInternAtom(display, "_NET_WM_NAME", True);
if (wmNameAtom == None) {
return "Unknown (no _NET_WM_NAME)";
}
status = XGetWindowProperty(
display,
wmWindow,
wmNameAtom,
0,
(~0L),
False,
AnyPropertyType,
&actualType,
&actualFormat,
&itemCount,
&bytesAfter,
&data
);
if (status != Success || !data) {
return "Unknown (failed to get _NET_WM_NAME)";
}
std::string wmName(reinterpret_cast<char*>(data));
XFree(data);
return wmName;
}
if (xdgSessionType == "tty")
return "TTY";
return "Unknown";
}
#endif #endif