Skip to content

Commit c7609a9

Browse files
committed
Added getBackend for backend (like: wayland)
1 parent fd5da22 commit c7609a9

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# [0.2.10]
1+
# [0.2.11]
22

33
### What's Changed?
4-
- getGTK and getQT added (taking informations from environment variables)
5-
- Some code optimizations and syntax optimizations.
4+
- Added getBackend for (wayland) or (x11) or (what if) (taking information from XDG_BACKEND env var.)
5+

src/ffetch.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ pub fn get_desktop_env() -> String {
131131
.unwrap_or_else(|_| "Unknown".to_string())
132132
}
133133

134+
pub fn get_compositor() -> String {
135+
env::var("XDG_BACKEND").unwrap_or_else(|_| "Unknown Backend".to_string())
136+
}
137+
134138
pub fn get_cpu_arch() -> String {
135139
let get_cpu_arch_command = Command::new("uname")
136140
.arg("-m")

src/main.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,10 @@ lazy_static! {
5656
static ref OSNAME: String = ffetch::get_os_name();
5757
static ref DESKTOP: String = ffetch::get_desktop_env();
5858
static ref LOCALE: String = ffetch::get_locale();
59+
static ref BACKEND: String = ffetch::get_compositor();
5960
static ref ARCH: String = ffetch::get_cpu_arch();
6061
static ref PLATFORM: String = ffetch::get_platform();
61-
static ref UPTIME: String = ffetch::get_uptime();
62+
static ref UPTIME: String = ffetch::get_uptime();
6263
static ref SHELL: String = ffetch::get_shell();
6364
static ref PACKAGES: String = ffetch::get_packages();
6465
static ref GPU: String = ffetch::get_gpu();
@@ -126,7 +127,7 @@ fn comp_with_mon_argument(input: &str) -> usize {
126127
}
127128

128129
fn find_token(string: &str, findstr: &str) -> bool {
129-
let tokens : Vec<&str> = string.split(" ").collect();
130+
let tokens: Vec<&str> = string.split(" ").collect();
130131
for item in &tokens {
131132
if item == &findstr {
132133
return true;
@@ -154,6 +155,7 @@ fn replace_syntax(conf: &str) -> String {
154155
.replace("getOsName", &OSNAME)
155156
.replace("getDesktop", &DESKTOP)
156157
.replace("getArch", &ARCH)
158+
.replace("getBackend", &BACKEND)
157159
.replace("getPlatform", &PLATFORM)
158160
.replace("getUptime", &UPTIME)
159161
.replace("getPackages", &PACKAGES)
@@ -285,6 +287,8 @@ fn lex_config(input: &str) -> String {
285287
result
286288
}
287289

290+
// fn colorize_ascii(ascii: String) {}
291+
288292
fn write_fetch(ascii: Vec<String>, ascii_color: String) -> String {
289293
let max_width = ascii.iter().map(|line| line.len()).max().unwrap_or(0);
290294
let mut ascii_index = 0;

0 commit comments

Comments
 (0)