Add option to change shutdown/reboot keys (#487)

Include options in the configuration to change which function keys to use for shutdown and reboot.
Fix config.map_len size in src/config.c.
Add missing defaults in config_defaults() in src/config.c.
pull/522/head
lolicon0930 11 months ago committed by GitHub
parent 0edb0012ab
commit 42bf929756
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -16,7 +16,7 @@ Ly is a lightweight TUI (ncurses-like) display manager for Linux and BSD.
- tput - tput
- shutdown - shutdown
On Debian-based distros running `apt install build-essential libpam0g-dev libxcb-xkb-dev` as root should install all the dependencies for you. On Debian-based distros running `apt install build-essential libpam0g-dev libxcb-xkb-dev` as root should install all the dependencies for you.
For Fedora try running `dnf install make automake gcc gcc-c++ kernel-devel pam-devel libxcb-devel` For Fedora try running `dnf install make automake gcc gcc-c++ kernel-devel pam-devel libxcb-devel`
## Support ## Support
@ -27,7 +27,7 @@ The following desktop environments were tested with success
- budgie - budgie
- cinnamon - cinnamon
- deepin - deepin
- dwm - dwm
- enlightenment - enlightenment
- gnome - gnome
- i3 - i3
@ -36,12 +36,12 @@ The following desktop environments were tested with success
- lxde - lxde
- lxqt - lxqt
- mate - mate
- maxx - maxx
- pantheon - pantheon
- qtile - qtile
- spectrwm - spectrwm
- sway - sway
- windowmaker - windowmaker
- xfce - xfce
- xmonad - xmonad
@ -121,7 +121,7 @@ $ make
# ln -s /etc/sv/ly /var/service/ # ln -s /etc/sv/ly /var/service/
``` ```
By default, ly will run on tty2. To change the tty it must be set in `/etc/ly/config.ini` By default, ly will run on tty2. To change the tty it must be set in `/etc/ly/config.ini`
You should as well disable your existing display manager service if needed, e.g.: You should as well disable your existing display manager service if needed, e.g.:

@ -3,7 +3,7 @@
# The active animation # The active animation
# 0 -> PSX DOOM fire (default) # 0 -> PSX DOOM fire (default)
# 1 -> CMatrix # 1 -> CMatrix
#animation = 0 #animation = 0
# format string for clock in top right corner (see strftime specification) # format string for clock in top right corner (see strftime specification)
@ -29,12 +29,12 @@
#define TB_CYAN 0x07 #define TB_CYAN 0x07
#define TB_WHITE 0x08 #define TB_WHITE 0x08
# #
# Setting both to zero makes `bg` black and `fg` white. To set the actual color palette you are encouraged to use another tool # Setting both to zero makes `bg` black and `fg` white. To set the actual color palette you are encouraged to use another tool
# such as [mkinitcpio-colors](https://github.com/evanpurkhiser/mkinitcpio-colors). Note that the color palette defined with # such as [mkinitcpio-colors](https://github.com/evanpurkhiser/mkinitcpio-colors). Note that the color palette defined with
# `mkinitcpio-colors` takes 16 colors (0-15), only values 0-8 are valid for `ly` config and these values do not correspond # `mkinitcpio-colors` takes 16 colors (0-15), only values 0-8 are valid for `ly` config and these values do not correspond
# exactly. For instance, in defining palettes with `mkinitcpio-colors` the order is black, dark red, dark green, brown, dark # exactly. For instance, in defining palettes with `mkinitcpio-colors` the order is black, dark red, dark green, brown, dark
# blue, dark purple, dark cyan, light gray, dark gray, bright red, bright green, yellow, bright blue, bright purple, bright # blue, dark purple, dark cyan, light gray, dark gray, bright red, bright green, yellow, bright blue, bright purple, bright
# cyan, and white, indexed in that order 0 through 15. For example, the color defined for white (indexed at 15 in the mkinitcpio # cyan, and white, indexed in that order 0 through 15. For example, the color defined for white (indexed at 15 in the mkinitcpio
# config) will be used by `ly` for `fg = 8`. # config) will be used by `ly` for `fg = 8`.
# Background color id # Background color id
@ -76,13 +76,19 @@
#save_file = /etc/ly/save #save_file = /etc/ly/save
# Remove F1/F2 command hints # Remove power management command hints
#hide_f1_commands = false #hide_key_hints = false
# Command executed when pressing F1 # Specifies the key used for shutdown
#shutdown_key = F1
# Specifies the key used for restart
#restart_key = F2
# Command executed when pressing shutdown_key
#shutdown_cmd = /sbin/shutdown -a now #shutdown_cmd = /sbin/shutdown -a now
# Command executed when pressing F2 # Command executed when pressing restart_key
#restart_cmd = /sbin/shutdown -r now #restart_cmd = /sbin/shutdown -r now

@ -1,5 +1,5 @@
capslock = Bloq Majús capslock = Bloq Majús
err_alloc = falla d'assignació de memòria err_alloc = falla d'assignació de memòria
err_bounds = índex fora de límit err_bounds = índex fora de límit
err_chdir = error al obrir carpeta home err_chdir = error al obrir carpeta home
err_console_dev = error al accedir a la consola err_console_dev = error al accedir a la consola
@ -34,12 +34,12 @@ err_user_init = error al inicialitzar usuari
err_user_uid = error al establir el UID de l'usuari err_user_uid = error al establir el UID de l'usuari
err_xsessions_dir = error al cercar la carpeta de sessions err_xsessions_dir = error al cercar la carpeta de sessions
err_xsessions_open = error al obrir la carpeta de sessions err_xsessions_open = error al obrir la carpeta de sessions
f1 = F1 aturar
f2 = F2 reiniciar
login = iniciar sessió login = iniciar sessió
logout = tancar sessió logout = tancar sessió
numlock = Bloq Num numlock = Bloq Num
password = Clau password = Clau
restart = reiniciar
shell = shell shell = shell
shutdown = aturar
wayland = wayland wayland = wayland
xinitrc = xinitrc xinitrc = xinitrc

@ -34,12 +34,12 @@ err_user_init = inicializace uživatele selhala
err_user_uid = nastavení UID uživateli selhalo err_user_uid = nastavení UID uživateli selhalo
err_xsessions_dir = nepodařilo se najít složku relací err_xsessions_dir = nepodařilo se najít složku relací
err_xsessions_open = nepodařilo se otevřít složku relací err_xsessions_open = nepodařilo se otevřít složku relací
f1 = F1 vypnout
f2 = F2 restartovat
login = uživatel login = uživatel
logout = odhlášen logout = odhlášen
numlock = numlock numlock = numlock
password = heslo password = heslo
restart = restartovat
shell = příkazový řádek shell = příkazový řádek
shutdown = vypnout
wayland = wayland wayland = wayland
xinitrc = xinitrc xinitrc = xinitrc

@ -34,12 +34,12 @@ err_user_init = Initialisierung des Nutzers fehlgeschlagen
err_user_uid = Setzen der Benutzer Id fehlgeschlagen err_user_uid = Setzen der Benutzer Id fehlgeschlagen
err_xsessions_dir = Fehler beim finden des Sitzungsordners err_xsessions_dir = Fehler beim finden des Sitzungsordners
err_xsessions_open = Fehler beim öffnen des Sitzungsordners err_xsessions_open = Fehler beim öffnen des Sitzungsordners
f1 = F1 Herunterfahren
f2 = F2 Neustarten
login = Anmelden login = Anmelden
logout = Abgemeldet logout = Abgemeldet
numlock = Numtaste numlock = Numtaste
password = Passwort password = Passwort
restart = Neustarten
shell = shell shell = shell
shutdown = Herunterfahren
wayland = wayland wayland = wayland
xinitrc = xinitrc xinitrc = xinitrc

@ -34,12 +34,12 @@ err_user_init = failed to initialize user
err_user_uid = failed to set user UID err_user_uid = failed to set user UID
err_xsessions_dir = failed to find sessions folder err_xsessions_dir = failed to find sessions folder
err_xsessions_open = failed to open sessions folder err_xsessions_open = failed to open sessions folder
f1 = F1 shutdown
f2 = F2 reboot
login = login login = login
logout = logged out logout = logged out
numlock = numlock numlock = numlock
password = password password = password
restart = reboot
shell = shell shell = shell
shutdown = shutdown
wayland = wayland wayland = wayland
xinitrc = xinitrc xinitrc = xinitrc

@ -34,12 +34,12 @@ err_user_init = error al inicializar usuario
err_user_uid = error al establecer el UID del usuario err_user_uid = error al establecer el UID del usuario
err_xsessions_dir = error al buscar la carpeta de sesiones err_xsessions_dir = error al buscar la carpeta de sesiones
err_xsessions_open = error al abrir la carpeta de sesiones err_xsessions_open = error al abrir la carpeta de sesiones
f1 = F1 apagar
f2 = F2 reiniciar
login = iniciar sesión login = iniciar sesión
logout = cerrar sesión logout = cerrar sesión
numlock = Bloq Num numlock = Bloq Num
password = contraseña password = contraseña
restart = reiniciar
shell = shell shell = shell
shutdown = apagar
wayland = wayland wayland = wayland
xinitrc = xinitrc xinitrc = xinitrc

@ -20,7 +20,7 @@ err_pam_cred_expired = identifiants expirés
err_pam_cred_insufficient = identifiants insuffisants err_pam_cred_insufficient = identifiants insuffisants
err_pam_cred_unavail = échec de l'obtention des identifiants err_pam_cred_unavail = échec de l'obtention des identifiants
err_pam_maxtries = limite d'essais atteinte err_pam_maxtries = limite d'essais atteinte
err_pam_perm_denied = permission refusée err_pam_perm_denied = permission refusée
err_pam_session = erreur de session err_pam_session = erreur de session
err_pam_sys = erreur système err_pam_sys = erreur système
err_pam_user_unknown = utilisateur inconnu err_pam_user_unknown = utilisateur inconnu
@ -34,12 +34,12 @@ err_user_init = échec d'initialisation de l'utilisateur
err_user_uid = échec de modification du UID err_user_uid = échec de modification du UID
err_xsessions_dir = échec de la recherche du dossier de sessions err_xsessions_dir = échec de la recherche du dossier de sessions
err_xsessions_open = échec de l'ouverture 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 logout = déconnection
numlock = verr.num numlock = verr.num
password = mot de passe password = mot de passe
restart = redémarrer
shell = shell shell = shell
shutdown = éteindre
wayland = wayland wayland = wayland
xinitrc = xinitrc xinitrc = xinitrc

@ -34,12 +34,12 @@ err_user_init = impossibile inizializzare utente
err_user_uid = impossible impostare UID utente err_user_uid = impossible impostare UID utente
err_xsessions_dir = impossibile localizzare cartella sessioni err_xsessions_dir = impossibile localizzare cartella sessioni
err_xsessions_open = impossibile aprire cartella sessioni err_xsessions_open = impossibile aprire cartella sessioni
f1 = F1 arresto
f2 = F2 riavvio
login = username login = username
logout = scollegato logout = scollegato
numlock = numlock numlock = numlock
password = password password = password
restart = riavvio
shell = shell shell = shell
shutdown = arresto
wayland = wayland wayland = wayland
xinitrc = xinitrc xinitrc = xinitrc

@ -34,12 +34,12 @@ err_user_init = nie udało się zainicjalizować użytkownika
err_user_uid = nie udało się ustawić UID 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_dir = nie udało się znaleźć folderu sesji
err_xsessions_open = nie udało się otworzyć 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 logout = wylogowano
numlock = numlock numlock = numlock
password = hasło password = hasło
restart = uruchom ponownie
shell = powłoka shell = powłoka
shutdown = wyłącz
wayland = wayland wayland = wayland
xinitrc = xinitrc xinitrc = xinitrc

@ -34,12 +34,12 @@ err_user_init = erro ao iniciar o utilizador
err_user_uid = erro ao definir o UID do utilizador err_user_uid = erro ao definir o UID do utilizador
err_xsessions_dir = erro ao localizar a pasta das sessões err_xsessions_dir = erro ao localizar a pasta das sessões
err_xsessions_open = erro ao abrir a pasta das sessões err_xsessions_open = erro ao abrir a pasta das sessões
f1 = F1 encerrar
f2 = F2 reiniciar
login = iniciar sessão login = iniciar sessão
logout = terminar sessão logout = terminar sessão
numlock = numlock numlock = numlock
password = palavra-passe password = palavra-passe
restart = reiniciar
shell = shell shell = shell
shutdown = encerrar
wayland = wayland wayland = wayland
xinitrc = xinitrc xinitrc = xinitrc

@ -34,12 +34,12 @@ err_user_init = não foi possível iniciar o usuário
err_user_uid = não foi possível definir o UID do usuário err_user_uid = não foi possível definir o UID do usuário
err_xsessions_dir = não foi possível encontrar a pasta das sessões 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 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 logout = desconectado
numlock = numlock numlock = numlock
password = senha password = senha
restart = reiniciar
shell = shell shell = shell
shutdown = desligar
wayland = wayland wayland = wayland
xinitrc = xinitrc xinitrc = xinitrc

@ -34,12 +34,12 @@ 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 logout = opreşte sesiunea
numlock = numlock numlock = numlock
password = parolă password = parolă
restart = resetează
shell = shell shell = shell
shutdown = opreşte sistemul
wayland = wayland wayland = wayland
xinitrc = xinitrc xinitrc = xinitrc

@ -34,12 +34,12 @@ err_user_init = не удалось инициализировать польз
err_user_uid = не удалось установить UID пользователя err_user_uid = не удалось установить UID пользователя
err_xsessions_dir = не удалось найти сессионную папку err_xsessions_dir = не удалось найти сессионную папку
err_xsessions_open = не удалось открыть сессионную папку err_xsessions_open = не удалось открыть сессионную папку
f1 = F1 выключить
f2 = F2 перезагрузить
login = логин login = логин
logout = logged out logout = logged out
numlock = numlock numlock = numlock
password = пароль password = пароль
restart = перезагрузить
shell = shell shell = shell
shutdown = выключить
wayland = wayland wayland = wayland
xinitrc = xinitrc xinitrc = xinitrc

@ -25,7 +25,7 @@ err_pam_session = greska sesije
err_pam_sys = greska sistema err_pam_sys = greska sistema
err_pam_user_unknown = nepoznat korisnik err_pam_user_unknown = nepoznat korisnik
err_path = neuspjelo postavljanje path-a err_path = neuspjelo postavljanje path-a
err_perm_dir = neuspjelo mijenjanje foldera err_perm_dir = neuspjelo mijenjanje foldera
err_perm_group = neuspjesno snizavanje dozvola grupe err_perm_group = neuspjesno snizavanje dozvola grupe
err_perm_user = neuspijesno snizavanje dozvola korisnika err_perm_user = neuspijesno snizavanje dozvola korisnika
err_pwnam = neuspijesno skupljanje informacija o korisniku err_pwnam = neuspijesno skupljanje informacija o korisniku
@ -33,13 +33,13 @@ err_user_gid = neuspijesno postavljanje korisničkog GID-a
err_user_init = neuspijensa inicijalizacija korisnika err_user_init = neuspijensa inicijalizacija korisnika
err_user_uid = neuspijesno postavljanje UID-a korisnika err_user_uid = neuspijesno postavljanje UID-a korisnika
err_xsessions_dir = neuspijesno pronalazenje foldera sesija err_xsessions_dir = neuspijesno pronalazenje foldera sesija
err_xsessions_open = neuspijesno otvaranje foldera sesija err_xsessions_open = neuspijesno otvaranje foldera sesija
f1 = F1 ugasi
f2 = F2 ponovo pokreni
login = korisnik login = korisnik
logout = izlogovan logout = izlogovan
numlock = numlock numlock = numlock
password = lozinka password = lozinka
restart = ponovo pokreni
shell = shell shell = shell
shutdown = ugasi
wayland = wayland wayland = wayland
xinitrc = xinitrc xinitrc = xinitrc

@ -6,7 +6,7 @@ err_console_dev = misslyckades att komma åt konsol
err_dgn_oob = loggmeddelande err_dgn_oob = loggmeddelande
err_domain = okänd domän err_domain = okänd domän
err_hostname = misslyckades att hämta värdnamn err_hostname = misslyckades att hämta värdnamn
err_mlock = misslyckades att låsa lösenordsminne err_mlock = misslyckades att låsa lösenordsminne
err_null = nullpekare err_null = nullpekare
err_pam = pam-transaktion misslyckades err_pam = pam-transaktion misslyckades
err_pam_abort = pam-transaktion avbröts err_pam_abort = pam-transaktion avbröts
@ -34,12 +34,12 @@ err_user_init = misslyckades att initialisera användaren
err_user_uid = misslyckades att ställa in användar-UID err_user_uid = misslyckades att ställa in användar-UID
err_xsessions_dir = misslyckades att hitta sessionskatalog err_xsessions_dir = misslyckades att hitta sessionskatalog
err_xsessions_open = misslyckades att öppna sessionskatalog err_xsessions_open = misslyckades att öppna sessionskatalog
f1 = F1 stäng av
f2 = F2 starta om
login = inloggning login = inloggning
logout = utloggad logout = utloggad
numlock = numlock numlock = numlock
password = lösenord password = lösenord
restart = starta om
shell = skal shell = skal
shutdown = stäng av
wayland = wayland wayland = wayland
xinitrc = xinitrc xinitrc = xinitrc

@ -34,12 +34,12 @@ err_user_init = kullanici oturumu baslatilamadi
err_user_uid = kullanici icin UID ayarlanamadi err_user_uid = kullanici icin UID ayarlanamadi
err_xsessions_dir = oturumlar klasoru bulunamadi err_xsessions_dir = oturumlar klasoru bulunamadi
err_xsessions_open = oturumlar klasoru acilamadi err_xsessions_open = oturumlar klasoru acilamadi
f1 = F1 makineyi kapat
f2 = F2 yeniden baslat
login = kullanici login = kullanici
logout = oturumdan cikis yapildi logout = oturumdan cikis yapildi
numlock = numlock numlock = numlock
password = sifre password = sifre
restart = yeniden baslat
shell = shell shell = shell
shutdown = makineyi kapat
wayland = wayland wayland = wayland
xinitrc = xinitrc xinitrc = xinitrc

@ -34,12 +34,12 @@ err_user_init = не вдалося ініціалізувати користу
err_user_uid = не вдалося змінити UID користувача err_user_uid = не вдалося змінити UID користувача
err_xsessions_dir = не вдалося знайти каталог сесій err_xsessions_dir = не вдалося знайти каталог сесій
err_xsessions_open = не вдалося відкрити каталог сесій err_xsessions_open = не вдалося відкрити каталог сесій
f1 = F1 вимкнути
f2 = F2 перезавантажити
login = логін login = логін
logout = вийти logout = вийти
numlock = numlock numlock = numlock
password = пароль password = пароль
restart = перезавантажити
shell = оболонка shell = оболонка
shutdown = вимкнути
wayland = wayland wayland = wayland
xinitrc = xinitrc xinitrc = xinitrc

@ -113,13 +113,13 @@ void lang_load()
{"err_user_uid", &lang.err_user_uid, lang_handle}, {"err_user_uid", &lang.err_user_uid, lang_handle},
{"err_xsessions_dir", &lang.err_xsessions_dir, lang_handle}, {"err_xsessions_dir", &lang.err_xsessions_dir, lang_handle},
{"err_xsessions_open", &lang.err_xsessions_open, lang_handle}, {"err_xsessions_open", &lang.err_xsessions_open, lang_handle},
{"f1", &lang.f1, lang_handle},
{"f2", &lang.f2, lang_handle},
{"login", &lang.login, lang_handle}, {"login", &lang.login, lang_handle},
{"logout", &lang.logout, lang_handle}, {"logout", &lang.logout, lang_handle},
{"numlock", &lang.numlock, lang_handle}, {"numlock", &lang.numlock, lang_handle},
{"password", &lang.password, lang_handle}, {"password", &lang.password, lang_handle},
{"restart", &lang.restart, lang_handle},
{"shell", &lang.shell, lang_handle}, {"shell", &lang.shell, lang_handle},
{"shutdown", &lang.shutdown, lang_handle},
{"wayland", &lang.wayland, lang_handle}, {"wayland", &lang.wayland, lang_handle},
{"xinitrc", &lang.xinitrc, lang_handle}, {"xinitrc", &lang.xinitrc, lang_handle},
}; };
@ -169,7 +169,7 @@ void config_load(const char *cfg_path)
{"default_input", &config.default_input, config_handle_u8}, {"default_input", &config.default_input, config_handle_u8},
{"fg", &config.fg, config_handle_u8}, {"fg", &config.fg, config_handle_u8},
{"hide_borders", &config.hide_borders, config_handle_bool}, {"hide_borders", &config.hide_borders, config_handle_bool},
{"hide_f1_commands", &config.hide_f1_commands, config_handle_bool}, {"hide_key_hints", &config.hide_key_hints, config_handle_bool},
{"input_len", &config.input_len, config_handle_u8}, {"input_len", &config.input_len, config_handle_u8},
{"lang", &config.lang, config_handle_str}, {"lang", &config.lang, config_handle_str},
{"load", &config.load, config_handle_bool}, {"load", &config.load, config_handle_bool},
@ -182,10 +182,12 @@ void config_load(const char *cfg_path)
{"min_refresh_delta", &config.min_refresh_delta, config_handle_u16}, {"min_refresh_delta", &config.min_refresh_delta, config_handle_u16},
{"path", &config.path, config_handle_str}, {"path", &config.path, config_handle_str},
{"restart_cmd", &config.restart_cmd, config_handle_str}, {"restart_cmd", &config.restart_cmd, config_handle_str},
{"restart_key", &config.restart_key, config_handle_str},
{"save", &config.save, config_handle_bool}, {"save", &config.save, config_handle_bool},
{"save_file", &config.save_file, config_handle_str}, {"save_file", &config.save_file, config_handle_str},
{"service_name", &config.service_name, config_handle_str}, {"service_name", &config.service_name, config_handle_str},
{"shutdown_cmd", &config.shutdown_cmd, config_handle_str}, {"shutdown_cmd", &config.shutdown_cmd, config_handle_str},
{"shutdown_key", &config.shutdown_key, config_handle_str},
{"term_reset_cmd", &config.term_reset_cmd, config_handle_str}, {"term_reset_cmd", &config.term_reset_cmd, config_handle_str},
{"tty", &config.tty, config_handle_u8}, {"tty", &config.tty, config_handle_u8},
{"wayland_cmd", &config.wayland_cmd, config_handle_str}, {"wayland_cmd", &config.wayland_cmd, config_handle_str},
@ -198,7 +200,7 @@ void config_load(const char *cfg_path)
{"xsessions", &config.xsessions, config_handle_str}, {"xsessions", &config.xsessions, config_handle_str},
}; };
uint16_t map_len[] = {34}; uint16_t map_len[] = {41};
struct configator_param* map[] = struct configator_param* map[] =
{ {
map_no_section, map_no_section,
@ -254,13 +256,13 @@ void lang_defaults()
lang.err_user_uid = strdup("failed to set user UID"); lang.err_user_uid = strdup("failed to set user UID");
lang.err_xsessions_dir = strdup("failed to find sessions folder"); lang.err_xsessions_dir = strdup("failed to find sessions folder");
lang.err_xsessions_open = strdup("failed to open sessions folder"); lang.err_xsessions_open = strdup("failed to open sessions folder");
lang.f1 = strdup("F1 shutdown");
lang.f2 = strdup("F2 reboot");
lang.login = strdup("login:"); lang.login = strdup("login:");
lang.logout = strdup("logged out"); lang.logout = strdup("logged out");
lang.numlock = strdup("numlock"); lang.numlock = strdup("numlock");
lang.password = strdup("password:"); lang.password = strdup("password:");
lang.restart = strdup("reboot");
lang.shell = strdup("shell"); lang.shell = strdup("shell");
lang.shutdown = strdup("shutdown");
lang.wayland = strdup("wayland"); lang.wayland = strdup("wayland");
lang.xinitrc = strdup("xinitrc"); lang.xinitrc = strdup("xinitrc");
} }
@ -279,6 +281,7 @@ void config_defaults()
config.default_input = LOGIN_INPUT; config.default_input = LOGIN_INPUT;
config.fg = 9; config.fg = 9;
config.hide_borders = false; config.hide_borders = false;
config.hide_key_hints = false;
config.input_len = 34; config.input_len = 34;
config.lang = strdup("en"); config.lang = strdup("en");
config.load = true; config.load = true;
@ -291,10 +294,12 @@ void config_defaults()
config.min_refresh_delta = 5; config.min_refresh_delta = 5;
config.path = strdup("/sbin:/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin"); config.path = strdup("/sbin:/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin");
config.restart_cmd = strdup("/sbin/shutdown -r now"); config.restart_cmd = strdup("/sbin/shutdown -r now");
config.restart_key = strdup("F2");
config.save = true; config.save = true;
config.save_file = strdup("/etc/ly/save"); config.save_file = strdup("/etc/ly/save");
config.service_name = strdup("ly"); config.service_name = strdup("ly");
config.shutdown_cmd = strdup("/sbin/shutdown -a now"); config.shutdown_cmd = strdup("/sbin/shutdown -a now");
config.shutdown_key = strdup("F1");
config.term_reset_cmd = strdup("/usr/bin/tput reset"); config.term_reset_cmd = strdup("/usr/bin/tput reset");
config.tty = 2; config.tty = 2;
config.wayland_cmd = strdup(DATADIR "/wsetup.sh"); config.wayland_cmd = strdup(DATADIR "/wsetup.sh");
@ -345,13 +350,13 @@ void lang_free()
free(lang.err_user_uid); free(lang.err_user_uid);
free(lang.err_xsessions_dir); free(lang.err_xsessions_dir);
free(lang.err_xsessions_open); free(lang.err_xsessions_open);
free(lang.f1);
free(lang.f2);
free(lang.login); free(lang.login);
free(lang.logout); free(lang.logout);
free(lang.numlock); free(lang.numlock);
free(lang.password); free(lang.password);
free(lang.restart);
free(lang.shell); free(lang.shell);
free(lang.shutdown);
free(lang.wayland); free(lang.wayland);
free(lang.xinitrc); free(lang.xinitrc);
} }
@ -364,9 +369,11 @@ void config_free()
free(config.mcookie_cmd); free(config.mcookie_cmd);
free(config.path); free(config.path);
free(config.restart_cmd); free(config.restart_cmd);
free(config.restart_key);
free(config.save_file); free(config.save_file);
free(config.service_name); free(config.service_name);
free(config.shutdown_cmd); free(config.shutdown_cmd);
free(config.shutdown_key);
free(config.term_reset_cmd); free(config.term_reset_cmd);
free(config.wayland_cmd); free(config.wayland_cmd);
free(config.waylandsessions); free(config.waylandsessions);

@ -48,13 +48,13 @@ struct lang
char* err_user_uid; char* err_user_uid;
char* err_xsessions_dir; char* err_xsessions_dir;
char* err_xsessions_open; char* err_xsessions_open;
char* f1;
char* f2;
char* login; char* login;
char* logout; char* logout;
char* numlock; char* numlock;
char* password; char* password;
char* restart;
char* shell; char* shell;
char* shutdown;
char* wayland; char* wayland;
char* xinitrc; char* xinitrc;
}; };
@ -73,7 +73,7 @@ struct config
uint8_t default_input; uint8_t default_input;
uint8_t fg; uint8_t fg;
bool hide_borders; bool hide_borders;
bool hide_f1_commands; bool hide_key_hints;
uint8_t input_len; uint8_t input_len;
char* lang; char* lang;
bool load; bool load;
@ -86,10 +86,12 @@ struct config
uint16_t min_refresh_delta; uint16_t min_refresh_delta;
char* path; char* path;
char* restart_cmd; char* restart_cmd;
char* restart_key;
bool save; bool save;
char* save_file; char* save_file;
char* service_name; char* service_name;
char* shutdown_cmd; char* shutdown_cmd;
char* shutdown_key;
char* term_reset_cmd; char* term_reset_cmd;
uint8_t tty; uint8_t tty;
char* wayland_cmd; char* wayland_cmd;

@ -192,7 +192,7 @@ char* time_str(char* fmt, int maxlen)
{ {
buffer[0] = '\0'; buffer[0] = '\0';
} }
return buffer; return buffer;
} }
@ -373,30 +373,54 @@ void draw_labels(struct term_buf* buf) // throws
} }
} }
void draw_f_commands() void draw_key_hints()
{ {
struct tb_cell* f1 = str_cell(lang.f1); struct tb_cell* shutdown_key = str_cell(config.shutdown_key);
int len = strlen(config.shutdown_key);
if (dgn_catch())
{
dgn_reset();
}
else
{
tb_blit(0, 0, len, 1, shutdown_key);
free(shutdown_key);
}
struct tb_cell* shutdown = str_cell(lang.shutdown);
len += 1;
if (dgn_catch()) if (dgn_catch())
{ {
dgn_reset(); dgn_reset();
} }
else else
{ {
tb_blit(0, 0, strlen(lang.f1), 1, f1); tb_blit(len, 0, strlen(lang.shutdown), 1, shutdown);
free(f1); free(shutdown);
} }
struct tb_cell* f2 = str_cell(lang.f2); struct tb_cell* restart_key = str_cell(config.restart_key);
len += strlen(lang.shutdown) + 1;
if (dgn_catch())
{
dgn_reset();
}
else
{
tb_blit(len, 0, strlen(config.restart_key), 1, restart_key);
free(restart_key);
}
struct tb_cell* restart = str_cell(lang.restart);
len += strlen(config.restart_key) + 1;
if (dgn_catch()) if (dgn_catch())
{ {
dgn_reset(); dgn_reset();
} }
else else
{ {
tb_blit(strlen(lang.f1) + 1, 0, strlen(lang.f2), 1, f2); tb_blit(len, 0, strlen(lang.restart), 1, restart);
free(f2); free(restart);
} }
} }
@ -962,7 +986,7 @@ bool cascade(struct term_buf* term_buf, uint8_t* fails)
} }
c_under = buf[(i + 1) * width + k].ch; c_under = buf[(i + 1) * width + k].ch;
if (!isspace(c_under)) if (!isspace(c_under))
{ {
continue; continue;
@ -983,7 +1007,7 @@ bool cascade(struct term_buf* term_buf, uint8_t* fails)
} }
} }
// stop force-updating // stop force-updating
if (!changes) if (!changes)
{ {
sleep(7); sleep(7);

@ -70,7 +70,7 @@ struct tb_cell* strn_cell(char* s, uint16_t len);
struct tb_cell* str_cell(char* s); struct tb_cell* str_cell(char* s);
void draw_labels(struct term_buf* buf); void draw_labels(struct term_buf* buf);
void draw_f_commands(); void draw_key_hints();
void draw_lock_state(struct term_buf* buf); void draw_lock_state(struct term_buf* buf);
void draw_desktop(struct desktop* target); void draw_desktop(struct desktop* target);
void draw_input(struct text* input); void draw_input(struct text* input);

@ -136,7 +136,7 @@ int main(int argc, char** argv)
// init visible elements // init visible elements
struct tb_event event; struct tb_event event;
struct term_buf buf; struct term_buf buf;
//Place the curser on the login field if there is no saved username, if there is, place the curser on the password field //Place the curser on the login field if there is no saved username, if there is, place the curser on the password field
uint8_t active_input; uint8_t active_input;
if (config.default_input == LOGIN_INPUT && login.text != login.end){ if (config.default_input == LOGIN_INPUT && login.text != login.end){
@ -192,8 +192,8 @@ int main(int argc, char** argv)
draw_box(&buf); draw_box(&buf);
draw_clock(&buf); draw_clock(&buf);
draw_labels(&buf); draw_labels(&buf);
if(!config.hide_f1_commands) if(!config.hide_key_hints)
draw_f_commands(); draw_key_hints();
draw_lock_state(&buf); draw_lock_state(&buf);
position_input(&buf, &desktop, &login, &password); position_input(&buf, &desktop, &login, &password);
draw_desktop(&desktop); draw_desktop(&desktop);
@ -242,15 +242,40 @@ int main(int argc, char** argv)
if (event.type == TB_EVENT_KEY) if (event.type == TB_EVENT_KEY)
{ {
char shutdown_key[4];
memset(shutdown_key, '\0', sizeof(shutdown_key));
strcpy(shutdown_key, config.shutdown_key);
memcpy(shutdown_key, "0", 1);
char restart_key[4];
memset(restart_key, '\0', sizeof(restart_key));
strcpy(restart_key, config.restart_key);
memcpy(restart_key, "0", 1);
switch (event.key) switch (event.key)
{ {
case TB_KEY_F1: case TB_KEY_F1:
shutdown = true;
run = false;
break;
case TB_KEY_F2: case TB_KEY_F2:
reboot = true; case TB_KEY_F3:
run = false; case TB_KEY_F4:
case TB_KEY_F5:
case TB_KEY_F6:
case TB_KEY_F7:
case TB_KEY_F8:
case TB_KEY_F9:
case TB_KEY_F10:
case TB_KEY_F11:
case TB_KEY_F12:
if( 0xFFFF - event.key + 1 == atoi(shutdown_key) )
{
shutdown = true;
run = false;
}
if( 0xFFFF - event.key + 1 == atoi(restart_key) )
{
reboot = true;
run = false;
}
break; break;
case TB_KEY_CTRL_C: case TB_KEY_CTRL_C:
run = false; run = false;

Loading…
Cancel
Save