mirror of
https://github.com/fairyglade/ly
synced 2024-11-16 00:12:58 +00:00
Try a more simple way to do it
This commit is contained in:
parent
3dd1a63a4c
commit
1c3608948d
18
src/inputs.c
18
src/inputs.c
@ -7,7 +7,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <ctype.h>
|
||||
|
||||
void handle_desktop(void* input_struct, struct tb_event* event)
|
||||
{
|
||||
@ -77,7 +76,6 @@ void handle_text(void* input_struct, struct tb_event* event)
|
||||
void input_desktop(struct desktop* target)
|
||||
{
|
||||
target->list = NULL;
|
||||
target->list_simple = NULL;
|
||||
target->cmd = NULL;
|
||||
target->display_server = NULL;
|
||||
target->cur = 0;
|
||||
@ -178,7 +176,6 @@ void input_desktop_add(
|
||||
{
|
||||
++(target->len);
|
||||
target->list = realloc(target->list, target->len * (sizeof (char*)));
|
||||
target->list_simple = realloc(target->list_simple, target->len * (sizeof (char*)));
|
||||
target->cmd = realloc(target->cmd, target->len * (sizeof (char*)));
|
||||
target->display_server = realloc(
|
||||
target->display_server,
|
||||
@ -193,22 +190,7 @@ void input_desktop_add(
|
||||
return;
|
||||
}
|
||||
|
||||
int name_len = strlen(name);
|
||||
|
||||
target->list[target->cur] = name;
|
||||
|
||||
char* name_simple = *name;
|
||||
if (strstr(name_simple, " ") != NULL)
|
||||
{
|
||||
name_simple = strtok(name_simple, " ");
|
||||
}
|
||||
|
||||
for (int i = 0; i < name_len; i++)
|
||||
{
|
||||
name_simple[i] = tolower(name_simple[i]);
|
||||
}
|
||||
|
||||
target->list_simple[target->cur] = name_simple;
|
||||
target->cmd[target->cur] = cmd;
|
||||
target->display_server[target->cur] = display_server;
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ struct text
|
||||
struct desktop
|
||||
{
|
||||
char** list;
|
||||
char** list_simple;
|
||||
char** cmd;
|
||||
enum display_server* display_server;
|
||||
|
||||
|
@ -265,14 +265,14 @@ void env_xdg_session(const enum display_server display_server)
|
||||
}
|
||||
}
|
||||
|
||||
void env_xdg(const char* tty_id, const char* desktop_name)
|
||||
void env_xdg(const char* tty_id)
|
||||
{
|
||||
char user[15];
|
||||
snprintf(user, 15, "/run/user/%d", getuid());
|
||||
setenv("XDG_RUNTIME_DIR", user, 0);
|
||||
setenv("XDG_SESSION_CLASS", "user", 0);
|
||||
setenv("XDG_SESSION_ID", "1", 0);
|
||||
setenv("XDG_SESSION_DESKTOP", desktop_name, 0);
|
||||
setenv("XDG_SESSION_DESKTOP", getenv("XDG_CURRENT_DESKTOP"), 0);
|
||||
setenv("XDG_SEAT", "seat0", 0);
|
||||
setenv("XDG_VTNR", tty_id, 0);
|
||||
}
|
||||
@ -609,7 +609,7 @@ void auth(
|
||||
}
|
||||
|
||||
// add xdg variables
|
||||
env_xdg(tty_id, desktop->list[desktop->cur]);
|
||||
env_xdg(tty_id);
|
||||
|
||||
// execute
|
||||
int ok = chdir(pwd->pw_dir);
|
||||
|
Loading…
Reference in New Issue
Block a user