diff --git a/README b/README index 1d5badc..9e402f1 100644 --- a/README +++ b/README @@ -25,6 +25,6 @@ $ ninja -C build install NOTES -You can press 'k', 'm', 'g' to display results in KB, MB of GB -respectively. +You can press Ctrl plus 'k', 'm', 'g' to display results in KB, MB +of GB respectively. diff --git a/src/bin/process.c b/src/bin/process.c index 6f8cfe6..dade9a5 100644 --- a/src/bin/process.c +++ b/src/bin/process.c @@ -138,15 +138,15 @@ _parse_line(const char *line) static Eina_List * _process_list_linux_get(void) { - char *name; - Eina_List *files, *list = NULL; + Eina_List *files, *list; FILE *f; - char path[PATH_MAX], line[4096], program_name[1024], state; + char *name, *link, state, line[4096], program_name[1024]; int pid, res, utime, stime, cutime, cstime, uid, psr, pri, nice, numthreads; unsigned int mem_size, mem_rss; - int pagesize = getpagesize(); + list = NULL; + files = ecore_file_ls("/proc"); EINA_LIST_FREE(files, name) { @@ -155,9 +155,7 @@ _process_list_linux_get(void) if (!pid) continue; - snprintf(path, sizeof(path), "/proc/%d/stat", pid); - - f = fopen(path, "r"); + f = fopen(eina_slstr_printf("/proc/%d/stat", pid), "r"); if (!f) continue; if (fgets(line, sizeof(line), f)) @@ -178,9 +176,7 @@ _process_list_linux_get(void) if (res != 42) continue; - snprintf(path, sizeof(path), "/proc/%d/status", pid); - - f = fopen(path, "r"); + f = fopen(eina_slstr_printf("/proc/%d/status", pid), "r"); if (!f) continue; while ((fgets(line, sizeof(line), f)) != NULL) @@ -194,6 +190,26 @@ _process_list_linux_get(void) fclose(f); + link = ecore_file_readlink(eina_slstr_printf("/proc/%d/exe", pid)); + if (link) + { + snprintf(program_name, sizeof(program_name), "%s", ecore_file_file_get(link)); + free(link); + } + else + { + f = fopen(eina_slstr_printf("/proc/%d/cmdline", pid), "r"); + if (f) + { + if (fgets(line, sizeof(line), f)) + { + if (ecore_file_exists(line)) + snprintf(program_name, sizeof(program_name), "%s", ecore_file_file_get(line)); + } + fclose(f); + } + } + Proc_Stats *p = calloc(1, sizeof(Proc_Stats)); if (!p) return NULL; @@ -222,17 +238,11 @@ Proc_Stats * proc_info_by_pid(int pid) { FILE *f; - char path[PATH_MAX]; - char line[4096]; - char state, program_name[1024]; + char *link, state, line[4096], program_name[1024]; int res, dummy, utime, stime, cutime, cstime, uid, psr; unsigned int mem_size, mem_rss, pri, nice, numthreads; - snprintf(path, sizeof(path), "/proc/%d/stat", pid); - if (!ecore_file_exists(path)) - return NULL; - - f = fopen(path, "r"); + f = fopen(eina_slstr_printf("/proc/%d/stat", pid), "r"); if (!f) return NULL; if (fgets(line, sizeof(line), f)) @@ -251,9 +261,7 @@ proc_info_by_pid(int pid) if (res != 42) return NULL; - snprintf(path, sizeof(path), "/proc/%d/status", pid); - - f = fopen(path, "r"); + f = fopen(eina_slstr_printf("/proc/%d/status", pid), "r"); if (!f) return NULL; while ((fgets(line, sizeof(line), f)) != NULL) @@ -266,6 +274,26 @@ proc_info_by_pid(int pid) } fclose(f); + link = ecore_file_readlink(eina_slstr_printf("/proc/%d/exe", pid)); + if (link) + { + snprintf(program_name, sizeof(program_name), "%s", ecore_file_file_get(link)); + free(link); + } + else + { + f = fopen(eina_slstr_printf("/proc/%d/cmdline", pid), "r"); + if (f) + { + if (fgets(line, sizeof(line), f)) + { + if (ecore_file_exists(line)) + snprintf(program_name, sizeof(program_name), "%s", ecore_file_file_get(line)); + } + fclose(f); + } + } + Proc_Stats *p = calloc(1, sizeof(Proc_Stats)); if (!p) return NULL; diff --git a/src/bin/ui.c b/src/bin/ui.c index 3951107..43fb3b4 100644 --- a/src/bin/ui.c +++ b/src/bin/ui.c @@ -637,10 +637,13 @@ _text_fields_append(Ui *ui, Proc_Stats *proc) if (ui->search_text && ui->search_text[0]) { + ui->searching = EINA_TRUE; if (strncasecmp(proc->command, ui->search_text, strlen(ui->search_text))) return; } + ui->searching = EINA_FALSE; + mem_size = proc->mem_size; mem_rss = proc->mem_rss; @@ -1324,6 +1327,7 @@ _ui_tab_system_add(Ui *ui) evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_ON); + elm_scroller_content_min_limit(scroller, EINA_TRUE, EINA_FALSE); elm_scroller_wheel_disabled_set(scroller, EINA_FALSE); evas_object_show(scroller); elm_object_content_set(scroller, table); @@ -2324,6 +2328,7 @@ _evisum_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) { Evas_Event_Key_Down *ev; Ui *ui; + Eina_Bool control; ev = event_info; ui = data; @@ -2331,16 +2336,25 @@ _evisum_key_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) if (!ev || !ev->keyname) return; + control = evas_key_modifier_is_set(ev->modifiers, "Control"); + ui->skip_wait = EINA_TRUE; + if (!strcmp(ev->keyname, "Escape")) + { + ui_shutdown(ui); + return; + } + + if (!control) return; + + /* Set data unit by CTRL + ... */ if ((ev->keyname[0] == 'K' || ev->keyname[0] == 'k') && !ev->keyname[1]) ui->data_unit = DATA_UNIT_KB; else if ((ev->keyname[0] == 'M' || ev->keyname[0] == 'm') && !ev->keyname[1]) ui->data_unit = DATA_UNIT_MB; else if ((ev->keyname[0] == 'G' || ev->keyname[0] == 'g') && !ev->keyname[1]) ui->data_unit = DATA_UNIT_GB; - else if (!strcmp(ev->keyname, "Escape")) - ui_shutdown(ui); } static Ui * diff --git a/src/bin/ui.h b/src/bin/ui.h index cf14e0a..a0fc20e 100644 --- a/src/bin/ui.h +++ b/src/bin/ui.h @@ -146,6 +146,7 @@ typedef struct Ui Eina_Bool sort_reverse; Eina_Bool panel_visible; Eina_Bool shutting_down; + Eina_Bool searching; uint64_t incoming_max; uint64_t outgoing_max;