diff options
author | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:18 +0200 |
---|---|---|
committer | Daniel Lange <DLange@git.local> | 2016-04-11 13:00:18 +0200 |
commit | 031c3bb95f3d0a74d985286068baa6dd4d29d83f (patch) | |
tree | f8258f898976e17dfbc9df30ca357be6cb3605a5 /Settings.c | |
parent | bb3dd9e92f5a33ba5dd1192edc1671192e63cc8e (diff) | |
download | debian_htop-031c3bb95f3d0a74d985286068baa6dd4d29d83f.tar.gz debian_htop-031c3bb95f3d0a74d985286068baa6dd4d29d83f.tar.bz2 debian_htop-031c3bb95f3d0a74d985286068baa6dd4d29d83f.zip |
Imported Upstream version 0.5.3upstream/0.5.3
Diffstat (limited to 'Settings.c')
-rw-r--r-- | Settings.c | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -26,13 +26,20 @@ Settings* Settings_new(ProcessList* pl, Header* header) { Settings* this = malloc(sizeof(Settings)); this->pl = pl; this->header = header; - // TODO: how to get SYSCONFDIR correctly through Autoconf? - // char* systemSettings = String_cat(SYSCONFDIR, "/htoprc"); - // Settings_read(this, systemSettings); - char* home = getenv("HOME"); + char* home; + home = getenv("HOME_ETC"); + if (!home) home = getenv("HOME"); this->userSettings = String_cat(home, "/.htoprc"); - Settings_read(this, this->userSettings); - // free(systemSettings); + bool ok = Settings_read(this, this->userSettings); + if (!ok) { + // TODO: how to get SYSCONFDIR correctly through Autoconf? + char* systemSettings = String_cat(SYSCONFDIR, "/htoprc"); + ok = Settings_read(this, systemSettings); + free(systemSettings); + if (!ok) { + Header_defaultMeters(this->header); + } + } return this; } @@ -72,7 +79,6 @@ bool Settings_read(Settings* this, char* fileName) { FILE* fd; fd = fopen(fileName, "r"); if (fd == NULL) { - Header_defaultMeters(this->header); return false; } const int maxLine = 512; @@ -176,8 +182,10 @@ bool Settings_write(Settings* this) { fprintf(fd, "tree_view=%d\n", (int) this->pl->treeView); fprintf(fd, "header_margin=%d\n", (int) this->header->margin); fprintf(fd, "left_meters="); - for (int i = 0; i < Header_size(this->header, LEFT_HEADER); i++) + for (int i = 0; i < Header_size(this->header, LEFT_HEADER); i++) { +fprintf(stderr, "Field #%d\n", i); fprintf(fd, "%s ", Header_readMeterName(this->header, i, LEFT_HEADER)); + } fprintf(fd, "\n"); fprintf(fd, "left_meter_modes="); for (int i = 0; i < Header_size(this->header, LEFT_HEADER); i++) |