aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-07-17 07:29:56 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-07-17 07:29:56 +0000
commit19aaa7b7743ab0d3be3063579a53a6f92b83ec31 (patch)
tree5973bdf3f01ef309a06308d55f4948584b029b14
parentrender: use cairo_rel_line_to() (diff)
conf: get user's shell
-rw-r--r--config.c17
-rw-r--r--config.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/config.c b/config.c
index 1bc5de59..a4520ea0 100644
--- a/config.c
+++ b/config.c
@@ -16,6 +16,21 @@
#include "log.h"
static char *
+get_shell(void)
+{
+ struct passwd *passwd = getpwuid(getuid());
+ if (passwd == NULL) {
+ LOG_ERRNO("failed to lookup user");
+ return NULL;
+ }
+
+ const char *shell = passwd->pw_shell;
+ LOG_DBG("user's shell: %s", shell);
+
+ return strdup(shell);
+}
+
+static char *
get_config_path_user_config(void)
{
struct passwd *passwd = getpwuid(getuid());
@@ -145,6 +160,7 @@ struct config
config_load(void)
{
struct config conf = {
+ .shell = get_shell(),
.font = strdup("monospace"),
};
@@ -174,5 +190,6 @@ out:
void
config_free(struct config conf)
{
+ free(conf.shell);
free(conf.font);
}
diff --git a/config.h b/config.h
index 4215a80a..dffa2998 100644
--- a/config.h
+++ b/config.h
@@ -1,6 +1,7 @@
#pragma once
struct config {
+ char *shell;
char *font;
};