TanmayPatil105 / procfetch

🎨 Yet another command-line system information utility written in C++
https://tanmaypatil105.github.io/procfetch/
GNU General Public License v3.0
23 stars 11 forks source link

Handle failures and exceptions #148

Open TanmayPatil105 opened 6 months ago

TanmayPatil105 commented 6 months ago

Currently, the program doesn't handle exceptions and it halts. I'm listing some failures here that I have experienced.

1. Username

string getuser()
{   
    return getenv("USER");
}

See discussion on https://github.com/TanmayPatil105/procfetch/pull/145!

2. Theme

string getTheme()
{   
    auto args = "gsettings get org.gnome.desktop.interface gtk-theme"s;
    auto s = Command::exec(args)->getOutput();
    return s.substr(1, s.find("\'", 1) - 1);
}   

Some machines don't have it installed. For example, Docker containers.

3. Icons

string getIcons()
{
    auto args = "gsettings get org.gnome.desktop.interface icon-theme"s;
    auto s = Command::exec(args)->getOutput();
    return s.substr(1, s.find("\'", 1) - 1);
}

Same as above