diff --git a/readme.md b/readme.md index f598d72..94b3b33 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,4 @@ + # Ly - a TUI display manager ![Ly screenshot](https://user-images.githubusercontent.com/5473047/88958888-65efbf80-d2a1-11ea-8ae5-3f263bce9cce.png "Ly screenshot") @@ -34,9 +35,11 @@ The following desktop environments were tested with success - qtile - sway - xfce + - xmonad - pantheon - maxx - windowmaker + - spectrwm Ly should work with any X desktop environment, and provides basic wayland support (sway works very well, for example). @@ -50,7 +53,12 @@ changing the source code won't be necessary :) ## Cloning and Compiling Clone the repository ``` -git clone --recurse-submodules https://github.com/nullgemm/ly.git +git clone --recurse-submodules https://github.com/nullgemm/ly +``` + +Change the directory to ly +``` +cd ly ``` Compile @@ -99,6 +107,12 @@ If you choose a tty that already has a login/getty running you have to disable t sudo rc-update del agetty.tty1 ``` +## Arch Linux Installation +From AUR: +``` +yay -S ly +``` + ## Configuration You can find all the configuration in `/etc/ly/config.ini`. The file is commented, and includes the default values. diff --git a/res/config.ini b/res/config.ini index 72b333b..2e9e6e8 100644 --- a/res/config.ini +++ b/res/config.ini @@ -100,6 +100,9 @@ # xorg server command #x_cmd = /usr/bin/X +# xinitrc +#xinitrc = ~/.xinitrc + # xorg setup command #x_cmd_setup = /etc/ly/xsetup.sh diff --git a/res/lang/en.ini b/res/lang/en.ini index 134c637..ecdc9ca 100644 --- a/res/lang/en.ini +++ b/res/lang/en.ini @@ -36,10 +36,10 @@ err_xsessions_dir = failed to find sessions folder err_xsessions_open = failed to open sessions folder f1 = F1 shutdown f2 = F2 reboot -login = login: +login = login logout = logged out numlock = numlock -password = password: +password = password shell = shell wayland = wayland xinitrc = xinitrc diff --git a/res/lang/es.ini b/res/lang/es.ini index 7323b6e..258c89d 100644 --- a/res/lang/es.ini +++ b/res/lang/es.ini @@ -36,10 +36,10 @@ err_xsessions_dir = error al buscar la carpeta de sesiones err_xsessions_open = error al abrir la carpeta de sesiones f1 = F1 apagar f2 = F2 reiniciar -login = iniciar sesion: +login = iniciar sesion logout = cerrar sesion numlock = Bloq Num -password = contraseña: +password = contraseña shell = shell wayland = wayland xinitrc = xinitrc diff --git a/res/lang/fr.ini b/res/lang/fr.ini index f7a5cb1..7efa430 100644 --- a/res/lang/fr.ini +++ b/res/lang/fr.ini @@ -36,10 +36,10 @@ err_xsessions_dir = échec de la recherche du dossier de sessions err_xsessions_open = échec de l'ouverture du dossier de sessions f1 = F1 éteindre f2 = F2 redémarrer -login = identifiant : +login = identifiant logout = déconnection numlock = verr.num -password = mot de passe : +password = mot de passe shell = shell wayland = wayland xinitrc = xinitrc diff --git a/res/lang/it.ini b/res/lang/it.ini index beb3531..637bd64 100644 --- a/res/lang/it.ini +++ b/res/lang/it.ini @@ -36,10 +36,10 @@ err_xsessions_dir = impossibile localizzare cartella sessioni err_xsessions_open = impossibile aprire cartella sessioni f1 = F1 arresto f2 = F2 riavvio -login = username: +login = username logout = scollegato numlock = numlock -password = password: +password = password shell = shell wayland = wayland xinitrc = xinitrc diff --git a/res/lang/pl.ini b/res/lang/pl.ini index 6fbebef..1804669 100644 --- a/res/lang/pl.ini +++ b/res/lang/pl.ini @@ -36,10 +36,10 @@ 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: +login = login logout = wylogowano numlock = numlock -password = hasło: +password = hasło shell = powłoka wayland = wayland xinitrc = xinitrc diff --git a/res/lang/pt.ini b/res/lang/pt.ini index f25b33f..0213046 100644 --- a/res/lang/pt.ini +++ b/res/lang/pt.ini @@ -36,10 +36,10 @@ err_xsessions_dir = não foi possível encontrar a pasta das sessões err_xsessions_open = não foi possível abrir a pasta das sessões f1 = F1 desligar f2 = F2 reiniciar -login = conectar: +login = conectar logout = desconectado numlock = numlock -password = senha: +password = senha shell = shell wayland = wayland xinitrc = xinitrc diff --git a/res/lang/ro.ini b/res/lang/ro.ini index 18c11a6..578f924 100644 --- a/res/lang/ro.ini +++ b/res/lang/ro.ini @@ -36,10 +36,10 @@ err_perm_user = nu s-a putut face downgrade permisiunilor de utilizator f1 = F1 opreşte sistemul f2 = F2 resetează -login = utilizator: +login = utilizator logout = opreşte sesiunea numlock = numlock -password = parolă: +password = parolă shell = shell wayland = wayland xinitrc = xinitrc diff --git a/res/lang/ru.ini b/res/lang/ru.ini index 6a42bd7..657214b 100644 --- a/res/lang/ru.ini +++ b/res/lang/ru.ini @@ -36,10 +36,10 @@ err_xsessions_dir = не удалось найти сессионную папк err_xsessions_open = не удалось открыть сессионную папку f1 = F1 выключить f2 = F2 перезагрузить -login = логин: +login = логин logout = logged out numlock = numlock -password = пароль: +password = пароль shell = shell wayland = wayland xinitrc = xinitrc diff --git a/res/lang/sr.ini b/res/lang/sr.ini index 58c3257..04bd679 100644 --- a/res/lang/sr.ini +++ b/res/lang/sr.ini @@ -36,10 +36,10 @@ err_xsessions_dir = neuspijesno pronalazenje foldera sesija err_xsessions_open = neuspijesno otvaranje foldera sesija f1 = F1 ugasi f2 = F2 ponovo pokreni -login = korisnik: +login = korisnik logout = izlogovan numlock = numlock -password = lozinka: +password = lozinka shell = shell wayland = wayland xinitrc = xinitrc diff --git a/src/config.c b/src/config.c index 0881bfc..bf7f20e 100644 --- a/src/config.c +++ b/src/config.c @@ -190,6 +190,7 @@ void config_load(const char *cfg_path) {"wayland_specifier", &config.wayland_specifier, config_handle_bool}, {"waylandsessions", &config.waylandsessions, config_handle_str}, {"x_cmd", &config.x_cmd, config_handle_str}, + {"xinitrc", &config.xinitrc, config_handle_str}, {"x_cmd_setup", &config.x_cmd_setup, config_handle_str}, {"xauth_cmd", &config.xauth_cmd, config_handle_str}, {"xsessions", &config.xsessions, config_handle_str}, @@ -296,6 +297,7 @@ void config_defaults() config.wayland_specifier = false; config.waylandsessions = strdup("/usr/share/wayland-sessions"); config.x_cmd = strdup("/usr/bin/X"); + config.xinitrc = strdup("~/.xinitrc"); config.x_cmd_setup = strdup(DATADIR "/xsetup.sh"); config.xauth_cmd = strdup("/usr/bin/xauth"); config.xsessions = strdup("/usr/share/xsessions"); @@ -364,6 +366,7 @@ void config_free() free(config.wayland_cmd); free(config.waylandsessions); free(config.x_cmd); + free(config.xinitrc); free(config.x_cmd_setup); free(config.xauth_cmd); free(config.xsessions); diff --git a/src/config.h b/src/config.h index 7d426af..67985bb 100644 --- a/src/config.h +++ b/src/config.h @@ -94,6 +94,7 @@ struct config bool wayland_specifier; char* waylandsessions; char* x_cmd; + char* xinitrc; char* x_cmd_setup; char* xauth_cmd; char* xsessions; diff --git a/src/draw.c b/src/draw.c index 9d16a81..81de187 100644 --- a/src/draw.c +++ b/src/draw.c @@ -129,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 (uint8_t i = 0; i < buf->box_width; ++i) + for (uint16_t i = 0; i < buf->box_width; ++i) { tb_put_cell( box_x + i, @@ -145,7 +145,7 @@ void draw_box(struct term_buf* buf) c1.ch = buf->box_chars.left; c2.ch = buf->box_chars.right; - for (uint8_t i = 0; i < buf->box_height; ++i) + for (uint16_t i = 0; i < buf->box_height; ++i) { tb_put_cell( box_x - 1, @@ -163,9 +163,9 @@ void draw_box(struct term_buf* buf) { struct tb_cell blank = {' ', config.fg, config.bg}; - for (uint8_t i = 0; i < buf->box_height; ++i) + for (uint16_t i = 0; i < buf->box_height; ++i) { - for (uint8_t k = 0; k < buf->box_width; ++k) + for (uint16_t k = 0; k < buf->box_width; ++k) { tb_put_cell( box_x + k, diff --git a/src/inputs.c b/src/inputs.c index d425c06..69a7e9b 100644 --- a/src/inputs.c +++ b/src/inputs.c @@ -82,7 +82,7 @@ void input_desktop(struct desktop* target) target->len = 0; input_desktop_add(target, strdup(lang.shell), strdup(""), DS_SHELL); - input_desktop_add(target, strdup(lang.xinitrc), strdup("~/.xinitrc"), DS_XINITRC); + input_desktop_add(target, strdup(lang.xinitrc), strdup(config.xinitrc), DS_XINITRC); #if 0 input_desktop_add(target, strdup(lang.wayland), strdup(""), DS_WAYLAND); #endif diff --git a/src/login.c b/src/login.c index 32b8e82..e704022 100644 --- a/src/login.c +++ b/src/login.c @@ -300,10 +300,31 @@ void remove_utmp_entry(struct utmp *entry) { endutent(); } -void xauth(const char* display_name, const char* shell, const char* dir) +void xauth(const char* display_name, const char* shell, char* pwd) { + const char* xauth_file = ".lyxauth"; + char* xauth_dir = getenv("XDG_RUNTIME_DIR"); + if ((xauth_dir == NULL) || (*xauth_dir == '\0')) + { + xauth_dir = getenv("XDG_CONFIG_DIR"); + if ((xauth_dir == NULL) || (*xauth_dir == '\0')) + { + xauth_dir = pwd; + xauth_file = "lyxauth"; + } + } + else + { + xauth_file = "lyxauth"; + } + + // trim trailing slashes + int i = strlen(xauth_dir) - 1; + while (xauth_dir[i] == '/') i--; + xauth_dir[i + 1] = '\0'; + char xauthority[256]; - snprintf(xauthority, 256, "%s/%s", dir, ".lyxauth"); + snprintf(xauthority, 256, "%s/%s", xauth_dir, xauth_file); setenv("XAUTHORITY", xauthority, 1); setenv("DISPLAY", display_name, 1); @@ -339,18 +360,10 @@ void xorg( const char* vt, const char* desktop_cmd) { - // generate xauthority file - const char* xauth_dir = getenv("XDG_CONFIG_HOME"); - - if ((xauth_dir == NULL) || (*xauth_dir == '\0')) - { - xauth_dir = pwd->pw_dir; - } - char display_name[4]; snprintf(display_name, 3, ":%d", get_free_display()); - xauth(display_name, pwd->pw_shell, xauth_dir); + xauth(display_name, pwd->pw_shell, pwd->pw_dir); // start xorg pid_t pid = fork(); @@ -530,7 +543,7 @@ void auth( if (pwd->pw_shell[0] == '\0') { setusershell(); - + char* shell = getusershell(); if (shell != NULL) @@ -551,7 +564,7 @@ void auth( if (pid == 0) { - // set user info + // set user info ok = initgroups(pwd->pw_name, pwd->pw_gid); if (ok != 0) @@ -657,21 +670,21 @@ void auth( // close pam session ok = pam_do(pam_close_session, handle, 0, buf); - + if (ok != PAM_SUCCESS) { return; } ok = pam_do(pam_setcred, handle, PAM_DELETE_CRED, buf); - + if (ok != PAM_SUCCESS) { return; } ok = pam_end(handle, 0); - + if (ok != PAM_SUCCESS) { pam_diagnose(ok, buf); diff --git a/src/main.c b/src/main.c index f0c3ae6..8aea32f 100644 --- a/src/main.c +++ b/src/main.c @@ -28,7 +28,7 @@ struct config config; // args handles void arg_help(void* data, char** pars, const int pars_count) { - printf("RTFM\n"); + printf("If you want to configure Ly, please check the config file, usually located at /etc/ly/config.ini.\n"); } void arg_version(void* data, char** pars, const int pars_count)