Skip to content

Commit 630f784

Browse files
committed
bug fix
1 parent 107abc1 commit 630f784

6 files changed

Lines changed: 105 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [0.2.18]
1+
# [0.2.19]
22

33
### What's Changed?
44

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ffetch"
3-
version = "0.5.6"
3+
version = "0.5.7"
44
authors = ["0l3d <0l3dgit@gmail.com>"]
55
edition = "2021"
66
description = "Fast, minimal & Rust-powered system fetcher"

PKGBUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Maintainer: 0l3d
22

33
pkgname=ffetch-bin
4-
pkgver=0.2.18
4+
pkgver=0.2.19
55
pkgrel=1
66
pkgdesc='CLI tool to fetch system info.'
77
url='https://github.com/0l3d/ffetch'

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# 🚀 **F-Fetch:** _Fast, Minimal & Rust-Powered System Fetcher_
1+
# 🚀 **F-Fetch:** _Fast, Minimal & Rust-Powered System Fetcher_
22

33
F-Fetch is a **very fast**, **minimal** terminal system fetcher written **100% in Rust**.
44
It is **highly customizable** - allowing you to add your own syntax and integrate your own features.
5-
At its core, it works simply and the codebase is easy to understand.
5+
At its core, it works simply and the codebase is easy to understand.
66

77
---
88

@@ -40,7 +40,9 @@ bash <(curl -s https://raw.githubusercontent.com/0l3d/ffetch/master/install.sh)
4040
```bash
4141
ffetch
4242
```
43+
4344
---
45+
4446
# 📚 **Use as Library**
4547

4648
You can also use F-Fetch as a library in your Rust projects:
@@ -82,12 +84,13 @@ fn main() {
8284
## Dependencies
8385

8486
If u're using `getTerm`, u need to make sure xprop is installed.
87+
If `getMonitor` fails, it uses `xrandr`.
8588

8689
For GPU and disk information, I use standard Linux tools like lspci (from pciutils) and df (from coreutils).
8790

8891
# F-Fetch Configuration & Examples
8992

90-
## F-Fetch Components List
93+
## F-Fetch Components List
9194

9295
- `getUsername`
9396
Returns the current **Username**.
@@ -250,7 +253,7 @@ echo "│ " fg.white t.bold " Hostname: " all.reset fg.green getHostname
250253
echo "" fg.white t.bold " Packages: " all.reset fg.green getPackages
251254
echo "" fg.white t.bold " Locale: " all.reset fg.green getLocale
252255
echo "" fg.white t.bold " Init: " all.reset fg.green getInit
253-
echo ""
256+
echo ""
254257
echo "" t.underline fg.bright_green "󰋊 Hardware Information :"
255258
echo ""
256259
echo "" fg.yellow t.bold " CPU: " all.reset fg.white getCpu

src/ffetch.rs

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,99 @@ pub fn get_monitor(monitor_index: usize) -> String {
11601160
))
11611161
}
11621162

1163+
fn parse_xrandr_monitors() -> Vec<String> {
1164+
let output = Command::new("xrandr")
1165+
.arg("--query")
1166+
.output()
1167+
.expect("Failed to execute xrandr");
1168+
1169+
if !output.status.success() {
1170+
return vec!["Failed to run xrandr".to_string()];
1171+
}
1172+
1173+
let stdout = String::from_utf8_lossy(&output.stdout);
1174+
let mut lines = stdout.lines();
1175+
1176+
let mut results = Vec::new();
1177+
1178+
while let Some(line) = lines.next() {
1179+
if line.contains(" connected") {
1180+
let parts: Vec<&str> = line.split_whitespace().collect();
1181+
let connector_full = parts[0];
1182+
let resolution_part = parts
1183+
.iter()
1184+
.find(|s| s.contains('+') && s.contains('x'))
1185+
.unwrap_or(&"Unknown");
1186+
let connector_short = connector_full.split('-').next().unwrap_or("Unknown");
1187+
let location = if connector_full.starts_with("eDP") {
1188+
"Internal"
1189+
} else {
1190+
"External"
1191+
};
1192+
1193+
let resolution = resolution_part.split('+').next().unwrap_or("Unknown");
1194+
1195+
let mut width_mm = 0.0;
1196+
let mut height_mm = 0.0;
1197+
1198+
for i in 0..parts.len() {
1199+
if parts[i].ends_with("mm") {
1200+
if width_mm == 0.0 {
1201+
width_mm = parts[i]
1202+
.trim_end_matches("mm")
1203+
.parse::<f32>()
1204+
.unwrap_or(0.0);
1205+
} else if height_mm == 0.0 {
1206+
height_mm = parts[i]
1207+
.trim_end_matches("mm")
1208+
.parse::<f32>()
1209+
.unwrap_or(0.0);
1210+
break;
1211+
}
1212+
}
1213+
}
1214+
1215+
let mut refresh_hz = "??".to_string();
1216+
1217+
while let Some(mode_line) = lines.next() {
1218+
if mode_line.trim().is_empty() || mode_line.contains("connected") {
1219+
break;
1220+
}
1221+
1222+
let mode_parts: Vec<&str> = mode_line.trim().split_whitespace().collect();
1223+
if mode_parts.len() >= 2 && mode_parts[0] == resolution {
1224+
refresh_hz = mode_parts[1]
1225+
.trim_end_matches(|c: char| c == '*' || c == '+')
1226+
.to_string();
1227+
break;
1228+
}
1229+
}
1230+
1231+
let width_in = width_mm / 25.4;
1232+
let height_in = height_mm / 25.4;
1233+
let diagonal_in = if width_in > 0.0 && height_in > 0.0 {
1234+
((width_in.powi(2) + height_in.powi(2)).sqrt() * 10.0).round() / 10.0
1235+
} else {
1236+
0.0
1237+
};
1238+
1239+
let line = if diagonal_in > 0.0 {
1240+
format!(
1241+
"({connector_short}): {resolution} @ {refresh_hz} Hz in {diagonal_in:.1}\" [{location}]"
1242+
)
1243+
} else {
1244+
format!(
1245+
"({connector_short}): {resolution} @ {refresh_hz} Hz [No size] [{location}]"
1246+
)
1247+
};
1248+
1249+
results.push(line);
1250+
}
1251+
}
1252+
1253+
results
1254+
}
1255+
11631256
let drm_dir = Path::new("/sys/class/drm");
11641257
let mut all_of_things = Vec::new();
11651258

@@ -1236,7 +1329,7 @@ pub fn get_monitor(monitor_index: usize) -> String {
12361329

12371330
all_of_things.push(line);
12381331
} else {
1239-
all_of_things.push(format!("({connector}): Failed to parse EDID"));
1332+
all_of_things.push(parse_xrandr_monitors()[monitor_index].to_string());
12401333
}
12411334
}
12421335

0 commit comments

Comments
 (0)