mirror of https://github.com/fairyglade/ly.git
Merge branch 'master' into master
This commit is contained in:
commit
1eab333747
15
.gitea
15
.gitea
|
|
@ -1,15 +0,0 @@
|
|||
[submodule "sub/argoat"]
|
||||
path = sub/argoat
|
||||
url = https://git.nullgemm.fr/nullgemm/argoat.git
|
||||
[submodule "sub/configator"]
|
||||
path = sub/configator
|
||||
url = https://git.nullgemm.fr/nullgemm/configator.git
|
||||
[submodule "sub/ctypes"]
|
||||
path = sub/ctypes
|
||||
url = https://git.nullgemm.fr/nullgemm/ctypes.git
|
||||
[submodule "sub/dragonfail"]
|
||||
path = sub/dragonfail
|
||||
url = https://git.nullgemm.fr/nullgemm/dragonfail.git
|
||||
[submodule "sub/termbox_next"]
|
||||
path = sub/termbox_next
|
||||
url = https://git.nullgemm.fr/nullgemm/termbox_next.git
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
bin
|
||||
obj
|
||||
.gitmodules
|
||||
valgrind.log
|
||||
|
|
|
|||
|
|
@ -4,9 +4,6 @@
|
|||
[submodule "sub/configator"]
|
||||
path = sub/configator
|
||||
url = https://github.com/nullgemm/configator.git
|
||||
[submodule "sub/ctypes"]
|
||||
path = sub/ctypes
|
||||
url = https://github.com/nullgemm/ctypes.git
|
||||
[submodule "sub/dragonfail"]
|
||||
path = sub/dragonfail
|
||||
url = https://github.com/nullgemm/dragonfail.git
|
||||
21
makefile
21
makefile
|
|
@ -104,24 +104,3 @@ clean:
|
|||
@echo "cleaning"
|
||||
@rm -rf $(BIND) $(OBJD) valgrind.log
|
||||
@(cd $(SUBD)/termbox_next && $(MAKE) clean)
|
||||
|
||||
remotes:
|
||||
@echo "registering remotes"
|
||||
@git remote add github git@github.com:nullgemm/$(NAME).git
|
||||
@git remote add gitea ssh://git@git.nullgem.fr:2999/nullgemm/$(NAME).git
|
||||
|
||||
github:
|
||||
@echo "sourcing submodules from https://github.com"
|
||||
@cp .github .gitmodules
|
||||
@git submodule sync
|
||||
@git submodule update --init --remote
|
||||
@cd $(SUBD)/argoat && make github
|
||||
@git submodule update --init --recursive --remote
|
||||
|
||||
gitea:
|
||||
@echo "sourcing submodules from personal server"
|
||||
@cp .gitea .gitmodules
|
||||
@git submodule sync
|
||||
@git submodule update --init --remote
|
||||
@cd $(SUBD)/argoat && make gitea
|
||||
@git submodule update --init --recursive --remote
|
||||
|
|
|
|||
|
|
@ -19,9 +19,11 @@ On Debian-based distros running `apt install build-essential libpam0g-dev libxcb
|
|||
|
||||
## Support
|
||||
The following desktop environments were tested with success
|
||||
- bspwm
|
||||
- budgie
|
||||
- cinnamon
|
||||
- deepin
|
||||
- dwm
|
||||
- enlightenment
|
||||
- gnome
|
||||
- i3
|
||||
|
|
@ -47,12 +49,7 @@ changing the source code won't be necessary :)
|
|||
## Cloning and Compiling
|
||||
Clone the repository
|
||||
```
|
||||
git clone https://github.com/nullgemm/ly.git
|
||||
```
|
||||
|
||||
Fetch submodules
|
||||
```
|
||||
make github
|
||||
git clone --recurse-submodules https://github.com/nullgemm/ly.git
|
||||
```
|
||||
|
||||
Compile
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@
|
|||
#hide_borders = false
|
||||
#hide_borders = true
|
||||
|
||||
# remove f1 commands
|
||||
#hide_f1_commands = false
|
||||
#hide_f1_commands = true
|
||||
|
||||
# number of visible chars on an input
|
||||
#input_len = 34
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
capslock = capslock
|
||||
err_alloc = impossibile allocare memoria
|
||||
err_bounds = indice fuori limite
|
||||
err_chdir = impossibile aprire home directory
|
||||
err_console_dev = impossibile aprire console
|
||||
err_dgn_oob = messaggio log
|
||||
err_domain = dominio non valido
|
||||
err_hostname = impossibile ottenere hostname
|
||||
err_mlock = impossibile ottenere lock per la password in memoria
|
||||
err_null = puntatore nullo
|
||||
err_pam = transazione PAM fallita
|
||||
err_pam_abort = transazione PAM interrotta
|
||||
err_pam_acct_expired = account scaduto
|
||||
err_pam_auth = errore di autenticazione
|
||||
err_pam_authinfo_unavail = impossibile ottenere informazioni utente
|
||||
err_pam_authok_reqd = token scaduto
|
||||
err_pam_buf = errore buffer memoria
|
||||
err_pam_cred_err = impossibile impostare credenziali
|
||||
err_pam_cred_expired = credenziali scadute
|
||||
err_pam_cred_insufficient = credenziali insufficienti
|
||||
err_pam_cred_unavail = impossibile ottenere credenziali
|
||||
err_pam_maxtries = raggiunto limite tentativi
|
||||
err_pam_perm_denied = permesso negato
|
||||
err_pam_session = errore di sessione
|
||||
err_pam_sys = errore di sistema
|
||||
err_pam_user_unknown = utente sconosciuto
|
||||
err_path = impossibile impostare percorso
|
||||
err_perm_dir = impossibile cambiare directory corrente
|
||||
err_perm_group = impossibile ridurre permessi gruppo
|
||||
err_perm_user = impossibile ridurre permessi utente
|
||||
err_pwnam = impossibile ottenere dati utente
|
||||
err_user_gid = impossibile impostare GID utente
|
||||
err_user_init = impossibile inizializzare utente
|
||||
err_user_uid = impossible impostare UID utente
|
||||
err_xsessions_dir = impossibile localizzare cartella sessioni
|
||||
err_xsessions_open = impossibile aprire cartella sessioni
|
||||
f1 = F1 arresto
|
||||
f2 = F2 riavvio
|
||||
login = username:
|
||||
logout = scollegato
|
||||
numlock = numlock
|
||||
password = password:
|
||||
shell = shell
|
||||
wayland = wayland
|
||||
xinitrc = xinitrc
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
capslock = capslock
|
||||
err_alloc = nieudana alokacja pamięci
|
||||
err_bounds = indeks poza granicami
|
||||
err_chdir = nie udało się otworzyć folderu domowego
|
||||
err_console_dev = nie udało się uzyskać dostępu do konsoli
|
||||
err_dgn_oob = wiadomość loga
|
||||
err_domain = niepoprawna domena
|
||||
err_hostname = nie udało się uzyskać nazwy hosta
|
||||
err_mlock = nie udało się zablokować pamięci haseł
|
||||
err_null = wskaźnik zerowy
|
||||
err_pam = transakcja pam nieudana
|
||||
err_pam_abort = transakcja pam przerwana
|
||||
err_pam_acct_expired = konto wygasło
|
||||
err_pam_auth = błąd autentyfikacji
|
||||
err_pam_authinfo_unavail = nie udało się zdobyć informacji o użytkowniku
|
||||
err_pam_authok_reqd = token wygasł
|
||||
err_pam_buf = błąd bufora pamięci
|
||||
err_pam_cred_err = nie udało się ustawić uwierzytelnienia
|
||||
err_pam_cred_expired = uwierzytelnienie wygasło
|
||||
err_pam_cred_insufficient = niewystarczające uwierzytelnienie
|
||||
err_pam_cred_unavail = nie udało się uzyskać uwierzytelnienia
|
||||
err_pam_maxtries = osiągnięto limit prób
|
||||
err_pam_perm_denied = brak uprawnień
|
||||
err_pam_session = błąd sesji
|
||||
err_pam_sys = błąd systemu
|
||||
err_pam_user_unknown = nieznany użytkownik
|
||||
err_path = nie udało się ustawić ścieżki
|
||||
err_perm_dir = nie udało się zmienić obecnego katalogu
|
||||
err_perm_group = nie udało się obniżyć uprawnień grupy
|
||||
err_perm_user = nie udało się obniżyć uprawnień użytkownika
|
||||
err_pwnam = nie udało się uzyskać informacji o użytkowniku
|
||||
err_user_gid = nie udało się ustawić GID użytkownika
|
||||
err_user_init = nie udało się zainicjalizować użytkownika
|
||||
err_user_uid = nie udało się ustawić UID użytkownika
|
||||
err_xsessions_dir = nie udało się znaleźć folderu sesji
|
||||
err_xsessions_open = nie udało się otworzyć folderu sesji
|
||||
f1 = F1 wyłącz
|
||||
f2 = F2 uruchom ponownie
|
||||
login = login:
|
||||
logout = wylogowano
|
||||
numlock = numlock
|
||||
password = hasło:
|
||||
shell = powłoka
|
||||
wayland = wayland
|
||||
xinitrc = xinitrc
|
||||
|
|
@ -10,17 +10,17 @@ err_mlock = сбой блокировки памяти
|
|||
err_null = нулевой указатель
|
||||
err_pam = pam транзакция не удалась
|
||||
err_pam_abort = pam транзакция прервана
|
||||
err_pam_acct_expired = срок действия аккаунта истек
|
||||
err_pam_acct_expired = срок действия аккаунта истёк
|
||||
err_pam_auth = ошибка аутентификации
|
||||
err_pam_authinfo_unavail = не удалось получить информацию о пользователе
|
||||
err_pam_authok_reqd = токен истек
|
||||
err_pam_authok_reqd = токен истёк
|
||||
err_pam_buf = ошибка буфера памяти
|
||||
err_pam_cred_err = не удалось установить полномочия
|
||||
err_pam_cred_expired = полномочия истекли
|
||||
err_pam_cred_insufficient = недостаточо полномочий
|
||||
err_pam_cred_unavail = не удалось получить полномочия
|
||||
err_pam_maxtries = лимит попыток исчерпан
|
||||
err_pam_perm_denied = доступ запрещен
|
||||
err_pam_perm_denied = доступ запрещён
|
||||
err_pam_session = ошибка сессии
|
||||
err_pam_sys = системная ошибка
|
||||
err_pam_user_unknown = неизвестный пользователь
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
capslock = capslock
|
||||
err_alloc = neuspijesna alokacija memorije
|
||||
err_bounds = izvan granica indeksa
|
||||
err_chdir = neuspijesno otvaranje home foldera
|
||||
err_console_dev = neuspijesno pristupanje konzoli
|
||||
err_dgn_oob = log poruka
|
||||
err_domain = nevazeci domen
|
||||
err_hostname = neuspijesno trazenje hostname-a
|
||||
err_mlock = neuspijesno zakljucavanje memorije lozinke
|
||||
err_null = null pokazivac
|
||||
err_pam = pam transakcija neuspijesna
|
||||
err_pam_abort = pam transakcija prekinuta
|
||||
err_pam_acct_expired = nalog istekao
|
||||
err_pam_auth = greska pri autentikaciji
|
||||
err_pam_authinfo_unavail = neuspjelo uzimanje informacija o korisniku
|
||||
err_pam_authok_reqd = token istekao
|
||||
err_pam_buf = greska bafera memorije
|
||||
err_pam_cred_err = neuspjelo postavljanje kredencijala
|
||||
err_pam_cred_expired = kredencijali istekli
|
||||
err_pam_cred_insufficient = nedovoljni kredencijali
|
||||
err_pam_cred_unavail = neuspjelo uzimanje kredencijala
|
||||
err_pam_maxtries = dostignut maksimalan broj pokusaja
|
||||
err_pam_perm_denied = nedozovoljeno
|
||||
err_pam_session = greska sesije
|
||||
err_pam_sys = greska sistema
|
||||
err_pam_user_unknown = nepoznat korisnik
|
||||
err_path = neuspjelo postavljanje path-a
|
||||
err_perm_dir = neuspjelo mijenjanje foldera
|
||||
err_perm_group = neuspjesno snizavanje dozvola grupe
|
||||
err_perm_user = neuspijesno snizavanje dozvola korisnika
|
||||
err_pwnam = neuspijesno skupljanje informacija o korisniku
|
||||
err_user_gid = neuspijesno postavljanje korisničkog GID-a
|
||||
err_user_init = neuspijensa inicijalizacija korisnika
|
||||
err_user_uid = neuspijesno postavljanje UID-a korisnika
|
||||
err_xsessions_dir = neuspijesno pronalazenje foldera sesija
|
||||
err_xsessions_open = neuspijesno otvaranje foldera sesija
|
||||
f1 = F1 ugasi
|
||||
f2 = F2 ponovo pokreni
|
||||
login = korisnik:
|
||||
logout = izlogovan
|
||||
numlock = numlock
|
||||
password = lozinka:
|
||||
shell = shell
|
||||
wayland = wayland
|
||||
xinitrc = xinitrc
|
||||
11
src/config.c
11
src/config.c
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
|
@ -30,11 +32,11 @@ static void config_handle_u8(void* data, char** pars, const int pars_count)
|
|||
{
|
||||
if (strcmp(*pars, "") == 0)
|
||||
{
|
||||
*((u8*)data) = 0;
|
||||
*((uint8_t*)data) = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*((u8*)data) = atoi(*pars);
|
||||
*((uint8_t*)data) = atoi(*pars);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -42,11 +44,11 @@ static void config_handle_u16(void* data, char** pars, const int pars_count)
|
|||
{
|
||||
if (strcmp(*pars, "") == 0)
|
||||
{
|
||||
*((u16*)data) = 0;
|
||||
*((uint16_t*)data) = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*((u16*)data) = atoi(*pars);
|
||||
*((uint16_t*)data) = atoi(*pars);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -165,6 +167,7 @@ void config_load(const char *cfg_path)
|
|||
{"default_input", &config.default_input, config_handle_u8},
|
||||
{"fg", &config.fg, config_handle_u8},
|
||||
{"hide_borders", &config.hide_borders, config_handle_bool},
|
||||
{"hide_f1_commands", &config.hide_f1_commands, config_handle_bool},
|
||||
{"input_len", &config.input_len, config_handle_u8},
|
||||
{"lang", &config.lang, config_handle_str},
|
||||
{"load", &config.load, config_handle_bool},
|
||||
|
|
|
|||
28
src/config.h
28
src/config.h
|
|
@ -1,7 +1,8 @@
|
|||
#ifndef H_LY_CONFIG
|
||||
#define H_LY_CONFIG
|
||||
|
||||
#include "ctypes.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
enum INPUTS {
|
||||
SESSION_SWITCH,
|
||||
|
|
@ -61,25 +62,26 @@ struct lang
|
|||
struct config
|
||||
{
|
||||
bool animate;
|
||||
u8 animation;
|
||||
uint8_t animation;
|
||||
char asterisk;
|
||||
u8 bg;
|
||||
uint8_t bg;
|
||||
bool blank_box;
|
||||
bool blank_password;
|
||||
char* console_dev;
|
||||
u8 default_input;
|
||||
u8 fg;
|
||||
uint8_t default_input;
|
||||
uint8_t fg;
|
||||
bool hide_borders;
|
||||
u8 input_len;
|
||||
bool hide_f1_commands;
|
||||
uint8_t input_len;
|
||||
char* lang;
|
||||
bool load;
|
||||
u8 margin_box_h;
|
||||
u8 margin_box_v;
|
||||
u8 max_desktop_len;
|
||||
u8 max_login_len;
|
||||
u8 max_password_len;
|
||||
uint8_t margin_box_h;
|
||||
uint8_t margin_box_v;
|
||||
uint8_t max_desktop_len;
|
||||
uint8_t max_login_len;
|
||||
uint8_t max_password_len;
|
||||
char* mcookie_cmd;
|
||||
u16 min_refresh_delta;
|
||||
uint16_t min_refresh_delta;
|
||||
char* path;
|
||||
char* restart_cmd;
|
||||
bool save;
|
||||
|
|
@ -87,7 +89,7 @@ struct config
|
|||
char* service_name;
|
||||
char* shutdown_cmd;
|
||||
char* term_reset_cmd;
|
||||
u8 tty;
|
||||
uint8_t tty;
|
||||
char* wayland_cmd;
|
||||
bool wayland_specifier;
|
||||
char* waylandsessions;
|
||||
|
|
|
|||
81
src/draw.c
81
src/draw.c
|
|
@ -1,6 +1,5 @@
|
|||
#include "dragonfail.h"
|
||||
#include "termbox.h"
|
||||
#include "ctypes.h"
|
||||
|
||||
#include "inputs.h"
|
||||
#include "utils.h"
|
||||
|
|
@ -9,6 +8,8 @@
|
|||
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
|
@ -29,8 +30,8 @@ void draw_init(struct term_buf* buf)
|
|||
buf->height = tb_height();
|
||||
hostname(&buf->info_line);
|
||||
|
||||
u16 len_login = strlen(lang.login);
|
||||
u16 len_password = strlen(lang.password);
|
||||
uint16_t len_login = strlen(lang.login);
|
||||
uint16_t len_password = strlen(lang.password);
|
||||
|
||||
if (len_login > len_password)
|
||||
{
|
||||
|
|
@ -89,10 +90,10 @@ void draw_free(struct term_buf* buf)
|
|||
|
||||
void draw_box(struct term_buf* buf)
|
||||
{
|
||||
u16 box_x = (buf->width - buf->box_width) / 2;
|
||||
u16 box_y = (buf->height - buf->box_height) / 2;
|
||||
u16 box_x2 = (buf->width + buf->box_width) / 2;
|
||||
u16 box_y2 = (buf->height + buf->box_height) / 2;
|
||||
uint16_t box_x = (buf->width - buf->box_width) / 2;
|
||||
uint16_t box_y = (buf->height - buf->box_height) / 2;
|
||||
uint16_t box_x2 = (buf->width + buf->box_width) / 2;
|
||||
uint16_t box_y2 = (buf->height + buf->box_height) / 2;
|
||||
buf->box_x = box_x;
|
||||
buf->box_y = box_y;
|
||||
|
||||
|
|
@ -128,7 +129,7 @@ void draw_box(struct term_buf* buf)
|
|||
struct tb_cell c1 = {buf->box_chars.top, config.fg, config.bg};
|
||||
struct tb_cell c2 = {buf->box_chars.bot, config.fg, config.bg};
|
||||
|
||||
for (u8 i = 0; i < buf->box_width; ++i)
|
||||
for (uint8_t i = 0; i < buf->box_width; ++i)
|
||||
{
|
||||
tb_put_cell(
|
||||
box_x + i,
|
||||
|
|
@ -144,7 +145,7 @@ void draw_box(struct term_buf* buf)
|
|||
c1.ch = buf->box_chars.left;
|
||||
c2.ch = buf->box_chars.right;
|
||||
|
||||
for (u8 i = 0; i < buf->box_height; ++i)
|
||||
for (uint8_t i = 0; i < buf->box_height; ++i)
|
||||
{
|
||||
tb_put_cell(
|
||||
box_x - 1,
|
||||
|
|
@ -162,9 +163,9 @@ void draw_box(struct term_buf* buf)
|
|||
{
|
||||
struct tb_cell blank = {' ', config.fg, config.bg};
|
||||
|
||||
for (u8 i = 0; i < buf->box_height; ++i)
|
||||
for (uint8_t i = 0; i < buf->box_height; ++i)
|
||||
{
|
||||
for (u8 k = 0; k < buf->box_width; ++k)
|
||||
for (uint8_t k = 0; k < buf->box_width; ++k)
|
||||
{
|
||||
tb_put_cell(
|
||||
box_x + k,
|
||||
|
|
@ -175,15 +176,15 @@ void draw_box(struct term_buf* buf)
|
|||
}
|
||||
}
|
||||
|
||||
struct tb_cell* strn_cell(char* s, u16 len) // throws
|
||||
struct tb_cell* strn_cell(char* s, uint16_t len) // throws
|
||||
{
|
||||
struct tb_cell* cells = malloc((sizeof (struct tb_cell)) * len);
|
||||
char* s2 = s;
|
||||
u32 c;
|
||||
uint32_t c;
|
||||
|
||||
if (cells != NULL)
|
||||
{
|
||||
for (u16 i = 0; i < len; ++i)
|
||||
for (uint16_t i = 0; i < len; ++i)
|
||||
{
|
||||
if ((s2 - s) >= len)
|
||||
{
|
||||
|
|
@ -250,7 +251,7 @@ void draw_labels(struct term_buf* buf) // throws
|
|||
|
||||
if (buf->info_line != NULL)
|
||||
{
|
||||
u16 len = strlen(buf->info_line);
|
||||
uint16_t len = strlen(buf->info_line);
|
||||
struct tb_cell* info_cell = str_cell(buf->info_line);
|
||||
|
||||
if (dgn_catch())
|
||||
|
|
@ -326,7 +327,7 @@ void draw_lock_state(struct term_buf* buf)
|
|||
close(fd);
|
||||
|
||||
// print text
|
||||
u16 pos_x = buf->width - strlen(lang.numlock);
|
||||
uint16_t pos_x = buf->width - strlen(lang.numlock);
|
||||
|
||||
if (numlock_on)
|
||||
{
|
||||
|
|
@ -363,7 +364,7 @@ void draw_lock_state(struct term_buf* buf)
|
|||
|
||||
void draw_desktop(struct desktop* target)
|
||||
{
|
||||
u16 len = strlen(target->list[target->cur]);
|
||||
uint16_t len = strlen(target->list[target->cur]);
|
||||
|
||||
if (len > (target->visible_len - 3))
|
||||
{
|
||||
|
|
@ -384,7 +385,7 @@ void draw_desktop(struct desktop* target)
|
|||
config.fg,
|
||||
config.bg);
|
||||
|
||||
for (u16 i = 0; i < len; ++ i)
|
||||
for (uint16_t i = 0; i < len; ++ i)
|
||||
{
|
||||
tb_change_cell(
|
||||
target->x + i + 2,
|
||||
|
|
@ -397,8 +398,8 @@ void draw_desktop(struct desktop* target)
|
|||
|
||||
void draw_input(struct text* input)
|
||||
{
|
||||
u16 len = strlen(input->text);
|
||||
u16 visible_len = input->visible_len;
|
||||
uint16_t len = strlen(input->text);
|
||||
uint16_t visible_len = input->visible_len;
|
||||
|
||||
if (len > visible_len)
|
||||
{
|
||||
|
|
@ -418,7 +419,7 @@ void draw_input(struct text* input)
|
|||
|
||||
struct tb_cell c1 = {' ', config.fg, config.bg};
|
||||
|
||||
for (u16 i = input->end - input->visible_start; i < visible_len; ++i)
|
||||
for (uint16_t i = input->end - input->visible_start; i < visible_len; ++i)
|
||||
{
|
||||
tb_put_cell(
|
||||
input->x + i,
|
||||
|
|
@ -430,8 +431,8 @@ void draw_input(struct text* input)
|
|||
|
||||
void draw_input_mask(struct text* input)
|
||||
{
|
||||
u16 len = strlen(input->text);
|
||||
u16 visible_len = input->visible_len;
|
||||
uint16_t len = strlen(input->text);
|
||||
uint16_t visible_len = input->visible_len;
|
||||
|
||||
if (len > visible_len)
|
||||
{
|
||||
|
|
@ -441,7 +442,7 @@ void draw_input_mask(struct text* input)
|
|||
struct tb_cell c1 = {config.asterisk, config.fg, config.bg};
|
||||
struct tb_cell c2 = {' ', config.fg, config.bg};
|
||||
|
||||
for (u16 i = 0; i < visible_len; ++i)
|
||||
for (uint16_t i = 0; i < visible_len; ++i)
|
||||
{
|
||||
if (input->visible_start + i < input->end)
|
||||
{
|
||||
|
|
@ -466,8 +467,8 @@ void position_input(
|
|||
struct text* login,
|
||||
struct text* password)
|
||||
{
|
||||
u16 x = buf->box_x + config.margin_box_h + buf->labels_max_len + 1;
|
||||
i32 len = buf->box_x + buf->box_width - config.margin_box_h - x;
|
||||
uint16_t x = buf->box_x + config.margin_box_h + buf->labels_max_len + 1;
|
||||
int32_t len = buf->box_x + buf->box_width - config.margin_box_h - x;
|
||||
|
||||
if (len < 0)
|
||||
{
|
||||
|
|
@ -498,7 +499,7 @@ static void doom_init(struct term_buf* buf)
|
|||
dgn_throw(DGN_ALLOC);
|
||||
}
|
||||
|
||||
u16 tmp_len = buf->width * buf->height;
|
||||
uint16_t tmp_len = buf->width * buf->height;
|
||||
buf->astate.doom->buf = malloc(tmp_len);
|
||||
tmp_len -= buf->width;
|
||||
|
||||
|
|
@ -530,7 +531,7 @@ static void matrix_init(struct term_buf* buf)
|
|||
dgn_throw(DGN_ALLOC);
|
||||
}
|
||||
|
||||
u16 len = buf->height + 1;
|
||||
uint16_t len = buf->height + 1;
|
||||
s->grid = malloc(sizeof(struct matrix_dot*) * len);
|
||||
|
||||
if (s->grid == NULL)
|
||||
|
|
@ -644,12 +645,12 @@ static void doom(struct term_buf* term_buf)
|
|||
{0x2588, 8, 4}, // white
|
||||
};
|
||||
|
||||
u16 src;
|
||||
u16 random;
|
||||
u16 dst;
|
||||
uint16_t src;
|
||||
uint16_t random;
|
||||
uint16_t dst;
|
||||
|
||||
u16 w = term_buf->init_width;
|
||||
u8* tmp = term_buf->astate.doom->buf;
|
||||
uint16_t w = term_buf->init_width;
|
||||
uint8_t* tmp = term_buf->astate.doom->buf;
|
||||
|
||||
if ((term_buf->width != term_buf->init_width) || (term_buf->height != term_buf->init_height))
|
||||
{
|
||||
|
|
@ -658,9 +659,9 @@ static void doom(struct term_buf* term_buf)
|
|||
|
||||
struct tb_cell* buf = tb_cell_buffer();
|
||||
|
||||
for (u16 x = 0; x < w; ++x)
|
||||
for (uint16_t x = 0; x < w; ++x)
|
||||
{
|
||||
for (u16 y = 1; y < term_buf->init_height; ++y)
|
||||
for (uint16_t y = 1; y < term_buf->init_height; ++y)
|
||||
{
|
||||
src = y * w + x;
|
||||
random = ((rand() % 7) & 3);
|
||||
|
|
@ -781,13 +782,13 @@ static void matrix(struct term_buf* buf)
|
|||
}
|
||||
}
|
||||
|
||||
u32 blank;
|
||||
uint32_t blank;
|
||||
utf8_char_to_unicode(&blank, " ");
|
||||
|
||||
for (int j = 0; j < buf->width; j += 2) {
|
||||
for (int i = 1; i <= buf->height; ++i)
|
||||
{
|
||||
u32 c;
|
||||
uint32_t c;
|
||||
int fg = TB_GREEN;
|
||||
int bg = TB_DEFAULT;
|
||||
|
||||
|
|
@ -835,10 +836,10 @@ void animate(struct term_buf* buf)
|
|||
}
|
||||
}
|
||||
|
||||
bool cascade(struct term_buf* term_buf, u8* fails)
|
||||
bool cascade(struct term_buf* term_buf, uint8_t* fails)
|
||||
{
|
||||
u16 width = term_buf->width;
|
||||
u16 height = term_buf->height;
|
||||
uint16_t width = term_buf->width;
|
||||
uint16_t height = term_buf->height;
|
||||
|
||||
struct tb_cell* buf = tb_cell_buffer();
|
||||
bool changes = false;
|
||||
|
|
|
|||
45
src/draw.h
45
src/draw.h
|
|
@ -2,20 +2,21 @@
|
|||
#define H_LY_DRAW
|
||||
|
||||
#include "termbox.h"
|
||||
#include "ctypes.h"
|
||||
|
||||
#include "inputs.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct box
|
||||
{
|
||||
u32 left_up;
|
||||
u32 left_down;
|
||||
u32 right_up;
|
||||
u32 right_down;
|
||||
u32 top;
|
||||
u32 bot;
|
||||
u32 left;
|
||||
u32 right;
|
||||
uint32_t left_up;
|
||||
uint32_t left_down;
|
||||
uint32_t right_up;
|
||||
uint32_t right_down;
|
||||
uint32_t top;
|
||||
uint32_t bot;
|
||||
uint32_t left;
|
||||
uint32_t right;
|
||||
};
|
||||
|
||||
struct matrix_dot
|
||||
|
|
@ -34,7 +35,7 @@ struct matrix_state
|
|||
|
||||
struct doom_state
|
||||
{
|
||||
u8* buf;
|
||||
uint8_t* buf;
|
||||
};
|
||||
|
||||
union anim_state
|
||||
|
|
@ -45,18 +46,18 @@ union anim_state
|
|||
|
||||
struct term_buf
|
||||
{
|
||||
u16 width;
|
||||
u16 height;
|
||||
u16 init_width;
|
||||
u16 init_height;
|
||||
uint16_t width;
|
||||
uint16_t height;
|
||||
uint16_t init_width;
|
||||
uint16_t init_height;
|
||||
|
||||
struct box box_chars;
|
||||
char* info_line;
|
||||
u16 labels_max_len;
|
||||
u16 box_x;
|
||||
u16 box_y;
|
||||
u16 box_width;
|
||||
u16 box_height;
|
||||
uint16_t labels_max_len;
|
||||
uint16_t box_x;
|
||||
uint16_t box_y;
|
||||
uint16_t box_width;
|
||||
uint16_t box_height;
|
||||
|
||||
union anim_state astate;
|
||||
};
|
||||
|
|
@ -65,7 +66,7 @@ void draw_init(struct term_buf* buf);
|
|||
void draw_free(struct term_buf* buf);
|
||||
void draw_box(struct term_buf* buf);
|
||||
|
||||
struct tb_cell* strn_cell(char* s, u16 len);
|
||||
struct tb_cell* strn_cell(char* s, uint16_t len);
|
||||
struct tb_cell* str_cell(char* s);
|
||||
|
||||
void draw_labels(struct term_buf* buf);
|
||||
|
|
@ -83,6 +84,6 @@ void position_input(
|
|||
|
||||
void animate_init(struct term_buf* buf);
|
||||
void animate(struct term_buf* buf);
|
||||
bool cascade(struct term_buf* buf, u8* fails);
|
||||
bool cascade(struct term_buf* buf, uint8_t* fails);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
#include "dragonfail.h"
|
||||
#include "termbox.h"
|
||||
#include "ctypes.h"
|
||||
|
||||
#include "inputs.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
|
|
@ -89,7 +88,7 @@ void input_desktop(struct desktop* target)
|
|||
#endif
|
||||
}
|
||||
|
||||
void input_text(struct text* target, u64 len)
|
||||
void input_text(struct text* target, uint64_t len)
|
||||
{
|
||||
target->text = malloc(len + 1);
|
||||
|
||||
|
|
@ -123,7 +122,7 @@ void input_desktop_free(struct desktop* target)
|
|||
{
|
||||
if (target != NULL)
|
||||
{
|
||||
for (u16 i = 0; i < target->len; ++i)
|
||||
for (uint16_t i = 0; i < target->len; ++i)
|
||||
{
|
||||
if (target->list[i] != NULL)
|
||||
{
|
||||
|
|
|
|||
23
src/inputs.h
23
src/inputs.h
|
|
@ -2,7 +2,8 @@
|
|||
#define H_LY_INPUTS
|
||||
|
||||
#include "termbox.h"
|
||||
#include "ctypes.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
enum display_server {DS_WAYLAND, DS_SHELL, DS_XINITRC, DS_XORG};
|
||||
|
||||
|
|
@ -10,13 +11,13 @@ struct text
|
|||
{
|
||||
char* text;
|
||||
char* end;
|
||||
i64 len;
|
||||
int64_t len;
|
||||
char* cur;
|
||||
char* visible_start;
|
||||
u16 visible_len;
|
||||
uint16_t visible_len;
|
||||
|
||||
u16 x;
|
||||
u16 y;
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
};
|
||||
|
||||
struct desktop
|
||||
|
|
@ -25,17 +26,17 @@ struct desktop
|
|||
char** cmd;
|
||||
enum display_server* display_server;
|
||||
|
||||
u16 cur;
|
||||
u16 len;
|
||||
u16 visible_len;
|
||||
u16 x;
|
||||
u16 y;
|
||||
uint16_t cur;
|
||||
uint16_t len;
|
||||
uint16_t visible_len;
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
};
|
||||
|
||||
void handle_desktop(void* input_struct, struct tb_event* event);
|
||||
void handle_text(void* input_struct, struct tb_event* event);
|
||||
void input_desktop(struct desktop* target);
|
||||
void input_text(struct text* target, u64 len);
|
||||
void input_text(struct text* target, uint64_t len);
|
||||
void input_desktop_free(struct desktop* target);
|
||||
void input_text_free(struct text* target);
|
||||
void input_desktop_right(struct desktop* target);
|
||||
|
|
|
|||
30
src/login.c
30
src/login.c
|
|
@ -12,6 +12,7 @@
|
|||
#include <pwd.h>
|
||||
#include <security/pam_appl.h>
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
@ -24,7 +25,7 @@
|
|||
int get_free_display()
|
||||
{
|
||||
char xlock[1024];
|
||||
u8 i;
|
||||
uint8_t i;
|
||||
|
||||
for (i = 0; i < 200; ++i)
|
||||
{
|
||||
|
|
@ -241,15 +242,8 @@ void env_init(struct passwd* pwd)
|
|||
}
|
||||
}
|
||||
|
||||
void env_xdg(const char* tty_id, const enum display_server display_server)
|
||||
void env_xdg_session(const enum display_server display_server)
|
||||
{
|
||||
char user[15];
|
||||
snprintf(user, 15, "/run/user/%d", getuid());
|
||||
setenv("XDG_RUNTIME_DIR", user, 0);
|
||||
setenv("XDG_SESSION_CLASS", "user", 0);
|
||||
setenv("XDG_SEAT", "seat0", 0);
|
||||
setenv("XDG_VTNR", tty_id, 0);
|
||||
|
||||
switch (display_server)
|
||||
{
|
||||
case DS_WAYLAND:
|
||||
|
|
@ -271,6 +265,17 @@ void env_xdg(const char* tty_id, const enum display_server display_server)
|
|||
}
|
||||
}
|
||||
|
||||
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_SEAT", "seat0", 0);
|
||||
setenv("XDG_VTNR", tty_id, 0);
|
||||
}
|
||||
|
||||
void add_utmp_entry(
|
||||
struct utmp *entry,
|
||||
char *username,
|
||||
|
|
@ -477,6 +482,9 @@ void auth(
|
|||
|
||||
ok = pam_start(config.service_name, NULL, &conv, &handle);
|
||||
|
||||
// Set XDG_SESSION_TYPE earlier to fix some bugs
|
||||
env_xdg_session(desktop->display_server[desktop->cur]);
|
||||
|
||||
if (ok != PAM_SUCCESS)
|
||||
{
|
||||
pam_diagnose(ok, buf);
|
||||
|
|
@ -594,13 +602,13 @@ void auth(
|
|||
// add pam variables
|
||||
char** env = pam_getenvlist(handle);
|
||||
|
||||
for (u16 i = 0; env && env[i]; ++i)
|
||||
for (uint16_t i = 0; env && env[i]; ++i)
|
||||
{
|
||||
putenv(env[i]);
|
||||
}
|
||||
|
||||
// add xdg variables
|
||||
env_xdg(tty_id, desktop->display_server[desktop->cur]);
|
||||
env_xdg(tty_id);
|
||||
|
||||
// execute
|
||||
int ok = chdir(pwd->pw_dir);
|
||||
|
|
|
|||
18
src/main.c
18
src/main.c
|
|
@ -2,7 +2,6 @@
|
|||
#include "configator.h"
|
||||
#include "dragonfail.h"
|
||||
#include "termbox.h"
|
||||
#include "ctypes.h"
|
||||
|
||||
#include "draw.h"
|
||||
#include "inputs.h"
|
||||
|
|
@ -10,8 +9,10 @@
|
|||
#include "utils.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -107,11 +108,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
config_load(config_path);
|
||||
|
||||
if (strcmp(config.lang, "en") != 0)
|
||||
{
|
||||
lang_load();
|
||||
}
|
||||
lang_load();
|
||||
|
||||
void* input_structs[3] =
|
||||
{
|
||||
|
|
@ -138,7 +135,7 @@ int main(int argc, char** argv)
|
|||
// init visible elements
|
||||
struct tb_event event;
|
||||
struct term_buf buf;
|
||||
u8 active_input = config.default_input;
|
||||
uint8_t active_input = config.default_input;
|
||||
|
||||
(*input_handles[active_input])(input_structs[active_input], NULL);
|
||||
|
||||
|
|
@ -162,7 +159,7 @@ int main(int argc, char** argv)
|
|||
bool update = true;
|
||||
bool reboot = false;
|
||||
bool shutdown = false;
|
||||
u8 auth_fails = 0;
|
||||
uint8_t auth_fails = 0;
|
||||
|
||||
switch_tty(&buf);
|
||||
|
||||
|
|
@ -177,7 +174,8 @@ int main(int argc, char** argv)
|
|||
animate(&buf);
|
||||
draw_box(&buf);
|
||||
draw_labels(&buf);
|
||||
draw_f_commands();
|
||||
if(!config.hide_f1_commands)
|
||||
draw_f_commands();
|
||||
draw_lock_state(&buf);
|
||||
position_input(&buf, &desktop, &login, &password);
|
||||
draw_desktop(&desktop);
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
#include "configator.h"
|
||||
#include "dragonfail.h"
|
||||
|
||||
#include "inputs.h"
|
||||
#include "config.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 76d1e23b5e7b84b82c291a3120d9e57bb2d50424
|
||||
Subproject commit e1844c4c94b70bb351ec2bd2ac6bb320ee793d8f
|
||||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit eb4b36559de8d17015f9416861ed085d06f5f5ed
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 0a2492c6aab3ff64e182db894ce4d40b26799fbd
|
||||
Subproject commit 15bd3299bf3e49bd6734bff385cb0392cd2fa502
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 23fff64470b0730959b39c70aa31fbddd776d9bc
|
||||
Subproject commit d961a8122210010e7c2c8f201e61170c13d319b4
|
||||
Loading…
Reference in New Issue