diff --git a/.gitea b/.gitea deleted file mode 100644 index 4ff1145..0000000 --- a/.gitea +++ /dev/null @@ -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 diff --git a/.gitignore b/.gitignore index 836a4d8..65ddc50 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ bin obj -.gitmodules valgrind.log diff --git a/.github b/.gitmodules similarity index 81% rename from .github rename to .gitmodules index 5522bb6..250adbe 100644 --- a/.github +++ b/.gitmodules @@ -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 diff --git a/makefile b/makefile index eef31ad..f8cc6ed 100644 --- a/makefile +++ b/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 diff --git a/readme.md b/readme.md index c7a0736..74e54bb 100644 --- a/readme.md +++ b/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 @@ -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 diff --git a/res/config.ini b/res/config.ini index 8e001e5..72b333b 100644 --- a/res/config.ini +++ b/res/config.ini @@ -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 diff --git a/res/lang/it.ini b/res/lang/it.ini new file mode 100644 index 0000000..beb3531 --- /dev/null +++ b/res/lang/it.ini @@ -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 diff --git a/res/lang/pl.ini b/res/lang/pl.ini new file mode 100644 index 0000000..6fbebef --- /dev/null +++ b/res/lang/pl.ini @@ -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 diff --git a/res/lang/ru.ini b/res/lang/ru.ini index a1802f5..6a42bd7 100644 --- a/res/lang/ru.ini +++ b/res/lang/ru.ini @@ -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 = неизвестный пользователь diff --git a/res/lang/sr.ini b/res/lang/sr.ini new file mode 100644 index 0000000..58c3257 --- /dev/null +++ b/res/lang/sr.ini @@ -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 diff --git a/src/config.c b/src/config.c index 51e36c3..640aa97 100644 --- a/src/config.c +++ b/src/config.c @@ -2,7 +2,9 @@ #include "config.h" +#include #include +#include #include #include #include @@ -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}, diff --git a/src/config.h b/src/config.h index fa0b67b..7d426af 100644 --- a/src/config.h +++ b/src/config.h @@ -1,7 +1,8 @@ #ifndef H_LY_CONFIG #define H_LY_CONFIG -#include "ctypes.h" +#include +#include 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; diff --git a/src/draw.c b/src/draw.c index 0cdf299..f515705 100644 --- a/src/draw.c +++ b/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 #include +#include +#include #include #include #include @@ -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; diff --git a/src/draw.h b/src/draw.h index e6d02f5..ce4cf60 100644 --- a/src/draw.h +++ b/src/draw.h @@ -2,20 +2,21 @@ #define H_LY_DRAW #include "termbox.h" -#include "ctypes.h" - #include "inputs.h" +#include +#include + 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 diff --git a/src/inputs.c b/src/inputs.c index 4984f47..d425c06 100644 --- a/src/inputs.c +++ b/src/inputs.c @@ -1,10 +1,9 @@ #include "dragonfail.h" #include "termbox.h" -#include "ctypes.h" - #include "inputs.h" #include "config.h" +#include #include #include #include @@ -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) { diff --git a/src/inputs.h b/src/inputs.h index a49dde5..6ba1448 100644 --- a/src/inputs.h +++ b/src/inputs.h @@ -2,7 +2,8 @@ #define H_LY_INPUTS #include "termbox.h" -#include "ctypes.h" + +#include 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); diff --git a/src/login.c b/src/login.c index 57219ae..9dee06b 100644 --- a/src/login.c +++ b/src/login.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -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); diff --git a/src/main.c b/src/main.c index 254026c..ec19aad 100644 --- a/src/main.c +++ b/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 +#include +#include #include +#include #include #include #include @@ -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); diff --git a/src/utils.c b/src/utils.c index be98bda..b7bfabc 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,12 +1,12 @@ #include "configator.h" #include "dragonfail.h" - #include "inputs.h" #include "config.h" #include "utils.h" #include #include +#include #include #include #include diff --git a/sub/argoat b/sub/argoat index 76d1e23..e1844c4 160000 --- a/sub/argoat +++ b/sub/argoat @@ -1 +1 @@ -Subproject commit 76d1e23b5e7b84b82c291a3120d9e57bb2d50424 +Subproject commit e1844c4c94b70bb351ec2bd2ac6bb320ee793d8f diff --git a/sub/ctypes b/sub/ctypes deleted file mode 160000 index eb4b365..0000000 --- a/sub/ctypes +++ /dev/null @@ -1 +0,0 @@ -Subproject commit eb4b36559de8d17015f9416861ed085d06f5f5ed diff --git a/sub/dragonfail b/sub/dragonfail index 0a2492c..15bd329 160000 --- a/sub/dragonfail +++ b/sub/dragonfail @@ -1 +1 @@ -Subproject commit 0a2492c6aab3ff64e182db894ce4d40b26799fbd +Subproject commit 15bd3299bf3e49bd6734bff385cb0392cd2fa502 diff --git a/sub/termbox_next b/sub/termbox_next index 23fff64..d961a81 160000 --- a/sub/termbox_next +++ b/sub/termbox_next @@ -1 +1 @@ -Subproject commit 23fff64470b0730959b39c70aa31fbddd776d9bc +Subproject commit d961a8122210010e7c2c8f201e61170c13d319b4