mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-26 07:57:59 -04:00
conf: get user's shell
This commit is contained in:
parent
6bce2bed00
commit
19aaa7b774
2 changed files with 18 additions and 0 deletions
17
config.c
17
config.c
|
|
@ -15,6 +15,21 @@
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "log.h"
|
#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 *
|
static char *
|
||||||
get_config_path_user_config(void)
|
get_config_path_user_config(void)
|
||||||
{
|
{
|
||||||
|
|
@ -145,6 +160,7 @@ struct config
|
||||||
config_load(void)
|
config_load(void)
|
||||||
{
|
{
|
||||||
struct config conf = {
|
struct config conf = {
|
||||||
|
.shell = get_shell(),
|
||||||
.font = strdup("monospace"),
|
.font = strdup("monospace"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -174,5 +190,6 @@ out:
|
||||||
void
|
void
|
||||||
config_free(struct config conf)
|
config_free(struct config conf)
|
||||||
{
|
{
|
||||||
|
free(conf.shell);
|
||||||
free(conf.font);
|
free(conf.font);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
config.h
1
config.h
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
struct config {
|
struct config {
|
||||||
|
char *shell;
|
||||||
char *font;
|
char *font;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue