Skip to content

Commit 82f2979

Browse files
committed
Add: added getTerm component.
1 parent 91b4e0e commit 82f2979

576 files changed

Lines changed: 43819 additions & 5 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 2 additions & 2 deletions

README.md

Lines changed: 6 additions & 0 deletions

ffetch

-2.15 MB
Binary file not shown.

ffetch-advanced.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# advanced config
1+
# 🌟 Advanced config
22
echo "╭───────────── " t.underline t.bold fg.yellow getUsername
33
echo "│ " t.underline " System Information :"
44
echo "│ " fg.blue " OS: " fg.cyan getOsName " " t.italic fg.yellow t.bold getArch
@@ -20,6 +20,7 @@ echo "│ " fg.magenta "󰪫 DE/WM: " fg.white t.bold getDesktop
2020
echo "│ " fg.magenta " Uptime: " fg.white t.bold getUptime
2121
echo "│ " fg.magenta "󰧨 Primary: " fg.white t.bold getMonitor(0)
2222
echo "│ " fg.magenta " Shell: " fg.white t.bold getShell
23+
echo "│ " fg.magenta " Terminal: " fg.white t.bold getTerm
2324
echo "╰───────────────────────────────╯"
2425

2526
ascii = "/home/getUsername/.config/ffetch/ascii.txt"

ffetch-middle.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# middle config
1+
# ⚡ Middle config
22
echo t.bold fg.yellow getUsername fg.black "@" fg.yellow getHostname
33
echo fg.blue "Distro: " fg.yellow t.bold getOsName
44
echo fg.blue "Platform: " fg.yellow t.bold getPlatform
@@ -11,6 +11,7 @@ echo fg.blue "Disk: " fg.yellow t.bold getDisk(/)
1111
echo fg.blue "Desktop: " fg.yellow t.bold getDesktop
1212
echo fg.blue "Primary: " fg.yellow t.bold getMonitor(0)
1313
echo fg.blue "Uptime: " fg.yellow t.bold getUptime
14+
echo fg.blue "Terminal: " fg.yellow t.bold getTerm
1415
echo fg.blue "Shell: " fg.yellow t.bold getShell
1516

1617
ascii = "/home/getUsername/.config/ffetch/ascii.txt"

ffetch-minimal.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# minimal config
1+
# 🔥 Minimal config
22
echo getUsername "@" getHostname
33
echo "Distro: " getOsName
44
echo "Platform: " getPlatform
@@ -10,6 +10,7 @@ echo "Packages: " getPackages
1010
echo "Disk: " getDisk(/)
1111
echo "Desktop: " getDesktop
1212
echo "Primary: " getMonitor(0)
13+
echo "Terminal: " getTerm
1314
echo "Uptime: " getUptime
1415
echo "Shell: " getShell
1516

src/ffetch.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
pub mod ffetch {
22
use display_info::DisplayInfo;
33
use lazy_static::lazy_static;
4+
use regex::Regex;
45
use rsbash::rash;
56
use std::env;
67
use std::{fs::read_to_string, process::Command};
@@ -10,6 +11,8 @@ pub mod ffetch {
1011

1112
lazy_static! {
1213
static ref DISPLAY_INFORMATION: Vec<DisplayInfo> = DisplayInfo::all().unwrap();
14+
static ref REGEX: Regex = Regex::new(r"window id # (0x[0-9a-f]+)").unwrap();
15+
static ref NAME_REGEX: Regex = Regex::new(r#""([^"]+)""#).unwrap();
1316
}
1417

1518
pub fn get_kernel_version() -> String {
@@ -292,6 +295,41 @@ pub mod ffetch {
292295
all_of_things
293296
}
294297

298+
pub fn get_terminal() -> String {
299+
let output = Command::new("xprop")
300+
.args(["-root", "_NET_ACTIVE_WINDOW"])
301+
.output()
302+
.expect("xprop run error.");
303+
304+
let stdout = String::from_utf8_lossy(&output.stdout);
305+
306+
let window_id = match REGEX.captures(&stdout) {
307+
Some(cap) => cap[1].to_string(),
308+
None => {
309+
eprintln!("⚠️ Window not found.");
310+
return "".to_string();
311+
}
312+
};
313+
314+
let output = Command::new("xprop")
315+
.args(["-id", &window_id])
316+
.output()
317+
.expect("xprop id run error.");
318+
319+
let info = String::from_utf8_lossy(&output.stdout);
320+
for line in info.lines() {
321+
if line.starts_with("WM_CLASS") {
322+
let mut matches = NAME_REGEX.captures_iter(line);
323+
324+
if let Some(app_class) = matches.next() {
325+
let terminal = app_class[1].to_string();
326+
return terminal;
327+
}
328+
}
329+
}
330+
return "".to_string();
331+
}
332+
295333
pub fn get_disks(disk_point: &str) -> String {
296334
let disks = Disks::new_with_refreshed_list();
297335
for disk in disks.list() {

src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ lazy_static! {
4848
static ref MON_REGEX: Regex = Regex::new(r"getMonitor\((.*?)\)").expect("Regex error:");
4949
static ref PKG_REGEX: Regex = Regex::new(r"getPackages\((.*?)\)").expect("Regex error:");
5050
static ref USERNAME: String = ffetch::ffetch::get_username();
51+
static ref TERMINAL: String = ffetch::ffetch::get_terminal();
5152
static ref KERNEL: String = ffetch::ffetch::get_kernel_version();
5253
static ref CPU: String = ffetch::ffetch::get_cpu_name();
5354
static ref MEMORY: String = ffetch::ffetch::get_memory();
@@ -158,6 +159,7 @@ fn replace_syntax(conf: &str) -> String {
158159
.replace("getMGpu", &mGPU)
159160
.replace("getShell", &SHELL)
160161
.replace("getLocale", &LOCALE)
162+
.replace("getTerm", &TERMINAL)
161163
.replace(&diskf, &ffetch::ffetch::get_disks(&disk))
162164
.replace(&monitorf, &ffetch::ffetch::get_monitor(index))
163165
// Fg Colors

target/.rustc_info.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"rustc_fingerprint":14480397058847111223,"outputs":{"13331785392996375709":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/opt/rust-bin-1.85.1\noff\npacked\nunpacked\n___\ndebug_assertions\nfmt_debug=\"full\"\noverflow_checks\npanic=\"unwind\"\nproc_macro\nrelocation_model=\"pic\"\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_feature=\"x87\"\ntarget_has_atomic\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_thread_local\ntarget_vendor=\"unknown\"\nub_checks\nunix\n","stderr":""},"17747080675513052775":{"success":true,"status":"","code":0,"stdout":"rustc 1.85.1 (4eb161250 2025-03-15)\nbinary: rustc\ncommit-hash: 4eb161250e340c8f48f66e2b929ef4a5bed7c181\ncommit-date: 2025-03-15\nhost: x86_64-unknown-linux-gnu\nrelease: 1.85.1\nLLVM version: 19.1.7\n","stderr":""},"2063776225603076451":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/opt/rust-bin-1.85.1\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""}},"successes":{}}

target/CACHEDIR.TAG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Signature: 8a477f597d28d172789f06886806bc55
2+
# This file is a cache directory tag created by cargo.
3+
# For information about cache directory tags see https://bford.info/cachedir/

0 commit comments

Comments
 (0)