rebased to master and fixed merge issues

This commit is contained in:
Slade Getz 2023-09-04 13:11:00 -05:00
commit 4e8838fdfd
32 changed files with 633 additions and 235 deletions

View File

@ -3,7 +3,7 @@ CC = gcc
FLAGS = -std=c99 -pedantic -g
FLAGS+= -Wall -Wextra -Werror=vla -Wno-unused-parameter
#FLAGS+= -DDEBUG
FLAGS+= -DGIT_VERSION_STRING=\"$(shell git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g')\"
FLAGS+= -DLY_VERSION=\"$(shell git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g')\"
LINK = -lpam -lxcb
VALGRIND = --show-leak-kinds=all --track-origins=yes --leak-check=full --suppressions=../res/valgrind.supp
CMD = ./$(NAME)
@ -101,7 +101,6 @@ installopenrc:
installrunit:
@echo "installing runit service"
@install -dZ ${DESTDIR}/etc/sv/ly-runit-service
@install -DZ $(RESD)/ly-runit-service/* -t ${DESTDIR}/etc/sv/ly
uninstall:
@ -112,6 +111,7 @@ uninstall:
@rm -f ${DESTDIR}/usr/lib/systemd/system/ly.service
@rm -f ${DESTDIR}/etc/pam.d/ly
@rm -f ${DESTDIR}/etc/init.d/${NAME}
@rm -rf ${DESTDIR}/etc/sv/ly
clean:
@echo "cleaning"

View File

@ -16,7 +16,7 @@ Ly is a lightweight TUI (ncurses-like) display manager for Linux and BSD.
- tput
- 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`
## Support
@ -27,20 +27,21 @@ The following desktop environments were tested with success
- budgie
- cinnamon
- deepin
- dwm
- dwm
- enlightenment
- gnome
- i3
- kde
- labwc
- lxde
- lxqt
- mate
- maxx
- maxx
- pantheon
- qtile
- spectrwm
- sway
- windowmaker
- windowmaker
- xfce
- xmonad
@ -120,22 +121,24 @@ $ make
# ln -s /etc/sv/ly /var/service/
```
Disable your existing display manager service if need be e.g.:
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.:
```
# rm /var/service/lxdm
```
If you are running on `tty2` (check your `/etc/ly/config.ini`) you can disable e.g. `agetty` running there:
The agetty service for the tty console where you are running ly should be disabled. For instance, if you are running ly on tty2 (that's the default, check your `/etc/ly/config.ini`) you should disable the agetty-tty2 service like this:
```
# rm /var/service/agetty-tty2
```
## Arch Linux Installation
You can install ly from the [AUR](https://aur.archlinux.org/packages/ly), using yay for example:
```
$ yay -S ly
You can install ly from the [`[extra]` repos](https://archlinux.org/packages/extra/x86_64/ly/):
```
$ sudo pacman -S ly
```
## Configuration

View File

@ -3,9 +3,14 @@
# The active animation
# 0 -> PSX DOOM fire (default)
# 1 -> CMatrix
# 1 -> CMatrix
#animation = 0
# format string for clock in top right corner (see strftime specification)
#clock = %c
# enable/disable big clock
#bigclock = true
# The character used to mask the password
#asterisk = *
@ -24,12 +29,12 @@
#define TB_CYAN 0x07
#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
# 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
# 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
# cyan, and white, indexed in that order 0 through 15. For example, the color defined for white (indexed at 15 in the mkinitcpio
# 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
# `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
# 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
# config) will be used by `ly` for `fg = 8`.
# Background color id
@ -71,13 +76,19 @@
#save_file = /etc/ly/save
# Remove F1/F2 command hints
#hide_f1_commands = false
# Remove power management command hints
#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
# Command executed when pressing F2
# Command executed when pressing restart_key
#restart_cmd = /sbin/shutdown -r now

6
res/lang/cat.ini Executable file → Normal file
View File

@ -1,5 +1,5 @@
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_chdir = error al obrir carpeta home
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_xsessions_dir = error al cercar la carpeta de sessions
err_xsessions_open = error al obrir la carpeta de sessions
f1 = F1 aturar
f2 = F2 reiniciar
login = iniciar sessió
logout = tancar sessió
numlock = Bloq Num
password = Clau
restart = reiniciar
shell = shell
shutdown = aturar
wayland = wayland
xinitrc = xinitrc

View File

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

View File

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

View File

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

View File

@ -34,12 +34,12 @@ err_user_init = error al inicializar usuario
err_user_uid = error al establecer el UID del usuario
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 sesión
logout = cerrar sesión
numlock = Bloq Num
numlock = Bloq Num
password = contraseña
restart = reiniciar
shell = shell
shutdown = apagar
wayland = wayland
xinitrc = xinitrc

View File

@ -5,7 +5,7 @@ err_chdir = échec de l'ouverture du répertoire home
err_console_dev = échec d'accès à la console
err_dgn_oob = message
err_domain = domaine invalide
err_hostname = échec de captation du nom d'hôte
err_hostname = échec de lecture du nom d'hôte
err_mlock = échec du verrouillage mémoire
err_null = pointeur null
err_pam = échec de la transaction pam
@ -20,7 +20,7 @@ err_pam_cred_expired = identifiants expirés
err_pam_cred_insufficient = identifiants insuffisants
err_pam_cred_unavail = échec de l'obtention des identifiants
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_sys = erreur système
err_pam_user_unknown = utilisateur inconnu
@ -28,18 +28,18 @@ err_path = échec de la modification du path
err_perm_dir = échec de changement de répertoire
err_perm_group = échec du déclassement des permissions de groupe
err_perm_user = échec du déclassement des permissions utilisateur
err_pwnam = échec de captation des infos utilisateur
err_pwnam = échec de lecture des infos utilisateur
err_user_gid = échec de modification du GID
err_user_init = échec d'initialisation de l'utilisateur
err_user_uid = échec de modification du UID
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
logout = déconnection
numlock = verr.num
password = mot de passe
restart = redémarrer
shell = shell
shutdown = éteindre
wayland = wayland
xinitrc = xinitrc

View File

@ -34,12 +34,12 @@ 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
restart = riavvio
shell = shell
shutdown = arresto
wayland = wayland
xinitrc = xinitrc

View File

@ -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_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
restart = uruchom ponownie
shell = powłoka
shutdown = wyłącz
wayland = wayland
xinitrc = xinitrc

View File

@ -34,12 +34,12 @@ err_user_init = erro ao iniciar o utilizador
err_user_uid = erro ao definir o UID do utilizador
err_xsessions_dir = erro ao localizar 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
logout = terminar sessão
numlock = numlock
password = palavra-passe
restart = reiniciar
shell = shell
shutdown = encerrar
wayland = wayland
xinitrc = xinitrc

View File

@ -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_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
logout = desconectado
numlock = numlock
password = senha
restart = reiniciar
shell = shell
shutdown = desligar
wayland = wayland
xinitrc = xinitrc

View File

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

View File

@ -17,7 +17,7 @@ err_pam_authok_reqd = токен истёк
err_pam_buf = ошибка буфера памяти
err_pam_cred_err = не удалось установить полномочия
err_pam_cred_expired = полномочия истекли
err_pam_cred_insufficient = недостаточо полномочий
err_pam_cred_insufficient = недостаточно полномочий
err_pam_cred_unavail = не удалось получить полномочия
err_pam_maxtries = лимит попыток исчерпан
err_pam_perm_denied = доступ запрещён
@ -34,12 +34,12 @@ err_user_init = не удалось инициализировать польз
err_user_uid = не удалось установить UID пользователя
err_xsessions_dir = не удалось найти сессионную папку
err_xsessions_open = не удалось открыть сессионную папку
f1 = F1 выключить
f2 = F2 перезагрузить
login = логин
logout = logged out
numlock = numlock
password = пароль
restart = перезагрузить
shell = shell
shutdown = выключить
wayland = wayland
xinitrc = xinitrc

View File

@ -25,7 +25,7 @@ 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_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
@ -33,13 +33,13 @@ 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
err_xsessions_open = neuspijesno otvaranje foldera sesija
login = korisnik
logout = izlogovan
numlock = numlock
password = lozinka
restart = ponovo pokreni
shell = shell
shutdown = ugasi
wayland = wayland
xinitrc = xinitrc

45
res/lang/sv.ini Normal file
View File

@ -0,0 +1,45 @@
capslock = capslock
err_alloc = misslyckad minnesallokering
err_bounds = utanför banan index
err_chdir = misslyckades att öppna hemkatalog
err_console_dev = misslyckades att komma åt konsol
err_dgn_oob = loggmeddelande
err_domain = okänd domän
err_hostname = misslyckades att hämta värdnamn
err_mlock = misslyckades att låsa lösenordsminne
err_null = nullpekare
err_pam = pam-transaktion misslyckades
err_pam_abort = pam-transaktion avbröts
err_pam_acct_expired = konto upphört
err_pam_auth = autentiseringsfel
err_pam_authinfo_unavail = misslyckades att hämta användarinfo
err_pam_authok_reqd = token utgången
err_pam_buf = minnesbuffer fel
err_pam_cred_err = misslyckades att ställa in inloggningsuppgifter
err_pam_cred_expired = inloggningsuppgifter upphörda
err_pam_cred_insufficient = otillräckliga inloggningsuppgifter
err_pam_cred_unavail = misslyckades att hämta inloggningsuppgifter
err_pam_maxtries = nådde maximal försöksgräns
err_pam_perm_denied = åtkomst nekad
err_pam_session = sessionsfel
err_pam_sys = systemfel
err_pam_user_unknown = okänd användare
err_path = misslyckades att ställa in sökväg
err_perm_dir = misslyckades att ändra aktuell katalog
err_perm_group = misslyckades att nergradera gruppbehörigheter
err_perm_user = misslyckades att nergradera användarbehörigheter
err_pwnam = misslyckades att hämta användarinfo
err_user_gid = misslyckades att ställa in användar-GID
err_user_init = misslyckades att initialisera användaren
err_user_uid = misslyckades att ställa in användar-UID
err_xsessions_dir = misslyckades att hitta sessionskatalog
err_xsessions_open = misslyckades att öppna sessionskatalog
login = inloggning
logout = utloggad
numlock = numlock
password = lösenord
restart = starta om
shell = skal
shutdown = stäng av
wayland = wayland
xinitrc = xinitrc

View File

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

View File

@ -1,5 +1,5 @@
capslock = capslock
err_alloc = невдалий розділ пам'яті
err_alloc = невдале виділення пам'яті
err_bounds = поза межами індексу
err_chdir = не вдалося відкрити домашній каталог
err_console_dev = невдалий доступ до консолі
@ -7,7 +7,7 @@ err_dgn_oob = повідомлення журналу (log)
err_domain = недійсний домен
err_hostname = не вдалося отримати ім'я хосту
err_mlock = збій блокування пам'яті
err_null = нульовий індекс
err_null = нульовий вказівник
err_pam = невдала pam транзакція
err_pam_abort = pam транзакція перервана
err_pam_acct_expired = термін дії акаунту вичерпано
@ -16,11 +16,11 @@ err_pam_authinfo_unavail = не вдалося отримати дані кор
err_pam_authok_reqd = термін дії токена вичерпано
err_pam_buf = помилка буферу пам'яті
err_pam_cred_err = не вдалося змінити облікові дані
err_pam_cred_expired = облікові дані вичерпано
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 = невідомий користувач
@ -32,14 +32,14 @@ err_pwnam = не вдалося отримати дані користувача
err_user_gid = не вдалося змінити GID користувача
err_user_init = не вдалося ініціалізувати користувача
err_user_uid = не вдалося змінити UID користувача
err_xsessions_dir = не вдалося знайти теку сесій
err_xsessions_open = не вдалося відкрити теку сесій
f1 = F1 вимкнути
f2 = F2 перезавантажити
err_xsessions_dir = не вдалося знайти каталог сесій
err_xsessions_open = не вдалося відкрити каталог сесій
login = логін
logout = вийти
numlock = numlock
password = пароль
restart = перезавантажити
shell = оболонка
shutdown = вимкнути
wayland = wayland
xinitrc = xinitrc

View File

@ -8,7 +8,5 @@ fi
BAUD_RATE=38400
TERM_NAME=linux
StandardInput=tty
TTYPath=/dev/tty2
TTYReset=yes
TTYVHangup=yes
auxtty=$(/bin/cat /etc/ly/config.ini 2>/dev/null 1| /bin/sed -n 's/\(^[[:space:]]*tty[[:space:]]*=[[:space:]]*\)\([[:digit:]][[:digit:]]*\)\(.*\)/\2/p')
TTY=tty${auxtty:-2}

View File

@ -1,3 +1,4 @@
#!/bin/sh
tty=${PWD##*-}
exec utmpset -w $tty
[ -r conf ] && . ./conf
exec utmpset -w ${TTY}

View File

@ -1,7 +1,5 @@
#!/bin/sh
tty=${PWD##*-}
[ -r conf ] && . ./conf
if [ -x /sbin/getty -o -x /bin/getty ]; then
@ -12,4 +10,4 @@ elif [ -x /sbin/agetty -o -x /bin/agetty ]; then
GETTY=agetty
fi
exec setsid ${GETTY} ${GETTY_ARGS} -nl /usr/bin/ly tty2 "${BAUD_RATE}" "${TERM_NAME}"
exec setsid ${GETTY} ${GETTY_ARGS} -nl /usr/bin/ly "${TTY}" "${BAUD_RATE}" "${TERM_NAME}"

View File

@ -51,6 +51,4 @@ case $SHELL in
;;
esac
# See https://github.com/fairyglade/ly/issues/433#issuecomment-1245306438
export XDG_RUNTIME_DIR="/run/user/$UID"
exec $@
exec "$@"

View File

@ -90,6 +90,7 @@ elif [ -f /etc/X11/Xresources ]; then
xrdb -merge /etc/X11/Xresources
fi
[ -f $HOME/.Xresources ] && xrdb -merge $HOME/.Xresources
[ -f $XDG_CONFIG_HOME/X11/Xresources ] && xrdb -merge $XDG_CONFIG_HOME/X11/Xresources
if [ -f "$USERXSESSION" ]; then
. "$USERXSESSION"

View File

@ -56,6 +56,38 @@ static const void* ANIM_FREES[] = {
#define DOOM_STEPS 13
static void doom_init(struct term_buf* buf)
{
buf->init_width = buf->width;
buf->init_height = buf->height;
buf->astate = (struct doom_state*)malloc(sizeof(struct doom_state));
if (buf->astate == NULL)
{
dgn_throw(DGN_ALLOC);
}
uint16_t tmp_len = buf->width * buf->height;
// cast the doom state to a pointer to the structure
struct doom_state* d = (struct doom_state*)buf->astate;
d->buf = malloc(tmp_len);
tmp_len -= buf->width;
if (d->buf == NULL)
{
dgn_throw(DGN_ALLOC);
}
memset(d->buf, 0, tmp_len);
memset(d->buf + tmp_len, DOOM_STEPS - 1, buf->width);
}
static void doom_free(struct term_buf* buf)
{
struct doom_state* d = (struct doom_state*)buf->astate;
free(d->buf);
free(d);
}
// Adapted from cmatrix
static void matrix_init(struct term_buf* buf)
@ -63,8 +95,7 @@ static void matrix_init(struct term_buf* buf)
buf->init_width = buf->width;
buf->init_height = buf->height;
buf->astate = (struct matrix_state*)malloc(sizeof(struct matrix_state));
// cast state to matrix_state pointer
struct matrix_state* s = (struct matrix_state*)buf->astate;
struct matrix_state* s = buf->astate;
if (s == NULL)
{
@ -138,13 +169,76 @@ static void matrix_init(struct term_buf* buf)
static void matrix_free(struct term_buf* buf)
{
// casting state to matrix_state pointer
free(((struct matrix_state*)buf->astate)->grid[0]);
free(((struct matrix_state*)buf->astate)->grid);
free(((struct matrix_state*)buf->astate)->length);
free(((struct matrix_state*)buf->astate)->spaces);
free(((struct matrix_state*)buf->astate)->updates);
free(((struct matrix_state*)buf->astate));
struct matrix_state* matrix = buf->astate;
free(matrix->grid[0]);
free(matrix->grid);
free(matrix->length);
free(matrix->spaces);
free(matrix->updates);
free(matrix);
}
static void doom(struct term_buf* term_buf)
{
static struct tb_cell fire[DOOM_STEPS] =
{
{' ', 9, 0}, // default
{0x2591, 2, 0}, // red
{0x2592, 2, 0}, // red
{0x2593, 2, 0}, // red
{0x2588, 2, 0}, // red
{0x2591, 4, 2}, // yellow
{0x2592, 4, 2}, // yellow
{0x2593, 4, 2}, // yellow
{0x2588, 4, 2}, // yellow
{0x2591, 8, 4}, // white
{0x2592, 8, 4}, // white
{0x2593, 8, 4}, // white
{0x2588, 8, 4}, // white
};
uint16_t src;
uint16_t random;
uint16_t dst;
uint16_t w = term_buf->init_width;
uint8_t* tmp = ((struct doom_state*)term_buf->astate)->buf;
if ((term_buf->width != term_buf->init_width) || (term_buf->height != term_buf->init_height))
{
return;
}
struct tb_cell* buf = tb_cell_buffer();
for (uint16_t x = 0; x < w; ++x)
{
for (uint16_t y = 1; y < term_buf->init_height; ++y)
{
src = y * w + x;
random = ((rand() % 7) & 3);
dst = src - random + 1;
if (w > dst)
{
dst = 0;
}
else
{
dst -= w;
}
tmp[dst] = tmp[src] - (random & 1);
if (tmp[dst] > 12)
{
tmp[dst] = 0;
}
buf[dst] = fire[tmp[dst]];
buf[src] = fire[tmp[src]];
}
}
}
// Adapted from cmatrix
@ -154,7 +248,7 @@ static void matrix(struct term_buf* buf)
const int frame_delay = 8;
static int count = 0;
bool first_col;
struct matrix_state* s = ((struct matrix_state*)buf->astate);
struct matrix_state* s = buf->astate;
// Allowed codepoints
const int randmin = 33;
@ -168,7 +262,8 @@ static void matrix(struct term_buf* buf)
}
count += 1;
if (count > frame_delay) {
if (count > frame_delay)
{
frame += 1;
if (frame > 4) frame = 1;
count = 0;
@ -243,7 +338,8 @@ static void matrix(struct term_buf* buf)
uint32_t blank;
utf8_char_to_unicode(&blank, " ");
for (int j = 0; j < buf->width; j += 2) {
for (int j = 0; j < buf->width; j += 2)
{
for (int i = 1; i <= buf->height; ++i)
{
uint32_t c;
@ -271,102 +367,6 @@ static void matrix(struct term_buf* buf)
}
}
// doom functions
static void doom_init(struct term_buf* buf)
{
buf->init_width = buf->width;
buf->init_height = buf->height;
buf->astate = (struct doom_state*)malloc(sizeof(struct doom_state));
if (buf->astate == NULL)
{
dgn_throw(DGN_ALLOC);
}
uint16_t tmp_len = buf->width * buf->height;
// cast state to doom_state pointer
struct doom_state* d = (struct doom_state*)buf->astate;
d->buf = malloc(tmp_len);
tmp_len -= buf->width;
if (((struct doom_state*)buf->astate)->buf == NULL)
{
dgn_throw(DGN_ALLOC);
}
memset(d->buf, 0, tmp_len);
memset(d->buf + tmp_len, DOOM_STEPS - 1, buf->width);
}
static void doom_free(struct term_buf* buf)
{
// cast state to doom_state pointer
free(((struct doom_state*)buf->astate)->buf);
free(((struct doom_state*)buf->astate));
}
static void doom(struct term_buf* term_buf)
{
static struct tb_cell fire[DOOM_STEPS] =
{
{' ', 9, 0}, // default
{0x2591, 2, 0}, // red
{0x2592, 2, 0}, // red
{0x2593, 2, 0}, // red
{0x2588, 2, 0}, // red
{0x2591, 4, 2}, // yellow
{0x2592, 4, 2}, // yellow
{0x2593, 4, 2}, // yellow
{0x2588, 4, 2}, // yellow
{0x2591, 8, 4}, // white
{0x2592, 8, 4}, // white
{0x2593, 8, 4}, // white
{0x2588, 8, 4}, // white
};
uint16_t src;
uint16_t random;
uint16_t dst;
uint16_t w = term_buf->init_width;
uint8_t* tmp = ((struct doom_state*)term_buf->astate)->buf;
if ((term_buf->width != term_buf->init_width) || (term_buf->height != term_buf->init_height))
{
return;
}
struct tb_cell* buf = tb_cell_buffer();
for (uint16_t x = 0; x < w; ++x)
{
for (uint16_t y = 1; y < term_buf->init_height; ++y)
{
src = y * w + x;
random = ((rand() % 7) & 3);
dst = src - random + 1;
if (w > dst)
{
dst = 0;
}
else
{
dst -= w;
}
tmp[dst] = tmp[src] - (random & 1);
if (tmp[dst] > 12)
{
tmp[dst] = 0;
}
buf[dst] = fire[tmp[dst]];
buf[src] = fire[tmp[src]];
}
}
}

146
src/bigclock.h Normal file
View File

@ -0,0 +1,146 @@
#include <stdint.h>
#define CLOCK_W 5
#define CLOCK_H 5
#if defined(__linux__) || defined(__FreeBSD__)
#define X 0x2593
#define _ 0x0000
#else
#define X '#'
#define _ 0
#endif
#if CLOCK_W == 5 && CLOCK_H == 5
uint32_t CLOCK_0[] = {
X,X,X,X,X,
X,X,_,X,X,
X,X,_,X,X,
X,X,_,X,X,
X,X,X,X,X
};
uint32_t CLOCK_1[] = {
_,_,_,X,X,
_,_,_,X,X,
_,_,_,X,X,
_,_,_,X,X,
_,_,_,X,X
};
uint32_t CLOCK_2[] = {
X,X,X,X,X,
_,_,_,X,X,
X,X,X,X,X,
X,X,_,_,_,
X,X,X,X,X
};
uint32_t CLOCK_3[] = {
X,X,X,X,X,
_,_,_,X,X,
X,X,X,X,X,
_,_,_,X,X,
X,X,X,X,X
};
uint32_t CLOCK_4[] = {
X,X,_,X,X,
X,X,_,X,X,
X,X,X,X,X,
_,_,_,X,X,
_,_,_,X,X
};
uint32_t CLOCK_5[] = {
X,X,X,X,X,
X,X,_,_,_,
X,X,X,X,X,
_,_,_,X,X,
X,X,X,X,X
};
uint32_t CLOCK_6[] = {
X,X,X,X,X,
X,X,_,_,_,
X,X,X,X,X,
X,X,_,X,X,
X,X,X,X,X,
};
uint32_t CLOCK_7[] = {
X,X,X,X,X,
_,_,_,X,X,
_,_,_,X,X,
_,_,_,X,X,
_,_,_,X,X
};
uint32_t CLOCK_8[] = {
X,X,X,X,X,
X,X,_,X,X,
X,X,X,X,X,
X,X,_,X,X,
X,X,X,X,X
};
uint32_t CLOCK_9[] = {
X,X,X,X,X,
X,X,_,X,X,
X,X,X,X,X,
_,_,_,X,X,
X,X,X,X,X
};
uint32_t CLOCK_S[] = {
_,_,_,_,_,
_,_,X,_,_,
_,_,_,_,_,
_,_,X,_,_,
_,_,_,_,_
};
uint32_t CLOCK_E[] = {
_,_,_,_,_,
_,_,_,_,_,
_,_,_,_,_,
_,_,_,_,_,
_,_,_,_,_
};
#endif
#undef X
#undef _
static inline uint32_t* CLOCK_N(char c)
{
switch(c)
{
case '0':
return CLOCK_0;
case '1':
return CLOCK_1;
case '2':
return CLOCK_2;
case '3':
return CLOCK_3;
case '4':
return CLOCK_4;
case '5':
return CLOCK_5;
case '6':
return CLOCK_6;
case '7':
return CLOCK_7;
case '8':
return CLOCK_8;
case '9':
return CLOCK_9;
case ':':
return CLOCK_S;
default:
return CLOCK_E;
}
}

View File

@ -113,13 +113,13 @@ void lang_load()
{"err_user_uid", &lang.err_user_uid, lang_handle},
{"err_xsessions_dir", &lang.err_xsessions_dir, 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},
{"logout", &lang.logout, lang_handle},
{"numlock", &lang.numlock, lang_handle},
{"password", &lang.password, lang_handle},
{"restart", &lang.restart, lang_handle},
{"shell", &lang.shell, lang_handle},
{"shutdown", &lang.shutdown, lang_handle},
{"wayland", &lang.wayland, lang_handle},
{"xinitrc", &lang.xinitrc, lang_handle},
};
@ -161,13 +161,15 @@ void config_load(const char *cfg_path)
{"animation", &config.animation, config_handle_u8},
{"asterisk", &config.asterisk, config_handle_char},
{"bg", &config.bg, config_handle_u8},
{"bigclock", &config.bigclock, config_handle_bool},
{"blank_box", &config.blank_box, config_handle_bool},
{"blank_password", &config.blank_password, config_handle_bool},
{"clock", &config.clock, config_handle_str},
{"console_dev", &config.console_dev, config_handle_str},
{"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},
{"hide_key_hints", &config.hide_key_hints, config_handle_bool},
{"input_len", &config.input_len, config_handle_u8},
{"lang", &config.lang, config_handle_str},
{"load", &config.load, config_handle_bool},
@ -180,10 +182,12 @@ void config_load(const char *cfg_path)
{"min_refresh_delta", &config.min_refresh_delta, config_handle_u16},
{"path", &config.path, 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_file", &config.save_file, config_handle_str},
{"service_name", &config.service_name, 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},
{"tty", &config.tty, config_handle_u8},
{"wayland_cmd", &config.wayland_cmd, config_handle_str},
@ -196,7 +200,7 @@ void config_load(const char *cfg_path)
{"xsessions", &config.xsessions, config_handle_str},
};
uint16_t map_len[] = {34};
uint16_t map_len[] = {41};
struct configator_param* map[] =
{
map_no_section,
@ -252,13 +256,13 @@ void lang_defaults()
lang.err_user_uid = strdup("failed to set user UID");
lang.err_xsessions_dir = strdup("failed to find 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.logout = strdup("logged out");
lang.numlock = strdup("numlock");
lang.password = strdup("password:");
lang.restart = strdup("reboot");
lang.shell = strdup("shell");
lang.shutdown = strdup("shutdown");
lang.wayland = strdup("wayland");
lang.xinitrc = strdup("xinitrc");
}
@ -269,12 +273,15 @@ void config_defaults()
config.animation = 0;
config.asterisk = '*';
config.bg = 0;
config.bigclock = false;
config.blank_box = true;
config.blank_password = false;
config.clock = NULL;
config.console_dev = strdup("/dev/console");
config.default_input = LOGIN_INPUT;
config.fg = 9;
config.hide_borders = false;
config.hide_key_hints = false;
config.input_len = 34;
config.lang = strdup("en");
config.load = true;
@ -287,10 +294,12 @@ void config_defaults()
config.min_refresh_delta = 5;
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_key = strdup("F2");
config.save = true;
config.save_file = strdup("/etc/ly/save");
config.service_name = strdup("ly");
config.shutdown_cmd = strdup("/sbin/shutdown -a now");
config.shutdown_key = strdup("F1");
config.term_reset_cmd = strdup("/usr/bin/tput reset");
config.tty = 2;
config.wayland_cmd = strdup(DATADIR "/wsetup.sh");
@ -341,27 +350,30 @@ void lang_free()
free(lang.err_user_uid);
free(lang.err_xsessions_dir);
free(lang.err_xsessions_open);
free(lang.f1);
free(lang.f2);
free(lang.login);
free(lang.logout);
free(lang.numlock);
free(lang.password);
free(lang.restart);
free(lang.shell);
free(lang.shutdown);
free(lang.wayland);
free(lang.xinitrc);
}
void config_free()
{
free(config.clock);
free(config.console_dev);
free(config.lang);
free(config.mcookie_cmd);
free(config.path);
free(config.restart_cmd);
free(config.restart_key);
free(config.save_file);
free(config.service_name);
free(config.shutdown_cmd);
free(config.shutdown_key);
free(config.term_reset_cmd);
free(config.wayland_cmd);
free(config.waylandsessions);

View File

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

View File

@ -5,6 +5,7 @@
#include "utils.h"
#include "config.h"
#include "draw.h"
#include "bigclock.h"
#include <ctype.h>
#include <fcntl.h>
@ -14,7 +15,9 @@
#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <unistd.h>
#include <time.h>
#if defined(__DragonFly__) || defined(__FreeBSD__)
#include <sys/kbio.h>
@ -156,6 +159,105 @@ void draw_box(struct term_buf* buf)
}
}
char* time_str(char* fmt, int maxlen)
{
time_t timer;
char* buffer = malloc(maxlen);
struct tm* tm_info;
timer = time(NULL);
tm_info = localtime(&timer);
if (strftime(buffer, maxlen, fmt, tm_info) == 0)
{
buffer[0] = '\0';
}
return buffer;
}
extern inline uint32_t* CLOCK_N(char c);
struct tb_cell* clock_cell(char c)
{
struct tb_cell* cells = malloc(sizeof(struct tb_cell) * CLOCK_W * CLOCK_H);
struct timeval tv;
gettimeofday(&tv, NULL);
if (config.animate && c == ':' && tv.tv_usec / 500000)
{
c = ' ';
}
uint32_t* clockchars = CLOCK_N(c);
for (int i = 0; i < CLOCK_W * CLOCK_H; i++)
{
cells[i].ch = clockchars[i];
cells[i].fg = config.fg;
cells[i].bg = config.bg;
}
return cells;
}
void alpha_blit(struct tb_cell* buf, uint16_t x, uint16_t y, uint16_t w, uint16_t h, struct tb_cell* cells)
{
if (x + w >= tb_width() || y + h >= tb_height())
return;
for (int i = 0; i < h; i++)
{
for (int j = 0; j < w; j++)
{
struct tb_cell cell = cells[i * w + j];
if (cell.ch)
{
buf[(y + i) * tb_width() + (x + j)] = cell;
}
}
}
}
void draw_bigclock(struct term_buf* buf)
{
if (!config.bigclock)
{
return;
}
int xo = buf->width / 2 - (5 * (CLOCK_W + 1)) / 2;
int yo = (buf->height - buf->box_height) / 2 - CLOCK_H - 2;
char* clockstr = time_str("%H:%M", 6);
struct tb_cell* clockcell;
for (int i = 0; i < 5; i++)
{
clockcell = clock_cell(clockstr[i]);
alpha_blit(tb_cell_buffer(), xo + i * (CLOCK_W + 1), yo, CLOCK_W, CLOCK_H, clockcell);
free(clockcell);
}
free(clockstr);
}
void draw_clock(struct term_buf* buf)
{
if (config.clock == NULL || strlen(config.clock) == 0)
{
return;
}
char* clockstr = time_str(config.clock, 32);
int clockstrlen = strlen(clockstr);
struct tb_cell* cells = strn_cell(clockstr, clockstrlen);
tb_blit(buf->width - clockstrlen, 0, clockstrlen, 1, cells);
free(clockstr);
free(cells);
}
struct tb_cell* strn_cell(char* s, uint16_t len) // throws
{
struct tb_cell* cells = malloc((sizeof (struct tb_cell)) * len);
@ -251,30 +353,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, strlen(lang.f1), 1, f1);
free(f1);
tb_blit(0, 0, len, 1, shutdown_key);
free(shutdown_key);
}
struct tb_cell* f2 = str_cell(lang.f2);
struct tb_cell* shutdown = str_cell(lang.shutdown);
len += 1;
if (dgn_catch())
{
dgn_reset();
}
else
{
tb_blit(strlen(lang.f1) + 1, 0, strlen(lang.f2), 1, f2);
free(f2);
tb_blit(len, 0, strlen(lang.shutdown), 1, shutdown);
free(shutdown);
}
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())
{
dgn_reset();
}
else
{
tb_blit(len, 0, strlen(lang.restart), 1, restart);
free(restart);
}
}
@ -308,6 +434,11 @@ void draw_lock_state(struct term_buf* buf)
// print text
uint16_t pos_x = buf->width - strlen(lang.numlock);
uint16_t pos_y = 1;
if (config.clock == NULL || strlen(config.clock) == 0)
{
pos_y = 0;
}
if (numlock_on)
{
@ -319,7 +450,7 @@ void draw_lock_state(struct term_buf* buf)
}
else
{
tb_blit(pos_x, 0, strlen(lang.numlock), 1, numlock);
tb_blit(pos_x, pos_y, strlen(lang.numlock), 1, numlock);
free(numlock);
}
}
@ -336,7 +467,7 @@ void draw_lock_state(struct term_buf* buf)
}
else
{
tb_blit(pos_x, 0, strlen(lang.capslock), 1, capslock);
tb_blit(pos_x, pos_y, strlen(lang.capslock), 1, capslock);
free(capslock);
}
}
@ -468,7 +599,6 @@ void position_input(
password->visible_len = len;
}
bool cascade(struct term_buf* term_buf, uint8_t* fails)
{
uint16_t width = term_buf->width;
@ -491,7 +621,7 @@ bool cascade(struct term_buf* term_buf, uint8_t* fails)
}
c_under = buf[(i + 1) * width + k].ch;
if (!isspace(c_under))
{
continue;
@ -512,7 +642,7 @@ bool cascade(struct term_buf* term_buf, uint8_t* fails)
}
}
// stop force-updating
// stop force-updating
if (!changes)
{
sleep(7);

View File

@ -47,7 +47,7 @@ struct tb_cell* strn_cell(char* s, uint16_t len);
struct tb_cell* str_cell(char* s);
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_desktop(struct desktop* target);
void draw_input(struct text* input);
@ -62,4 +62,7 @@ void position_input(
bool cascade(struct term_buf* buf, uint8_t* fails);
void draw_bigclock(struct term_buf *buf);
void draw_clock(struct term_buf *buf);
#endif

View File

@ -15,11 +15,11 @@ void handle_desktop(void* input_struct, struct tb_event* event)
if ((event != NULL) && (event->type == TB_EVENT_KEY))
{
if (event->key == TB_KEY_ARROW_LEFT)
if (event->key == TB_KEY_ARROW_LEFT || (event->key == TB_KEY_CTRL_H))
{
input_desktop_right(target);
}
else if (event->key == TB_KEY_ARROW_RIGHT)
else if (event->key == TB_KEY_ARROW_RIGHT || (event->key == TB_KEY_CTRL_L))
{
input_desktop_left(target);
}

View File

@ -15,12 +15,15 @@
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>
#include <stdlib.h>
#define ARG_COUNT 7
// things you can define:
// GIT_VERSION_STRING
#ifndef LY_VERSION
#define LY_VERSION "0.6.0"
#endif
// global
struct lang lang;
@ -30,15 +33,13 @@ struct config config;
void arg_help(void* data, char** pars, const int pars_count)
{
printf("If you want to configure Ly, please check the config file, usually located at /etc/ly/config.ini.\n");
exit(0);
}
void arg_version(void* data, char** pars, const int pars_count)
{
#ifdef GIT_VERSION_STRING
printf("Ly version %s\n", GIT_VERSION_STRING);
#else
printf("Ly version unknown\n");
#endif
printf("Ly version %s\n", LY_VERSION);
exit(0);
}
// low-level error messages
@ -136,7 +137,7 @@ int main(int argc, char** argv)
// init visible elements
struct tb_event event;
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
uint8_t active_input;
if (config.default_input == LOGIN_INPUT && login.text != login.end){
@ -189,10 +190,12 @@ int main(int argc, char** argv)
(*input_handles[active_input])(input_structs[active_input], NULL);
tb_clear();
animate(&buf);
draw_bigclock(&buf);
draw_box(&buf);
draw_clock(&buf);
draw_labels(&buf);
if(!config.hide_f1_commands)
draw_f_commands();
if(!config.hide_key_hints)
draw_key_hints();
draw_lock_state(&buf);
position_input(&buf, &desktop, &login, &password);
draw_desktop(&desktop);
@ -209,11 +212,30 @@ int main(int argc, char** argv)
tb_present();
}
if (config.animate) {
error = tb_peek_event(&event, config.min_refresh_delta);
} else {
error = tb_poll_event(&event);
int timeout = -1;
if (config.animate)
{
timeout = config.min_refresh_delta;
}
else
{
struct timeval tv;
gettimeofday(&tv, NULL);
if (config.bigclock)
timeout = (60 - tv.tv_sec % 60) * 1000 - tv.tv_usec / 1000 + 1;
if (config.clock)
timeout = 1000 - tv.tv_usec / 1000 + 1;
}
if (timeout == -1)
{
error = tb_poll_event(&event);
}
else
{
error = tb_peek_event(&event, timeout);
}
if (error < 0)
{
@ -222,15 +244,40 @@ int main(int argc, char** argv)
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)
{
case TB_KEY_F1:
shutdown = true;
run = false;
break;
case TB_KEY_F2:
reboot = true;
run = false;
case TB_KEY_F3:
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;
case TB_KEY_CTRL_C:
run = false;
@ -242,6 +289,7 @@ int main(int argc, char** argv)
update = true;
}
break;
case TB_KEY_CTRL_K:
case TB_KEY_ARROW_UP:
if (active_input > 0)
{
@ -249,6 +297,7 @@ int main(int argc, char** argv)
update = true;
}
break;
case TB_KEY_CTRL_J:
case TB_KEY_ARROW_DOWN:
if (active_input < 2)
{
@ -323,8 +372,7 @@ int main(int argc, char** argv)
{
execl("/bin/sh", "sh", "-c", config.shutdown_cmd, NULL);
}
if (reboot)
else if (reboot)
{
execl("/bin/sh", "sh", "-c", config.restart_cmd, NULL);
}