Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit 1fd60e2

Browse files
🐛 Fix no res file in VMs (#123)
* 🐛 Fix no res file in VMs * 🐛 Remove extra / * Done
1 parent 0efb98e commit 1fd60e2

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/Makefile
22
src/config.h
33
src/procfetch
4+
ascii/Makefile
45
*.o
56
dist/
67
docs/

src/fetch.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,14 @@ string getDE()
238238
return getenv("XDG_CURRENT_DESKTOP");
239239
}
240240

241+
/**
242+
* @returns checks for Resolution file
243+
*/
244+
bool resCheck()
245+
{
246+
return Path::of("/sys/class/graphics/fb0/modes"s).isRegularFile();
247+
}
248+
241249
/**
242250
* @returns gets current Screen Resolution
243251
* @param path
@@ -298,6 +306,14 @@ string getCPU(string path)
298306
return cpu;
299307
}
300308

309+
/**
310+
* @returns checks for CPUtemp file
311+
*/
312+
bool CpuTempCheck()
313+
{
314+
return Path::of("/sys/class/thermal/thermal_zone1"s).isDirectory();
315+
}
316+
301317
/**
302318
* @returns gets CPU temp
303319
* @param path
@@ -311,18 +327,6 @@ int getCPUtemp(string path)
311327
return stoi(temp);
312328
}
313329

314-
/**
315-
* @returns checks for CPUtemp file
316-
*/
317-
bool CpuTempCheck()
318-
{
319-
if (Path::of("/sys/class/thermal/thermal_zone1"s).isDirectory())
320-
{
321-
return true;
322-
}
323-
return false;
324-
}
325-
326330
/**
327331
* @returns gets vendor of Internal and External GPU
328332
*/

src/fetch.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ string getSHELL(string path);
4141

4242
string getDE();
4343

44+
bool resCheck();
45+
4446
string getRES(string path);
4547

4648
string getTheme();
@@ -49,10 +51,10 @@ string getIcons();
4951

5052
string getCPU(string path);
5153

52-
int getCPUtemp(string path);
53-
5454
bool CpuTempCheck();
5555

56+
int getCPUtemp(string path);
57+
5658
vector<string> getGPU();
5759

5860
string getPackages();

src/main.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,13 @@ void DisplayInfo(bool show_battery)
9696
cout << title.text("RAM : ") << getRAM("/proc/meminfo") << endl;
9797
cout << title.text("shell : ") << getSHELL("/etc/passwd") << endl;
9898
cout << title.text("DE : ") << getDE() << endl;
99-
cout << title.text("Resolution : ")
100-
<< getRES("/sys/class/graphics/fb0/modes") << endl;
99+
100+
if (resCheck())
101+
{
102+
cout << title.text("Resolution : ")
103+
<< getRES("/sys/class/graphics/fb0/modes") << endl;
104+
}
105+
101106
cout << title.text("Theme : ") << getTheme() << endl;
102107
cout << title.text("Icons : ") << getIcons() << endl;
103108
cout << title.text("CPU : ") << getCPU("/proc/cpuinfo") << endl;

0 commit comments

Comments
 (0)