From f31c55b562f4c9da291e900fa9816bf90b5e8697 Mon Sep 17 00:00:00 2001 From: OSVidYapan Date: Mon, 16 Mar 2026 21:13:08 +0100 Subject: [PATCH 1/3] Improve README.md (#940) For anyone who doesn't know see this thread; https://codeberg.org/fairyglade/ly/pulls/934 This is the original post i have fixed the commit log issue (by recreating entire new fork) Note that is is also grammarly fixed version. (mostly please advise if i still have those mistakes) Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/940 Reviewed-by: AnErrupTion Co-authored-by: OSVidYapan Co-committed-by: OSVidYapan --- readme.md | 129 +++++++++++++++++------------------------------------- 1 file changed, 41 insertions(+), 88 deletions(-) diff --git a/readme.md b/readme.md index 9014f5e..88f419d 100644 --- a/readme.md +++ b/readme.md @@ -2,25 +2,32 @@ ![Ly screenshot](.github/screenshot.png "Ly screenshot") -Ly is a lightweight TUI (ncurses-like) display manager for Linux and BSD, -designed with portability in mind (e.g. it does not require systemd to run). +Ly is a lightweight TUI (ncurses-like) display manager for Linux and BSD, designed with portability in mind (e.g. it does not require systemd to run). Join us on Matrix over at [#ly-dm:matrix.org](https://matrix.to/#/#ly-dm:matrix.org)! -**Note**: Development happens on [Codeberg](https://codeberg.org/fairyglade/ly) -with a mirror on [GitHub](https://github.com/fairyglade/ly). +**Note**: Development happens on [Codeberg](https://codeberg.org/fairyglade/ly) with a mirror on [GitHub](https://github.com/fairyglade/ly). ## Dependencies - Compile-time: + - zig 0.15.x + - libc + - pam + - xcb (optional, required by default; needed for X11 support) + - Runtime (with default config): + - xorg + - xorg-xauth + - shutdown + - brightnessctl ### Debian @@ -31,8 +38,7 @@ with a mirror on [GitHub](https://github.com/fairyglade/ly). ### Fedora -**Warning**: You may encounter issues with SELinux on Fedora. -It is recommended to add a rule for Ly as it currently does not ship one. +**Warning**: You may encounter issues with SELinux on Fedora. It is recommended to add a rule for Ly as it currently does not ship one. ``` # dnf install kernel-devel pam-devel libxcb-devel zig xorg-x11-xauth xorg-x11-server brightnessctl @@ -50,16 +56,22 @@ It is recommended to add a rule for Ly as it currently does not ship one. ## Support -Ly has been tested with a wide variety of desktop environments and window -managers, all of which you can find in the sections below: +Every environment that works on other login managers also should work on Ly. -[Wayland environments](#supported-wayland-environments) +- Unlike most login managers Ly has xinitrc entry and it also supports shell. -[X11 environments](#supported-x11-environments) +- If you installed your favorite environment and you don't see it, that's because Ly doesn't automatically refresh itself. To fix this you should restart Ly service (depends on your init system) or the easy way is to reboot your system. + +- If your environment is still missing then check at `/usr/share/xsessions` or `/usr/share/wayland-sessions` to see if a .desktop file is present. + +- If there isn't a .desktop file then create a new one at `/etc/ly/custom-sessions` that launches your favorite environment. These .desktop files can be only seen by Ly and if you want them system-wide you also can create at those directories instead. + +- If only Xorg sessions doesn't work then check if your distro compiles Ly with Xorg support as it can be compiled with Xorg support disabled. Logs are defined by `/etc/ly/config.ini`: - The session log is located at `~/.local/state/ly-session.log` by default. + - The system log is located at `/var/log/ly.log` by default. ## Manually building @@ -72,23 +84,17 @@ $ cd ly $ zig build ``` -After building, you can (optionally) test Ly in a terminal emulator, although -authentication will **not** work: +After building, you can (optionally) test Ly in a terminal emulator, although authentication will **not** work: ``` $ zig build run ``` -**Important**: While you can also run Ly in a terminal emulator as root, it is -**not** recommended either. If you want to properly test Ly, please enable its -service (as described below) and reboot your machine. +**Important**: While you can also run Ly in a terminal emulator as root, it is **not** recommended either. If you want to properly test Ly, please enable its service (as described below) and reboot your machine. -The following sections show how to install Ly for a particular init system. -Because the procedure is very similar for all of them, the commands will only -be detailed for the first section (which is about systemd). +The following sections show how to install Ly for a particular init system. Because the procedure is very similar for all of them, the commands will only be detailed for the first section (which is about systemd). -**Note**: All following sections will assume you are using LightDM for -convenience sake. +**Note**: All following sections will assume you are using LightDM for convenience sake. ### systemd @@ -100,9 +106,7 @@ Now, you can install Ly on your system: **Note**: The `init_system` parameter is optional and defaults to `systemd`. -Note that you also need to disable your current display manager. For example, -if LightDM is the current display manager, you can execute the following -command: +Note that you also need to disable your current display manager. For example, if LightDM is the current display manager, you can execute the following command: ``` # systemctl disable lightdm.service @@ -114,8 +118,7 @@ Then, similarly to the previous command, you need to enable the Ly service: # systemctl enable ly@tty2.service ``` -**Important**: Because Ly runs in a TTY, you **must** disable the TTY service -that Ly will run on, otherwise bad things will happen. For example, to disable `getty` spawning on TTY 2, you need to execute the following command: +**Important**: Because Ly runs in a TTY, you **must** disable the TTY service that Ly will run on, otherwise bad things will happen. For example, to disable `getty` spawning on TTY 2, you need to execute the following command: ``` # systemctl disable getty@tty2.service @@ -127,8 +130,7 @@ The target of the symlink, `ly@ttyN.service`, does not actually exist, but syste Compare to `man 5 logind.conf`, especially regarding the `NAutoVTs=` and `ReserveVT=` parameters. -On non-systemd systems, you can change the TTY Ly will run on by editing the corresponding -service file for your platform. +On non-systemd systems, you can change the TTY Ly will run on by editing the corresponding service file for your platform. ### OpenRC @@ -139,8 +141,7 @@ service file for your platform. # rc-update del agetty.tty2 ``` -**Note**: On Gentoo specifically, you also **must** comment out the appropriate -line for the TTY in /etc/inittab. +**Note**: On Gentoo specifically, you also **must** comment out the appropriate line for the TTY in /etc/inittab. ### runit @@ -171,8 +172,7 @@ To disable TTY 2, edit `/etc/s6/config/tty2.conf` and set `SPAWN="no"`. # dinitctl enable ly ``` -To disable TTY 2, go to `/etc/dinit.d/config/console.conf` and modify -`ACTIVE_CONSOLES`. +To disable TTY 2, go to `/etc/dinit.d/config/console.conf` and modify `ACTIVE_CONSOLES`. ### sysvinit @@ -199,8 +199,7 @@ Ly:\ :al=root: ``` -Then, modify the command field of the `ttyv1` terminal entry in `/etc/ttys` -(TTYs in FreeBSD start at 0): +Then, modify the command field of the `ttyv1` terminal entry in `/etc/ttys` (TTYs in FreeBSD start at 0): ``` ttyv1 "/usr/libexec/getty Ly" xterm on secure @@ -208,37 +207,27 @@ ttyv1 "/usr/libexec/getty Ly" xterm on secure ### Updating -You can also install Ly without overrding the current configuration file. This -is called **updating**. To update, simply run: +You can also install Ly without overrding the current configuration file. This is called **updating**. To update, simply run: ``` # zig build installnoconf ``` -You can, of course, still select the init system of your choice when using this -command. +You can, of course, still select the init system of your choice when using this command. ## Configuration -You can find all the configuration in `/etc/ly/config.ini`. The file is fully -commented, and includes the default values. +You can find all the configuration in `/etc/ly/config.ini`. The file is fully commented, and includes the default values. ## Controls -Use the Up/Down arrow keys to change the current field, and the Left/Right -arrow keys to scroll through the different fields (whether it be the info line, -the desktop environment, or the username). The info line is where messages and -errors are displayed. +Use the Up/Down arrow keys to change the current field, and the Left/Right arrow keys to scroll through the different fields (whether it be the info line, the desktop environment, or the username). The info line is where messages and errors are displayed. ## A note on .xinitrc -If your `.xinitrc` file doesn't work ,make sure it is executable and includes a -shebang. This file is supposed to be a shell script! Quoting from `xinit`'s man -page: +If your `.xinitrc` file doesn't work ,make sure it is executable and includes a shebang. This file is supposed to be a shell script! Quoting from `xinit`'s man page: -> If no specific client program is given on the command line, xinit will look -> for a file in the user's home directory called .xinitrc to run as a shell -> script to start up client programs. +> If no specific client program is given on the command line, xinit will look for a file in the user's home directory called .xinitrc to run as a shell script to start up client programs. A typical shebang for a shell script looks like this: @@ -249,50 +238,14 @@ A typical shebang for a shell script looks like this: ## Tips - The numlock and capslock state is printed in the top-right corner. + - Use the F1 and F2 keys to respectively shutdown and reboot. -- Take a look at your `.xsession` file if X doesn't start, as it can interfere - (this file is launched with X to configure the display properly). -## Supported Wayland environments - -- budgie -- cosmic -- deepin -- enlightenment -- gnome -- hyprland -- kde -- labwc -- niri -- pantheon -- sway -- weston - -## Supported X11 environments - -- awesome -- bspwm -- budgie -- cinnamon -- dwm -- enlightenment -- gnome -- kde -- leftwm -- lxde -- mate -- maxx -- pantheon -- qwm -- spectrwm -- windowmaker -- xfce -- xmonad +- Take a look at your `.xsession` file if X doesn't start, as it can interfere (this file is launched with X to configure the display properly). ## A final note -The name "Ly" is a tribute to the fairy from the game Rayman. Ly was tested by -oxodao, who is some seriously awesome dude. +The name "Ly" is a tribute to the fairy from the game Rayman. Ly was tested by oxodao, who is some seriously awesome dude. Also, Ly wouldn't be there today without [Kawaii-Ash](https://github.com/Kawaii-Ash), who has done significant contributions to the project for the Zig rewrite, which lead to the release of Ly v1.0.0. Massive thanks, and sorry for not crediting you enough beforehand! From 7cefff45705f32a8ec6f093adb7f93900e86e041 Mon Sep 17 00:00:00 2001 From: GalaxyShard Date: Mon, 16 Mar 2026 23:16:43 +0100 Subject: [PATCH 2/3] Add Esperanto translation (#942) Title. - [x] I have tested & confirmed the changes work locally Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/942 Reviewed-by: AnErrupTion Co-authored-by: GalaxyShard Co-committed-by: GalaxyShard --- res/lang/eo.ini | 78 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 res/lang/eo.ini diff --git a/res/lang/eo.ini b/res/lang/eo.ini new file mode 100644 index 0000000..9c75dc3 --- /dev/null +++ b/res/lang/eo.ini @@ -0,0 +1,78 @@ +authenticating = aŭtentigado... +brightness_down = malpliigi helecon +brightness_up = pliigi helecon +capslock = majuskla baskulo +custom = propra +err_alloc = malsukcesis memorasignon +err_args = ne povas analizi argumentojn de komanda linio +err_autologin_session = aŭtomatan ensalutan seancon ne trovis +err_bounds = indico estas ekster-intervala +err_brightness_change = malsukcesis ŝanĝi la helecon +err_chdir = malsukcesis malfermi hejman dosierujon +err_clock_too_long = horloĝa ĉeno estas tro longa +err_config = ne povas analizi agordan dosieron +err_crawl = malsukcesis dum serĉado de seancaj dosierujoj +err_dgn_oob = protokola mesaĝo +err_domain = malvalida domajno +err_empty_password = ne akceptas malplenan pasvorton +err_envlist = malsukcesis preni la medivariablojn +err_get_active_tty = malsukcesis preni la aktivan TTY-on +err_hibernate = malsukcesis ruli la komandon por diskodormo +err_hostname = malsukcesis preni la sistemnomon +err_inactivity = malsukcesis ruli la agorditan komandon por malaktiveco +err_lock_state = malsukcesis preni la ŝlosan staton +err_log = malsukcesis malfermi la protokolan dosieron +err_mlock = malsukcesis ŝlosi pasvortan memoron +err_null = nula memorloko +err_numlock = malsukcesis agordi numeran baskulon +err_pam = PAM-a transakcio malsukcesis +err_pam_abort = PAM-a transakcio malsukcesis +err_pam_acct_expired = konto eksvalidiĝis +err_pam_auth = aŭtentiga eraro +err_pam_authinfo_unavail = malsukcesis preni uzantajn informojn +err_pam_authok_reqd = memorsigno eksvalidiĝis +err_pam_buf = bufra eraro +err_pam_cred_err = malsukcesis agordi akreditaĵon +err_pam_cred_expired = akreditaĵo eksvalidiĝis +err_pam_cred_insufficient = nesufiĉa akreditaĵo +err_pam_cred_unavail = malsukcesis preni akreditaĵon +err_pam_maxtries = atingis maksimuman kvanton da provoj +err_pam_perm_denied = permeso negis +err_pam_session = seancan eraron +err_pam_sys = sisteman eraron +err_pam_user_unknown = ne konas uzanton +err_path = malsukcesis agordi la median dosierindikon +err_perm_dir = malsukcesis ŝanĝi la nunan dosierujon +err_perm_group = malsukcesis redukti grupajn permesojn +err_perm_user = malsukcesis redukti uzantajn permesojn +err_pwnam = malsukcesis preni uzantajn informojn +err_sleep = malsukcesis ruli memordorman komandon +err_start = malsukcesis ruli startan komandon +err_battery = malsukcesis ŝargi baterian staton +err_switch_tty = malsukcesis ŝanĝi TTY-on +err_tty_ctrl = TTY-an stiran transigon malsukcesis +err_no_users = nul uzantojn trovas +err_uid_range = malsukcesis dinamike preni UID-an intervalon +err_user_gid = malsukcesis agordi uzantan GID-on +err_user_init = malsukcesis iniciĝi uzanto +err_user_uid = malsukcesis agordi uzantan UID-on +err_xauth = malsukcesis plenumi je xauth +err_xcb_conn = malsukcesis dum konectado al xcb +err_xsessions_dir = malsukcesis trovi seancan dosierujon +err_xsessions_open = malsukcesis malfermi seancan dosierujon +hibernate = diskodormi +insert = enmeti +login = uzanto +logout = elsalutis +no_x11_support = x11 estas foriĝita de kompil-tempo +normal = normala +numlock = numera baskulo +other = alia +password = pasvorto +restart = restartigi +shell = ŝelo +shutdown = malŝalti +sleep = memordormi +wayland = wayland +x11 = x11 +xinitrc = xinitrc From 3a4109eb2d52c9183fb48c265fd128377864bb1a Mon Sep 17 00:00:00 2001 From: Luna Date: Tue, 17 Mar 2026 12:27:23 +0100 Subject: [PATCH 3/3] Add toggle visibility to password (#938) ## What are the changes about? I have add a keybinding to toggle the visibility of the password ## What existing issue does this resolve? N/A ## Pre-requisites - [x] I have tested & confirmed the changes work locally Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/938 Reviewed-by: AnErrupTion Co-authored-by: Luna Co-committed-by: Luna --- res/config.ini | 3 +++ res/lang/ar.ini | 1 + res/lang/bg.ini | 1 + res/lang/cat.ini | 1 + res/lang/cs.ini | 1 + res/lang/de.ini | 1 + res/lang/en.ini | 1 + res/lang/es.ini | 1 + res/lang/fr.ini | 1 + res/lang/it.ini | 1 + res/lang/ja_JP.ini | 1 + res/lang/ku.ini | 1 + res/lang/lv.ini | 1 + res/lang/pl.ini | 1 + res/lang/pt.ini | 1 + res/lang/pt_BR.ini | 1 + res/lang/ro.ini | 1 + res/lang/ru.ini | 1 + res/lang/sr.ini | 1 + res/lang/sv.ini | 3 ++- res/lang/tr.ini | 3 ++- res/lang/uk.ini | 1 + res/lang/zh_CN.ini | 1 + src/config/Config.zig | 1 + src/config/Lang.zig | 1 + src/main.zig | 34 +++++++++++++++++++++++++++++++++- src/tui/components/Text.zig | 4 ++++ 27 files changed, 66 insertions(+), 3 deletions(-) diff --git a/res/config.ini b/res/config.ini index 9e917f1..715d679 100644 --- a/res/config.ini +++ b/res/config.ini @@ -325,6 +325,9 @@ session_log = .local/state/ly-session.log # Setup command setup_cmd = $CONFIG_DIRECTORY/ly/setup.sh +# Specifies the key combination used for showing the password +show_password_key = F7 + # Command executed when pressing shutdown_key shutdown_cmd = /sbin/shutdown $PLATFORM_SHUTDOWN_ARG now diff --git a/res/lang/ar.ini b/res/lang/ar.ini index 6971326..14aaee6 100644 --- a/res/lang/ar.ini +++ b/res/lang/ar.ini @@ -73,6 +73,7 @@ restart = اعادة التشغيل shell = shell shutdown = ايقاف التشغيل sleep = وضع السكون + wayland = wayland x11 = x11 xinitrc = xinitrc diff --git a/res/lang/bg.ini b/res/lang/bg.ini index 8557023..ee38f60 100644 --- a/res/lang/bg.ini +++ b/res/lang/bg.ini @@ -73,6 +73,7 @@ restart = рестартиране shell = обвивка shutdown = изключване sleep = заспиване + wayland = wayland x11 = x11 xinitrc = xinitrc diff --git a/res/lang/cat.ini b/res/lang/cat.ini index 85dbe53..967c728 100644 --- a/res/lang/cat.ini +++ b/res/lang/cat.ini @@ -73,6 +73,7 @@ restart = reiniciar shell = shell shutdown = aturar sleep = suspendre + wayland = wayland x11 = x11 xinitrc = xinitrc diff --git a/res/lang/cs.ini b/res/lang/cs.ini index ff6943e..9e879e1 100644 --- a/res/lang/cs.ini +++ b/res/lang/cs.ini @@ -73,6 +73,7 @@ restart = restartovat shell = příkazový řádek shutdown = vypnout + wayland = wayland xinitrc = xinitrc diff --git a/res/lang/de.ini b/res/lang/de.ini index 60ca3bd..d4a5f30 100644 --- a/res/lang/de.ini +++ b/res/lang/de.ini @@ -73,6 +73,7 @@ restart = Neustarten shell = Shell shutdown = Herunterfahren sleep = Sleep + wayland = wayland x11 = X11 xinitrc = xinitrc diff --git a/res/lang/en.ini b/res/lang/en.ini index b840816..082b02f 100644 --- a/res/lang/en.ini +++ b/res/lang/en.ini @@ -73,6 +73,7 @@ restart = reboot shell = shell shutdown = shutdown sleep = sleep +toggle_password = toggle password wayland = wayland x11 = x11 xinitrc = xinitrc diff --git a/res/lang/es.ini b/res/lang/es.ini index fd3450a..9f04ecb 100644 --- a/res/lang/es.ini +++ b/res/lang/es.ini @@ -73,6 +73,7 @@ restart = reiniciar shell = shell shutdown = apagar sleep = suspender + wayland = wayland xinitrc = xinitrc diff --git a/res/lang/fr.ini b/res/lang/fr.ini index 17258de..886149b 100644 --- a/res/lang/fr.ini +++ b/res/lang/fr.ini @@ -73,6 +73,7 @@ restart = redémarrer shell = shell shutdown = éteindre sleep = veille + wayland = wayland x11 = x11 xinitrc = xinitrc diff --git a/res/lang/it.ini b/res/lang/it.ini index d909609..245c84e 100644 --- a/res/lang/it.ini +++ b/res/lang/it.ini @@ -73,6 +73,7 @@ restart = riavvio shell = shell shutdown = arresto + wayland = wayland xinitrc = xinitrc diff --git a/res/lang/ja_JP.ini b/res/lang/ja_JP.ini index f77abd3..9c98b93 100644 --- a/res/lang/ja_JP.ini +++ b/res/lang/ja_JP.ini @@ -73,6 +73,7 @@ restart = 再起動 shell = シェル shutdown = シャットダウン sleep = スリープ + wayland = Wayland x11 = X11 xinitrc = xinitrc diff --git a/res/lang/ku.ini b/res/lang/ku.ini index 897d557..a47ef65 100644 --- a/res/lang/ku.ini +++ b/res/lang/ku.ini @@ -73,6 +73,7 @@ restart = ji nû ve bide destpêkirin shell = shell shutdown = vemirîne sleep = têxîne xewê + wayland = wayland x11 = x11 xinitrc = xinitrc diff --git a/res/lang/lv.ini b/res/lang/lv.ini index f572a99..6def7f8 100644 --- a/res/lang/lv.ini +++ b/res/lang/lv.ini @@ -73,6 +73,7 @@ restart = restartēt shell = terminālis shutdown = izslēgt sleep = snauda + wayland = wayland x11 = x11 xinitrc = xinitrc diff --git a/res/lang/pl.ini b/res/lang/pl.ini index aadc9ff..3adef78 100644 --- a/res/lang/pl.ini +++ b/res/lang/pl.ini @@ -73,6 +73,7 @@ restart = uruchom ponownie shell = powłoka shutdown = wyłącz sleep = uśpij + wayland = wayland x11 = x11 xinitrc = xinitrc diff --git a/res/lang/pt.ini b/res/lang/pt.ini index 16d25a3..608a122 100644 --- a/res/lang/pt.ini +++ b/res/lang/pt.ini @@ -73,6 +73,7 @@ restart = reiniciar shell = shell shutdown = encerrar + wayland = wayland xinitrc = xinitrc diff --git a/res/lang/pt_BR.ini b/res/lang/pt_BR.ini index f8d0e26..fb5d58e 100644 --- a/res/lang/pt_BR.ini +++ b/res/lang/pt_BR.ini @@ -73,6 +73,7 @@ restart = reiniciar shell = shell shutdown = desligar + wayland = wayland xinitrc = xinitrc diff --git a/res/lang/ro.ini b/res/lang/ro.ini index 9dfd75a..33c6e5d 100644 --- a/res/lang/ro.ini +++ b/res/lang/ro.ini @@ -73,6 +73,7 @@ restart = resetează shell = shell shutdown = opreşte sistemul + wayland = wayland xinitrc = xinitrc diff --git a/res/lang/ru.ini b/res/lang/ru.ini index e47a41e..baad2f2 100644 --- a/res/lang/ru.ini +++ b/res/lang/ru.ini @@ -73,6 +73,7 @@ restart = перезагрузить shell = оболочка shutdown = выключить sleep = сон + wayland = wayland x11 = x11 xinitrc = xinitrc diff --git a/res/lang/sr.ini b/res/lang/sr.ini index 71c7ea1..e5dcd4b 100644 --- a/res/lang/sr.ini +++ b/res/lang/sr.ini @@ -73,6 +73,7 @@ restart = ponovo pokreni shell = shell shutdown = ugasi + wayland = wayland xinitrc = xinitrc diff --git a/res/lang/sv.ini b/res/lang/sv.ini index 5f869ca..2cb113c 100644 --- a/res/lang/sv.ini +++ b/res/lang/sv.ini @@ -73,6 +73,7 @@ restart = starta om shell = shell shutdown = stäng av sleep = viloläge + wayland = wayland x11 = x11 -xinitrc = xinitrc \ No newline at end of file +xinitrc = xinitrc diff --git a/res/lang/tr.ini b/res/lang/tr.ini index d3ad9ba..807cf30 100644 --- a/res/lang/tr.ini +++ b/res/lang/tr.ini @@ -73,6 +73,7 @@ restart = yeniden baslat shell = shell shutdown = makineyi kapat sleep = uykuya al + wayland = wayland -xinitrc = xinitrc \ No newline at end of file +xinitrc = xinitrc diff --git a/res/lang/uk.ini b/res/lang/uk.ini index f1dcf54..fe37435 100644 --- a/res/lang/uk.ini +++ b/res/lang/uk.ini @@ -73,6 +73,7 @@ restart = перезавантажити shell = оболонка shutdown = вимкнути + wayland = wayland xinitrc = xinitrc diff --git a/res/lang/zh_CN.ini b/res/lang/zh_CN.ini index 493ceac..ce1b23c 100644 --- a/res/lang/zh_CN.ini +++ b/res/lang/zh_CN.ini @@ -73,6 +73,7 @@ password = 密码 shell = shell + wayland = wayland x11 = x11 xinitrc = xinitrc diff --git a/src/config/Config.zig b/src/config/Config.zig index 1672dbb..b3f1e53 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -82,6 +82,7 @@ save: bool = true, service_name: [:0]const u8 = "ly", session_log: ?[]const u8 = "ly-session.log", setup_cmd: []const u8 = build_options.config_directory ++ "/ly/setup.sh", +show_password_key: []const u8 = "F7", shutdown_cmd: []const u8 = "/sbin/shutdown -a now", shutdown_key: []const u8 = "F1", sleep_cmd: ?[]const u8 = null, diff --git a/src/config/Lang.zig b/src/config/Lang.zig index 79145e5..e21700a 100644 --- a/src/config/Lang.zig +++ b/src/config/Lang.zig @@ -78,6 +78,7 @@ restart: []const u8 = "reboot", shell: [:0]const u8 = "shell", shutdown: []const u8 = "shutdown", sleep: []const u8 = "sleep", +toggle_password: []const u8 = "toggle password", wayland: []const u8 = "wayland", x11: []const u8 = "x11", xinitrc: [:0]const u8 = "xinitrc", diff --git a/src/main.zig b/src/main.zig index a1d88b8..0f5df1d 100644 --- a/src/main.zig +++ b/src/main.zig @@ -76,6 +76,7 @@ const UiState = struct { restart_label: Label, sleep_label: Label, hibernate_label: Label, + toggle_password_label: Label, brightness_down_label: Label, brightness_up_label: Label, numlock_label: Label, @@ -393,6 +394,16 @@ pub fn main() !void { ); defer state.hibernate_label.deinit(); + state.toggle_password_label = Label.init( + "", + null, + state.buffer.fg, + state.buffer.bg, + null, + null, + ); + defer state.toggle_password_label.deinit(); + state.brightness_down_label = Label.init( "", null, @@ -424,6 +435,11 @@ pub fn main() !void { "{s} {s}", .{ state.config.restart_key, state.lang.restart }, ); + try state.toggle_password_label.setTextAlloc( + state.allocator, + "{s} {s}", + .{ state.config.show_password_key, state.lang.toggle_password }, + ); if (state.config.sleep_cmd != null) { try state.sleep_label.setTextAlloc( state.allocator, @@ -1019,6 +1035,10 @@ pub fn main() !void { if (state.config.sleep_cmd != null) { try layer2.append(state.allocator, state.sleep_label.widget()); } + if (state.config.hibernate_cmd != null) { + try layer2.append(state.allocator, state.hibernate_label.widget()); + } + try layer2.append(state.allocator, state.toggle_password_label.widget()); if (state.config.brightness_down_key != null) { try layer2.append(state.allocator, state.brightness_down_label.widget()); } @@ -1074,6 +1094,7 @@ pub fn main() !void { try state.buffer.registerKeybind(state.config.shutdown_key, &shutdownCmd, &state); try state.buffer.registerKeybind(state.config.restart_key, &restartCmd, &state); + try state.buffer.registerKeybind(state.config.show_password_key, &togglePasswordMask, &state); if (state.config.sleep_cmd != null) try state.buffer.registerKeybind(state.config.sleep_key, &sleepCmd, &state); if (state.config.hibernate_cmd != null) try state.buffer.registerKeybind(state.config.hibernate_key, &hibernateCmd, &state); if (state.config.brightness_down_key) |key| try state.buffer.registerKeybind(key, &decreaseBrightnessCmd, &state); @@ -1201,6 +1222,14 @@ fn clearPassword(ptr: *anyopaque) !bool { return false; } +fn togglePasswordMask(ptr: *anyopaque) !bool { + var state: *UiState = @ptrCast(@alignCast(ptr)); + + state.password.toggleMask(); + state.buffer.drawNextFrame(true); + return false; +} + fn quit(ptr: *anyopaque) !bool { var state: *UiState = @ptrCast(@alignCast(ptr)); @@ -1666,7 +1695,10 @@ fn positionWidgets(ptr: *anyopaque) !void { state.hibernate_label.positionX(state.sleep_label .childrenPosition() .addX(1)); - state.brightness_down_label.positionX(state.hibernate_label + state.toggle_password_label.positionX(state.hibernate_label + .childrenPosition() + .addX(1)); + state.brightness_down_label.positionX(state.toggle_password_label .childrenPosition() .addX(1)); state.brightness_up_label.positionXY(state.brightness_down_label diff --git a/src/tui/components/Text.zig b/src/tui/components/Text.zig index 3890e79..d31aee7 100644 --- a/src/tui/components/Text.zig +++ b/src/tui/components/Text.zig @@ -96,6 +96,10 @@ pub fn clear(self: *Text) void { self.visible_start = 0; } +pub fn toggleMask(self: *Text) void { + self.masked = !self.masked; +} + pub fn handle(self: *Text, maybe_key: ?keyboard.Key, insert_mode: bool) !void { if (maybe_key) |key| { if (key.left or (!insert_mode and (key.h or key.backspace))) {