mirror of https://github.com/fairyglade/ly.git
Merge branch 'fairyglade:master' into master
This commit is contained in:
commit
443616e4ed
13
makefile
13
makefile
|
@ -104,16 +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
|
||||
|
||||
gitea: github
|
||||
github:
|
||||
@echo "sourcing submodules"
|
||||
@git submodule sync
|
||||
@git submodule update --init --remote
|
||||
@cd $(SUBD)/argoat && make github
|
||||
@git submodule update --init --recursive --remote
|
||||
|
|
10
readme.md
10
readme.md
|
@ -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
|
||||
|
@ -29,6 +31,7 @@ The following desktop environments were tested with success
|
|||
- lxde
|
||||
- lxqt
|
||||
- mate
|
||||
- qtile
|
||||
- sway
|
||||
- xfce
|
||||
- pantheon
|
||||
|
@ -47,12 +50,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
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
#animate = false
|
||||
#animate = true
|
||||
|
||||
# the active animation (only animation '0' available for now)
|
||||
# the active animation
|
||||
# 0 -> PSX DOOM fire (default)
|
||||
# 1 -> CMatrix
|
||||
#animation = 0
|
||||
|
||||
# the char used to mask the password
|
||||
|
@ -32,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
|
|
@ -167,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},
|
||||
|
|
|
@ -71,6 +71,7 @@ struct config
|
|||
uint8_t default_input;
|
||||
uint8_t fg;
|
||||
bool hide_borders;
|
||||
bool hide_f1_commands;
|
||||
uint8_t input_len;
|
||||
char* lang;
|
||||
bool load;
|
||||
|
|
269
src/draw.c
269
src/draw.c
|
@ -48,7 +48,7 @@ void draw_init(struct term_buf* buf)
|
|||
+ (config.input_len + 1)
|
||||
+ buf->labels_max_len;
|
||||
|
||||
#if defined(__linux__)
|
||||
#if defined(__linux__) || defined(__FreeBSD__)
|
||||
buf->box_chars.left_up = 0x250c;
|
||||
buf->box_chars.left_down = 0x2514;
|
||||
buf->box_chars.right_up = 0x2510;
|
||||
|
@ -69,11 +69,22 @@ void draw_init(struct term_buf* buf)
|
|||
#endif
|
||||
}
|
||||
|
||||
static void doom_free(struct term_buf* buf);
|
||||
static void matrix_free(struct term_buf* buf);
|
||||
|
||||
void draw_free(struct term_buf* buf)
|
||||
{
|
||||
if (config.animate)
|
||||
{
|
||||
free(buf->tmp_buf);
|
||||
switch (config.animation)
|
||||
{
|
||||
case 0:
|
||||
doom_free(buf);
|
||||
break;
|
||||
case 1:
|
||||
matrix_free(buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -481,18 +492,118 @@ static void doom_init(struct term_buf* buf)
|
|||
{
|
||||
buf->init_width = buf->width;
|
||||
buf->init_height = buf->height;
|
||||
buf->astate.doom = malloc(sizeof(struct doom_state));
|
||||
|
||||
uint16_t tmp_len = buf->width * buf->height;
|
||||
buf->tmp_buf = malloc(tmp_len);
|
||||
tmp_len -= buf->width;
|
||||
|
||||
if (buf->tmp_buf == NULL)
|
||||
if (buf->astate.doom == NULL)
|
||||
{
|
||||
dgn_throw(DGN_ALLOC);
|
||||
}
|
||||
|
||||
memset(buf->tmp_buf, 0, tmp_len);
|
||||
memset(buf->tmp_buf + tmp_len, DOOM_STEPS - 1, buf->width);
|
||||
uint16_t tmp_len = buf->width * buf->height;
|
||||
buf->astate.doom->buf = malloc(tmp_len);
|
||||
tmp_len -= buf->width;
|
||||
|
||||
if (buf->astate.doom->buf == NULL)
|
||||
{
|
||||
dgn_throw(DGN_ALLOC);
|
||||
}
|
||||
|
||||
memset(buf->astate.doom->buf, 0, tmp_len);
|
||||
memset(buf->astate.doom->buf + tmp_len, DOOM_STEPS - 1, buf->width);
|
||||
}
|
||||
|
||||
static void doom_free(struct term_buf* buf)
|
||||
{
|
||||
free(buf->astate.doom->buf);
|
||||
free(buf->astate.doom);
|
||||
}
|
||||
|
||||
// Adapted from cmatrix
|
||||
static void matrix_init(struct term_buf* buf)
|
||||
{
|
||||
buf->init_width = buf->width;
|
||||
buf->init_height = buf->height;
|
||||
buf->astate.matrix = malloc(sizeof(struct matrix_state));
|
||||
struct matrix_state* s = buf->astate.matrix;
|
||||
|
||||
if (s == NULL)
|
||||
{
|
||||
dgn_throw(DGN_ALLOC);
|
||||
}
|
||||
|
||||
uint16_t len = buf->height + 1;
|
||||
s->grid = malloc(sizeof(struct matrix_dot*) * len);
|
||||
|
||||
if (s->grid == NULL)
|
||||
{
|
||||
dgn_throw(DGN_ALLOC);
|
||||
}
|
||||
|
||||
len = (buf->height + 1) * buf->width;
|
||||
(s->grid)[0] = malloc(sizeof(struct matrix_dot) * len);
|
||||
|
||||
if ((s->grid)[0] == NULL)
|
||||
{
|
||||
dgn_throw(DGN_ALLOC);
|
||||
}
|
||||
|
||||
for (int i = 1; i <= buf->height; ++i)
|
||||
{
|
||||
s->grid[i] = s->grid[i - 1] + buf->width;
|
||||
|
||||
if (s->grid[i] == NULL)
|
||||
{
|
||||
dgn_throw(DGN_ALLOC);
|
||||
}
|
||||
}
|
||||
|
||||
s->length = malloc(buf->width * sizeof(int));
|
||||
|
||||
if (s->length == NULL)
|
||||
{
|
||||
dgn_throw(DGN_ALLOC);
|
||||
}
|
||||
|
||||
s->spaces = malloc(buf->width * sizeof(int));
|
||||
|
||||
if (s->spaces == NULL)
|
||||
{
|
||||
dgn_throw(DGN_ALLOC);
|
||||
}
|
||||
|
||||
s->updates = malloc(buf->width * sizeof(int));
|
||||
|
||||
if (s->updates == NULL)
|
||||
{
|
||||
dgn_throw(DGN_ALLOC);
|
||||
}
|
||||
|
||||
// Initialize grid
|
||||
for (int i = 0; i <= buf->height; ++i)
|
||||
{
|
||||
for (int j = 0; j <= buf->width - 1; j += 2)
|
||||
{
|
||||
s->grid[i][j].val = -1;
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < buf->width; j += 2)
|
||||
{
|
||||
s->spaces[j] = (int) rand() % buf->height + 1;
|
||||
s->length[j] = (int) rand() % (buf->height - 3) + 3;
|
||||
s->grid[1][j].val = ' ';
|
||||
s->updates[j] = (int) rand() % 3 + 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void matrix_free(struct term_buf* buf)
|
||||
{
|
||||
free(buf->astate.matrix->grid[0]);
|
||||
free(buf->astate.matrix->grid);
|
||||
free(buf->astate.matrix->length);
|
||||
free(buf->astate.matrix->spaces);
|
||||
free(buf->astate.matrix->updates);
|
||||
free(buf->astate.matrix);
|
||||
}
|
||||
|
||||
void animate_init(struct term_buf* buf)
|
||||
|
@ -501,11 +612,16 @@ void animate_init(struct term_buf* buf)
|
|||
{
|
||||
switch(config.animation)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
{
|
||||
doom_init(buf);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
matrix_init(buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -534,7 +650,7 @@ static void doom(struct term_buf* term_buf)
|
|||
uint16_t dst;
|
||||
|
||||
uint16_t w = term_buf->init_width;
|
||||
uint8_t* tmp = term_buf->tmp_buf;
|
||||
uint8_t* tmp = term_buf->astate.doom->buf;
|
||||
|
||||
if ((term_buf->width != term_buf->init_width) || (term_buf->height != term_buf->init_height))
|
||||
{
|
||||
|
@ -573,6 +689,130 @@ static void doom(struct term_buf* term_buf)
|
|||
}
|
||||
}
|
||||
|
||||
// Adapted from cmatrix
|
||||
static void matrix(struct term_buf* buf)
|
||||
{
|
||||
static int frame = 3;
|
||||
const int frame_delay = 8;
|
||||
static int count = 0;
|
||||
bool first_col;
|
||||
struct matrix_state* s = buf->astate.matrix;
|
||||
|
||||
// Allowed codepoints
|
||||
const int randmin = 33;
|
||||
const int randnum = 123 - randmin;
|
||||
// Chars change mid-scroll
|
||||
const bool changes = true;
|
||||
|
||||
if ((buf->width != buf->init_width) || (buf->height != buf->init_height))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
count += 1;
|
||||
if (count > frame_delay) {
|
||||
frame += 1;
|
||||
if (frame > 4) frame = 1;
|
||||
count = 0;
|
||||
|
||||
for (int j = 0; j < buf->width; j += 2)
|
||||
{
|
||||
int tail;
|
||||
if (frame > s->updates[j])
|
||||
{
|
||||
if (s->grid[0][j].val == -1 && s->grid[1][j].val == ' ')
|
||||
{
|
||||
if (s->spaces[j] > 0)
|
||||
{
|
||||
s->spaces[j]--;
|
||||
} else {
|
||||
s->length[j] = (int) rand() % (buf->height - 3) + 3;
|
||||
s->grid[0][j].val = (int) rand() % randnum + randmin;
|
||||
s->spaces[j] = (int) rand() % buf->height + 1;
|
||||
}
|
||||
}
|
||||
|
||||
int i = 0, seg_len = 0;
|
||||
first_col = 1;
|
||||
while (i <= buf->height)
|
||||
{
|
||||
// Skip over spaces
|
||||
while (i <= buf->height
|
||||
&& (s->grid[i][j].val == ' ' || s->grid[i][j].val == -1))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i > buf->height) break;
|
||||
|
||||
// Find the head of this col
|
||||
tail = i;
|
||||
seg_len = 0;
|
||||
while (i <= buf->height
|
||||
&& (s->grid[i][j].val != ' ' && s->grid[i][j].val != -1))
|
||||
{
|
||||
s->grid[i][j].is_head = false;
|
||||
if (changes)
|
||||
{
|
||||
if (rand() % 8 == 0)
|
||||
s->grid[i][j].val = (int) rand() % randnum + randmin;
|
||||
}
|
||||
i++;
|
||||
seg_len++;
|
||||
}
|
||||
|
||||
// Head's down offscreen
|
||||
if (i > buf->height)
|
||||
{
|
||||
s->grid[tail][j].val = ' ';
|
||||
continue;
|
||||
}
|
||||
|
||||
s->grid[i][j].val = (int) rand() % randnum + randmin;
|
||||
s->grid[i][j].is_head = true;
|
||||
|
||||
if (seg_len > s->length[j] || !first_col) {
|
||||
s->grid[tail][j].val = ' ';
|
||||
s->grid[0][j].val = -1;
|
||||
}
|
||||
first_col = 0;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
uint32_t c;
|
||||
int fg = TB_GREEN;
|
||||
int bg = TB_DEFAULT;
|
||||
|
||||
if (s->grid[i][j].val == -1 || s->grid[i][j].val == ' ')
|
||||
{
|
||||
tb_change_cell(j, i - 1, blank, fg, bg);
|
||||
continue;
|
||||
}
|
||||
|
||||
char tmp[2];
|
||||
tmp[0] = s->grid[i][j].val;
|
||||
tmp[1] = '\0';
|
||||
if(utf8_char_to_unicode(&c, tmp))
|
||||
{
|
||||
if (s->grid[i][j].is_head)
|
||||
{
|
||||
fg = TB_WHITE | TB_BOLD;
|
||||
}
|
||||
tb_change_cell(j, i - 1, c, fg, bg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void animate(struct term_buf* buf)
|
||||
{
|
||||
buf->width = tb_width();
|
||||
|
@ -582,11 +822,16 @@ void animate(struct term_buf* buf)
|
|||
{
|
||||
switch(config.animation)
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
{
|
||||
doom(buf);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
matrix(buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
27
src/draw.h
27
src/draw.h
|
@ -19,6 +19,31 @@ struct box
|
|||
uint32_t right;
|
||||
};
|
||||
|
||||
struct matrix_dot
|
||||
{
|
||||
int val;
|
||||
bool is_head;
|
||||
};
|
||||
|
||||
struct matrix_state
|
||||
{
|
||||
struct matrix_dot** grid;
|
||||
int* length;
|
||||
int* spaces;
|
||||
int* updates;
|
||||
};
|
||||
|
||||
struct doom_state
|
||||
{
|
||||
uint8_t* buf;
|
||||
};
|
||||
|
||||
union anim_state
|
||||
{
|
||||
struct doom_state* doom;
|
||||
struct matrix_state* matrix;
|
||||
};
|
||||
|
||||
struct term_buf
|
||||
{
|
||||
uint16_t width;
|
||||
|
@ -34,7 +59,7 @@ struct term_buf
|
|||
uint16_t box_width;
|
||||
uint16_t box_height;
|
||||
|
||||
uint8_t* tmp_buf;
|
||||
union anim_state astate;
|
||||
};
|
||||
|
||||
void draw_init(struct term_buf* buf);
|
||||
|
|
25
src/login.c
25
src/login.c
|
@ -242,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:
|
||||
|
@ -272,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,
|
||||
|
@ -478,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);
|
||||
|
@ -601,7 +608,7 @@ void auth(
|
|||
}
|
||||
|
||||
// add xdg variables
|
||||
env_xdg(tty_id, desktop->display_server[desktop->cur]);
|
||||
env_xdg(tty_id);
|
||||
|
||||
// execute
|
||||
int ok = chdir(pwd->pw_dir);
|
||||
|
|
25
src/main.c
25
src/main.c
|
@ -108,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] =
|
||||
{
|
||||
|
@ -141,11 +137,17 @@ int main(int argc, char** argv)
|
|||
struct term_buf buf;
|
||||
uint8_t active_input = config.default_input;
|
||||
|
||||
(*input_handles[active_input])(input_structs[active_input], NULL);
|
||||
|
||||
// init drawing stuff
|
||||
draw_init(&buf);
|
||||
|
||||
// draw_box and position_input are called because they need to be
|
||||
// called before *input_handles[active_input] for the cursor to be
|
||||
// positioned correctly
|
||||
draw_box(&buf);
|
||||
position_input(&buf, &desktop, &login, &password);
|
||||
(*input_handles[active_input])(input_structs[active_input], NULL);
|
||||
|
||||
if (config.animate)
|
||||
{
|
||||
animate_init(&buf);
|
||||
|
@ -174,11 +176,13 @@ int main(int argc, char** argv)
|
|||
{
|
||||
if (auth_fails < 10)
|
||||
{
|
||||
(*input_handles[active_input])(input_structs[active_input], NULL);
|
||||
tb_clear();
|
||||
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);
|
||||
|
@ -195,7 +199,11 @@ int main(int argc, char** argv)
|
|||
tb_present();
|
||||
}
|
||||
|
||||
error = tb_peek_event(&event, config.min_refresh_delta);
|
||||
if (config.animate) {
|
||||
error = tb_peek_event(&event, config.min_refresh_delta);
|
||||
} else {
|
||||
error = tb_poll_event(&event);
|
||||
}
|
||||
|
||||
if (error < 0)
|
||||
{
|
||||
|
@ -221,6 +229,7 @@ int main(int argc, char** argv)
|
|||
if (active_input > 0)
|
||||
{
|
||||
input_text_clear(input_structs[active_input]);
|
||||
update = true;
|
||||
}
|
||||
break;
|
||||
case TB_KEY_ARROW_UP:
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 76d1e23b5e7b84b82c291a3120d9e57bb2d50424
|
||||
Subproject commit e1844c4c94b70bb351ec2bd2ac6bb320ee793d8f
|
|
@ -1 +1 @@
|
|||
Subproject commit 0a2492c6aab3ff64e182db894ce4d40b26799fbd
|
||||
Subproject commit 15bd3299bf3e49bd6734bff385cb0392cd2fa502
|
|
@ -1 +1 @@
|
|||
Subproject commit 23fff64470b0730959b39c70aa31fbddd776d9bc
|
||||
Subproject commit d961a8122210010e7c2c8f201e61170c13d319b4
|
Loading…
Reference in New Issue