mirror of
https://github.com/javalsai/lidm.git
synced 2025-07-04 23:08:42 +02:00
Merge branch 'javalsai:master' into master
This commit is contained in:
commit
d7b5f4f090
@ -1,6 +1,6 @@
|
|||||||
pkgbase = lidm-bin
|
pkgbase = lidm-bin
|
||||||
pkgdesc = A fully colorful customizable TUI display manager made in C. (release binary)
|
pkgdesc = A fully colorful customizable TUI display manager made in C. (release binary)
|
||||||
pkgver = 1.0.0
|
pkgver = 1.1.0
|
||||||
pkgrel = 1
|
pkgrel = 1
|
||||||
url = https://github.com/javalsai/lidm
|
url = https://github.com/javalsai/lidm
|
||||||
arch = x86_64
|
arch = x86_64
|
||||||
@ -8,11 +8,11 @@ pkgbase = lidm-bin
|
|||||||
depends = pam
|
depends = pam
|
||||||
provides = lidm
|
provides = lidm
|
||||||
conflicts = lidm
|
conflicts = lidm
|
||||||
source = lidm::https://github.com/javalsai/lidm/releases/download/v1.0.0/lidm-amd64
|
source = lidm::https://github.com/javalsai/lidm/releases/download/v1.1.0/lidm-amd64
|
||||||
source = default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/v1.0.0/themes/default.ini
|
source = default-theme.ini::https://raw.githubusercontent.com/javalsai/lidm/v1.1.0/themes/default.ini
|
||||||
source = lidm.1::https://raw.githubusercontent.com/javalsai/lidm/v1.0.0/assets/man/lidm.1
|
source = lidm.1::https://raw.githubusercontent.com/javalsai/lidm/v1.1.0/assets/man/lidm.1
|
||||||
source = lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/v1.0.0/assets/man/lidm-config.5
|
source = lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/v1.1.0/assets/man/lidm-config.5
|
||||||
sha256sums = 77e8aeeb8dd751620a63220fa6e419d9066b1b35d79e12ce5449a5a1acb24252
|
sha256sums = 7bc64f0f10994c062ea80ea2c6ee9d45828567b448e170fb3e7af4111ce1c2dc
|
||||||
sha256sums = a8d29e220c23b48b5cd3aac0c0e395e90a9d6c9ca9c9c35a45ad6f3df5f55542
|
sha256sums = a8d29e220c23b48b5cd3aac0c0e395e90a9d6c9ca9c9c35a45ad6f3df5f55542
|
||||||
sha256sums = 7f2fb91f55088be1a9b1c93ecf5d6c1e437f369b56df2eacc9d10b00c93c39f8
|
sha256sums = 7f2fb91f55088be1a9b1c93ecf5d6c1e437f369b56df2eacc9d10b00c93c39f8
|
||||||
sha256sums = 5dbe088ce29c95a400080190560d4308c10519a953e83d2d5020dfdf47dd830f
|
sha256sums = 5dbe088ce29c95a400080190560d4308c10519a953e83d2d5020dfdf47dd830f
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
|
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
|
||||||
# Maintainer: javalsai <javalsai@proton.me>
|
# Maintainer: javalsai <javalsai@proton.me>
|
||||||
pkgname=lidm-bin
|
pkgname=lidm-bin
|
||||||
pkgver=1.0.0
|
pkgver=1.1.0
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
depends=('pam')
|
depends=('pam')
|
||||||
pkgdesc="A fully colorful customizable TUI display manager made in C. (release binary)"
|
pkgdesc="A fully colorful customizable TUI display manager made in C. (release binary)"
|
||||||
@ -16,7 +16,7 @@ source=(
|
|||||||
"lidm.1::https://raw.githubusercontent.com/javalsai/lidm/v$pkgver/assets/man/lidm.1"
|
"lidm.1::https://raw.githubusercontent.com/javalsai/lidm/v$pkgver/assets/man/lidm.1"
|
||||||
"lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/v$pkgver/assets/man/lidm-config.5"
|
"lidm-config.5::https://raw.githubusercontent.com/javalsai/lidm/v$pkgver/assets/man/lidm-config.5"
|
||||||
)
|
)
|
||||||
sha256sums=('77e8aeeb8dd751620a63220fa6e419d9066b1b35d79e12ce5449a5a1acb24252'
|
sha256sums=('7bc64f0f10994c062ea80ea2c6ee9d45828567b448e170fb3e7af4111ce1c2dc'
|
||||||
'a8d29e220c23b48b5cd3aac0c0e395e90a9d6c9ca9c9c35a45ad6f3df5f55542'
|
'a8d29e220c23b48b5cd3aac0c0e395e90a9d6c9ca9c9c35a45ad6f3df5f55542'
|
||||||
'7f2fb91f55088be1a9b1c93ecf5d6c1e437f369b56df2eacc9d10b00c93c39f8'
|
'7f2fb91f55088be1a9b1c93ecf5d6c1e437f369b56df2eacc9d10b00c93c39f8'
|
||||||
'5dbe088ce29c95a400080190560d4308c10519a953e83d2d5020dfdf47dd830f')
|
'5dbe088ce29c95a400080190560d4308c10519a953e83d2d5020dfdf47dd830f')
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
|
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
|
||||||
# Maintainer: javalsai <javalsai@proton.me>
|
# Maintainer: javalsai <javalsai@proton.me>
|
||||||
pkgname=lidm-git
|
pkgname=lidm-git
|
||||||
pkgver=1.0.0.r0.g2b1e469
|
pkgver=1.1.0.r0.g11e9257
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
depends=('pam')
|
depends=('pam')
|
||||||
makedepends=('git' 'make' 'gcc')
|
makedepends=('git' 'make' 'gcc')
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
pkgbase = lidm
|
pkgbase = lidm
|
||||||
pkgdesc = A fully colorful customizable TUI display manager made in C. (build latest tag)
|
pkgdesc = A fully colorful customizable TUI display manager made in C. (build latest tag)
|
||||||
pkgver = 1.0.0
|
pkgver = 1.1.0
|
||||||
pkgrel = 1
|
pkgrel = 1
|
||||||
url = https://github.com/javalsai/lidm
|
url = https://github.com/javalsai/lidm
|
||||||
arch = any
|
arch = any
|
||||||
@ -8,7 +8,7 @@ pkgbase = lidm
|
|||||||
makedepends = git
|
makedepends = git
|
||||||
makedepends = gcc
|
makedepends = gcc
|
||||||
depends = pam
|
depends = pam
|
||||||
source = tarball.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/v1.0.0.tar.gz
|
source = tarball.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/v1.1.0.tar.gz
|
||||||
sha256sums = 5a336c7aecc709d1514e6f16f63b316263894a08291a49aaae8ee1b6a06bad74
|
sha256sums = 4c39eb29f8a8b705b7a40f71df9b0ee2c8c140da039f933b2b895e649aaa8068
|
||||||
|
|
||||||
pkgname = lidm
|
pkgname = lidm
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
|
# shellcheck disable=SC2034,SC2148,SC2128,SC2154,SC2164
|
||||||
# Maintainer: javalsai <javalsai@proton.me>
|
# Maintainer: javalsai <javalsai@proton.me>
|
||||||
pkgname=lidm
|
pkgname=lidm
|
||||||
pkgver=1.0.0
|
pkgver=1.1.0
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
depends=('pam')
|
depends=('pam')
|
||||||
makedepends=('git' 'gcc')
|
makedepends=('git' 'gcc')
|
||||||
@ -10,7 +10,7 @@ arch=('any')
|
|||||||
url="https://github.com/javalsai/lidm"
|
url="https://github.com/javalsai/lidm"
|
||||||
license=('GPL')
|
license=('GPL')
|
||||||
source=("tarball.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/v$pkgver.tar.gz")
|
source=("tarball.tar.gz::https://github.com/javalsai/lidm/archive/refs/tags/v$pkgver.tar.gz")
|
||||||
sha256sums=('5a336c7aecc709d1514e6f16f63b316263894a08291a49aaae8ee1b6a06bad74')
|
sha256sums=('4c39eb29f8a8b705b7a40f71df9b0ee2c8c140da039f933b2b895e649aaa8068')
|
||||||
|
|
||||||
build() {
|
build() {
|
||||||
tar -xzf "tarball.tar.gz"
|
tar -xzf "tarball.tar.gz"
|
||||||
|
@ -2,15 +2,16 @@
|
|||||||
#define LAUNCHSTATEH_
|
#define LAUNCHSTATEH_
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include "macros.h"
|
||||||
|
|
||||||
struct LaunchState {
|
struct LaunchState {
|
||||||
int user_opt;
|
char* NNULLABLE username;
|
||||||
int session_opt;
|
char* NNULLABLE session_opt;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LaunchState read_launch_state();
|
int read_launch_state(struct LaunchState* NNULLABLE state);
|
||||||
bool write_launch_state(struct LaunchState state);
|
bool write_launch_state(struct LaunchState state);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
17
src/config.c
17
src/config.c
@ -126,7 +126,7 @@ struct parser_error parse_key(enum introspection_type typ, union typ_ptr at,
|
|||||||
aux_str = strdup(key);
|
aux_str = strdup(key);
|
||||||
if (!aux_str) FAIL("allocation failure");
|
if (!aux_str) FAIL("allocation failure");
|
||||||
aux_err = parse_str_inplace(aux_str);
|
aux_err = parse_str_inplace(aux_str);
|
||||||
if (!aux_err.msg) {
|
if (aux_err.msg) {
|
||||||
free(aux_str);
|
free(aux_str);
|
||||||
return aux_err;
|
return aux_err;
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ struct parser_error parse_key(enum introspection_type typ, union typ_ptr at,
|
|||||||
aux_str = strdup(key);
|
aux_str = strdup(key);
|
||||||
if (!aux_str) FAIL("allocation failure");
|
if (!aux_str) FAIL("allocation failure");
|
||||||
aux_err = parse_str_inplace(aux_str);
|
aux_err = parse_str_inplace(aux_str);
|
||||||
if (!aux_err.msg) {
|
if (aux_err.msg) {
|
||||||
free(aux_str);
|
free(aux_str);
|
||||||
return aux_err;
|
return aux_err;
|
||||||
}
|
}
|
||||||
@ -170,7 +170,7 @@ struct parser_error parse_key(enum introspection_type typ, union typ_ptr at,
|
|||||||
#undef FAIL
|
#undef FAIL
|
||||||
#undef NOFAIL
|
#undef NOFAIL
|
||||||
|
|
||||||
// NOLINTBEGIN(readability-identifier-length,readability-function-cognitive-complexity,readability-identifier-length)
|
// NOLINTBEGIN(readability-identifier-length,readability-function-cognitive-complexity)
|
||||||
struct status config_line_handler(void* _config, char* table, char* k,
|
struct status config_line_handler(void* _config, char* table, char* k,
|
||||||
char* v) {
|
char* v) {
|
||||||
struct config* config = (struct config*)_config;
|
struct config* config = (struct config*)_config;
|
||||||
@ -213,11 +213,14 @@ struct status config_line_handler(void* _config, char* table, char* k,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_printf("[I] cfg parsed [%s.%s]\n", table, k);
|
if (this_intros_key->typ == STRING)
|
||||||
|
log_printf("[I] cfg parsed [%s.%s] (%s)\n", table, k, *k_addr.string);
|
||||||
|
else
|
||||||
|
log_printf("[I] cfg parsed [%s.%s]\n", table, k);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
// NOLINTEND(readability-identifier-length,readability-function-cognitive-complexity,readability-identifier-length)
|
// NOLINTEND(readability-identifier-length,readability-function-cognitive-complexity)
|
||||||
|
|
||||||
int parse_config(struct config* NNULLABLE config, char* NNULLABLE path) {
|
int parse_config(struct config* NNULLABLE config, char* NNULLABLE path) {
|
||||||
FILE* fd = fopen(path, "r");
|
FILE* fd = fopen(path, "r");
|
||||||
@ -232,9 +235,7 @@ int parse_config(struct config* NNULLABLE config, char* NNULLABLE path) {
|
|||||||
|
|
||||||
bool ret = read_desktop(fd, config, config_line_handler);
|
bool ret = read_desktop(fd, config, config_line_handler);
|
||||||
(void)fclose(fd);
|
(void)fclose(fd);
|
||||||
if (!ret) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!ret) return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,32 +1,52 @@
|
|||||||
// Small file for saving last selection
|
// Small file for saving last selection
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "launch_state.h"
|
||||||
|
|
||||||
#define STATE_DIR "/var/lib/lidm"
|
#define STATE_DIR "/var/lib/lidm"
|
||||||
#define STATE_FILE "/var/lib/lidm/state"
|
#define STATE_FILE "/var/lib/lidm/state"
|
||||||
|
|
||||||
#include "launch_state.h"
|
#define RWXR_X___ 0750
|
||||||
|
|
||||||
struct LaunchState read_launch_state() {
|
int read_launch_state(struct LaunchState* NNULLABLE state) {
|
||||||
struct LaunchState state;
|
|
||||||
state.user_opt = 1;
|
|
||||||
state.session_opt = 1;
|
|
||||||
FILE* state_fd = fopen(STATE_FILE, "r");
|
FILE* state_fd = fopen(STATE_FILE, "r");
|
||||||
if (state_fd == NULL) return state;
|
if (state_fd == NULL) return -1;
|
||||||
if (fscanf(state_fd, "%i;%i", &state.user_opt, &state.session_opt) != 2) {
|
|
||||||
state.user_opt = 1;
|
*state = (struct LaunchState){
|
||||||
state.session_opt = 1;
|
.username = NULL,
|
||||||
|
.session_opt = NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
size_t num = 0;
|
||||||
|
if (getline(&state->username, &num, state_fd) < 0) goto fail;
|
||||||
|
state->username[strcspn(state->username, "\n")] = 0;
|
||||||
|
|
||||||
|
num = 0;
|
||||||
|
if (getline(&state->session_opt, &num, state_fd) < 0) {
|
||||||
|
free(state->session_opt);
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
state->session_opt[strcspn(state->session_opt, "\n")] = 0;
|
||||||
|
|
||||||
(void)fclose(state_fd);
|
(void)fclose(state_fd);
|
||||||
return state;
|
return 0;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
(void)fclose(state_fd);
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool write_launch_state(struct LaunchState state) {
|
bool write_launch_state(struct LaunchState state) {
|
||||||
FILE* state_fd = fopen(STATE_FILE, "w");
|
FILE* state_fd = fopen(STATE_FILE, "w");
|
||||||
if (state_fd == NULL) {
|
if (state_fd == NULL) {
|
||||||
if (mkdir(STATE_DIR, 0755) == -1) return false;
|
if (mkdir(STATE_DIR, RWXR_X___) == -1) return false;
|
||||||
state_fd = fopen(STATE_FILE, "w");
|
state_fd = fopen(STATE_FILE, "w");
|
||||||
if (state_fd == NULL) return false;
|
if (state_fd == NULL) return false;
|
||||||
}
|
}
|
||||||
(void)fprintf(state_fd, "%i;%i", state.user_opt, state.session_opt);
|
(void)fprintf(state_fd, "%s\n%s\n", state.username, state.session_opt);
|
||||||
(void)fclose(state_fd);
|
(void)fclose(state_fd);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
44
src/ui.c
44
src/ui.c
@ -21,6 +21,7 @@
|
|||||||
#include "efield.h"
|
#include "efield.h"
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
#include "launch_state.h"
|
#include "launch_state.h"
|
||||||
|
#include "log.h"
|
||||||
#include "ofield.h"
|
#include "ofield.h"
|
||||||
#include "sessions.h"
|
#include "sessions.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
@ -199,15 +200,33 @@ int load(struct Vector* users, struct Vector* sessions) {
|
|||||||
of_user = ofield_new(users->length);
|
of_user = ofield_new(users->length);
|
||||||
of_passwd = ofield_new(0);
|
of_passwd = ofield_new(0);
|
||||||
|
|
||||||
struct LaunchState initial_state = read_launch_state();
|
of_user.current_opt = users->length > 0;
|
||||||
if (initial_state.user_opt > users->length ||
|
of_session.current_opt = sessions->length > 0;
|
||||||
initial_state.session_opt >
|
struct LaunchState initial_state;
|
||||||
sessions->length + g_config->behavior.include_defshell) {
|
if (read_launch_state(&initial_state) == 0) {
|
||||||
initial_state.user_opt = 1;
|
for (size_t i = 0; i < users->length; i++) {
|
||||||
initial_state.session_opt = 1;
|
struct user* user_i = (struct user*)vec_get(users, i);
|
||||||
|
if (strcmp(user_i->username, initial_state.username) == 0) {
|
||||||
|
of_user.current_opt = i + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < sessions->length; i++) {
|
||||||
|
struct session* session_i = (struct session*)vec_get(sessions, i);
|
||||||
|
if (strcmp(session_i->name, initial_state.session_opt) == 0) {
|
||||||
|
of_session.current_opt = i + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (g_config->behavior.include_defshell) {
|
||||||
|
if (strcmp(st_user().shell, initial_state.session_opt) == 0)
|
||||||
|
of_session.current_opt = sessions->length + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(initial_state.username);
|
||||||
|
free(initial_state.session_opt);
|
||||||
}
|
}
|
||||||
of_user.current_opt = initial_state.user_opt;
|
|
||||||
of_session.current_opt = initial_state.session_opt;
|
|
||||||
|
|
||||||
/// PRINTING
|
/// PRINTING
|
||||||
const struct uint_point BOXSTART = box_start();
|
const struct uint_point BOXSTART = box_start();
|
||||||
@ -265,10 +284,11 @@ int load(struct Vector* users, struct Vector* sessions) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (len == 1 && *seq == '\n') {
|
if (len == 1 && *seq == '\n') {
|
||||||
struct LaunchState ls;
|
bool successful_write = write_launch_state((struct LaunchState){
|
||||||
ls.user_opt = of_user.current_opt;
|
.username = st_user().username,
|
||||||
ls.session_opt = of_session.current_opt;
|
.session_opt = st_session(g_config->behavior.include_defshell).name,
|
||||||
write_launch_state(ls);
|
});
|
||||||
|
if (!successful_write) log_puts("[E] failed to write launch state");
|
||||||
|
|
||||||
if (!launch(st_user().username, of_passwd.efield.content,
|
if (!launch(st_user().username, of_passwd.efield.content,
|
||||||
st_session(g_config->behavior.include_defshell),
|
st_session(g_config->behavior.include_defshell),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user