Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: adding working directory to detailed process view #880

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/btop_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,7 @@ namespace Proc {
if (item_fit >= 6) out += cjust("User:", item_width);
if (item_fit >= 7) out += cjust("Threads:", item_width);
if (item_fit >= 8) out += cjust("Nice:", item_width);
if (item_fit >= 9) out += cjust("Working Directory:", item_width);


//? Command line
Expand Down Expand Up @@ -1738,7 +1739,7 @@ namespace Proc {
//? Draw details box if shown
if (show_detailed) {
bool alive = detailed.status != "Dead";
const int item_fit = floor((double)(d_width - 2) / 10);
const int item_fit = floor((double)(d_width - 2) / 11);
const int item_width = floor((double)(d_width - 2) / min(item_fit, 8));

//? Graph part of box
Expand All @@ -1763,6 +1764,7 @@ namespace Proc {
if (item_fit >= 6) out += cjust(detailed.entry.user, item_width, true);
if (item_fit >= 7) out += cjust(to_string(detailed.entry.threads), item_width);
if (item_fit >= 8) out += cjust(to_string(detailed.entry.p_nice), item_width);
if (item_fit >= 9) out += cjust(detailed.entry.working_dir, item_width);


const double mem_p = (double)detailed.mem_bytes.back() * 100 / totalMem;
Expand Down
1 change: 1 addition & 0 deletions src/btop_shared.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ namespace Proc {
string name{}; // defaults to ""
string cmd{}; // defaults to ""
string short_cmd{}; // defaults to ""
string working_dir{}; // defaults to ""
size_t threads{};
int name_offset{};
string user{}; // defaults to ""
Expand Down
6 changes: 6 additions & 0 deletions src/linux/btop_collect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2481,6 +2481,12 @@ namespace Proc {
catch (const std::out_of_range&) {}
d_read.close();
}

// Get working directory of process
ifstream working_dir(pid_path/"cwd");
if(working_dir.good())
detailed.entry.working_dir = fs::read_symlink(pid_path/"cwd");

if (detailed.memory.empty()) {
detailed.mem_bytes.push_back(detailed.entry.mem);
detailed.memory = floating_humanizer(detailed.entry.mem);
Expand Down
Loading