Feature: Add custom command & label support (#945)

## What are the changes about?

Adds customizable commands and labels to ly.
Solves https://codeberg.org/fairyglade/ly/issues/905.

Since Ly doesn't use INI headers. I use them exclusively for declarations of custom commands and labels.

### Commands

Bind a keybind to a command, and add a hint to the HUD. Useful for use cases like display brightness, switching between GPUs, etc.

Supports localization in the `name` field only. ex: where `lang = es`: `$brightness_up` => `bajar brillo`

Declared in config.ini with the following:

```ini
[cmd:F8]
name = custom command 2
cmd = touch /tmp/ly.gaming
```

### Labels

Add a label to the HUD. As specified in #905.
The text of the label corresponds to the output of the command specified in `[lbl:NAME]`.
Only shows the first line of the output.

Declared in config.ini with the following:

```ini
[lbl:kernel]
cmd = uname -srn
refresh = 0
```

Example to add to the config.ini:
```ini
# Declare a command with the F8 binding.
[cmd:F8]
#The name of the command to show up in Ly.
name = custom command
cmd = touch /tmp/ly.gaming

# Declare a label with an ID. This ID should be unique across all labels.
[lbl:kernel]
cmd = uname -srn
# In frames, the time to re-run the command and update the label. If 0, only run once- do not refresh.
refresh = 0

# Once you're done setting up labels and commands, add an empty header
# below to continue configurating the rest of Ly.
# Put other settings not belonging to custom commands/labels below here.
[]

```

## Pre-requisites

- [x] I have tested & confirmed the changes work locally

![image](/attachments/f9373ac9-567e-4f47-987c-1df6f4ee0d84)

Reviewed-on: https://codeberg.org/fairyglade/ly/pulls/945
Reviewed-by: AnErrupTion <anerruption+codeberg@disroot.org>
Co-authored-by: RadsammyT <radsammyt@gmail.com>
Co-committed-by: RadsammyT <radsammyt@gmail.com>
This commit is contained in:
RadsammyT
2026-03-27 17:15:49 +01:00
committed by AnErrupTion
parent a6fc5d67e8
commit 7a8d913531
30 changed files with 376 additions and 1 deletions

View File

@@ -143,6 +143,11 @@ colormix_col2 = 0x000000FF
# Color mixing animation third color id
colormix_col3 = 0x20000000
# For custom binds: the horizontal limit in characters for each
# line of custom binds before moving on to the next.
# If null, defaults to the width of the terminal instead.
custom_bind_width = null
# Custom sessions directory
# You can specify multiple directories,
# e.g. $CONFIG_DIRECTORY/ly/custom-sessions:$PREFIX_DIRECTORY/share/custom-sessions
@@ -380,3 +385,35 @@ xinitrc = ~/.xinitrc
# You can specify multiple directories,
# e.g. $PREFIX_DIRECTORY/share/xsessions:$PREFIX_DIRECTORY/local/share/xsessions
xsessions = $PREFIX_DIRECTORY/share/xsessions
# Custom Commands and Labels:
# The following examples below give an outline for setting up custom commands and labels.
# Unless specified as optional, an option is mandatory.
# Comments preceding with '##' are for documentation.
# Comments preceding with '#' comment out the example INI.
##---
## Declare a command with the F8 binding.
#[cmd:F8]
## The name of the command to show up in Ly.
## Note: "$" in "$brightness_up" fetches the appropriate string from the specified locale file
## and is replaced with the value representing "brightness_up".
## You can see the list of keys in any locale file in $CONFIG_DIRECTORY/ly/lang.
#name = custom command $brightness_up
#cmd = touch /tmp/ly.gaming
#
## Declare a label with an ID. This ID should be unique across all labels.
#[lbl:kernel]
#cmd = uname -srn
## Optional, defaulting to 0.
## In frames, the time to re-run the command and update the label.
## If 0, only run once and do not refresh afterwards
#refresh = 0
#
## Once you're done setting up labels and commands, add an empty header
## below to continue configurating the rest of Ly.
## Put other settings not belonging to custom commands/labels below here.
#[]
#
##---

View File

@@ -3,6 +3,9 @@ brightness_down = خفض السطوع
brightness_up = رفع السطوع
capslock = capslock
err_alloc = فشل في تخصيص الذاكرة

View File

@@ -3,6 +3,9 @@ brightness_down = намаляване на яркостта
brightness_up = увеличаване на яркостта
capslock = caps lock
custom = персонализирано
err_alloc = неуспешно заделяне на памет
err_args = неуспешен анализ на аргументите от командния ред
err_autologin_session = сесията за автоматично влизане не е намерена

View File

@@ -3,6 +3,9 @@ brightness_down = abaixar brillantor
brightness_up = apujar brillantor
capslock = Bloq Majús
err_alloc = assignació de memòria fallida

View File

@@ -3,6 +3,9 @@
capslock = capslock
err_alloc = alokace paměti selhala

View File

@@ -3,6 +3,9 @@ brightness_down = Helligkeit-
brightness_up = Helligkeit+
capslock = Feststelltaste
err_alloc = Speicherzuweisung fehlgeschlagen

View File

@@ -3,6 +3,9 @@ brightness_down = decrease brightness
brightness_up = increase brightness
capslock = capslock
custom = custom
custom_info_err_output_long = output too long
custom_info_err_no_output = no output
custom_info_err_no_output_error = , possible error
err_alloc = failed memory allocation
err_args = unable to parse command line arguments
err_autologin_session = autologin session not found

View File

@@ -3,6 +3,9 @@ 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
@@ -73,6 +76,7 @@ restart = restartigi
shell = ŝelo
shutdown = malŝalti
sleep = memordormi
wayland = wayland
x11 = x11
xinitrc = xinitrc

View File

@@ -3,6 +3,9 @@ brightness_down = bajar brillo
brightness_up = subir brillo
capslock = Bloq Mayús
err_alloc = asignación de memoria fallida

View File

@@ -3,6 +3,9 @@ brightness_down = diminuer la luminosité
brightness_up = augmenter la luminosité
capslock = verr.maj
custom = customisé
err_alloc = échec d'allocation mémoire
err_args = échec de l'analyse des arguments en lignes de commande
err_autologin_session = session de connexion automatique introuvable

View File

@@ -3,6 +3,9 @@
capslock = capslock
err_alloc = impossibile allocare memoria

View File

@@ -3,6 +3,9 @@ brightness_down = 明るさを下げる
brightness_up = 明るさを上げる
capslock = CapsLock
err_alloc = メモリ割り当て失敗

View File

@@ -3,6 +3,9 @@ brightness_down = ronahiyê kêm bike
brightness_up = ronahiyê bilind bike
capslock = tîpên girdek (capslock)
custom = kesane
err_alloc = veqetandina bîrê têk çû
err_args = argumanên rêzika fermanê nehatin analîzkirin
err_autologin_session = danişîna têketina xweber nehate dîtin

View File

@@ -3,6 +3,9 @@ brightness_down = samazināt spilgtumu
brightness_up = palielināt spilgtumu
capslock = caps lock
custom = pielāgots
err_alloc = neizdevās atmiņas piešķiršana

View File

@@ -3,6 +3,9 @@ brightness_down = zmniejsz jasność
brightness_up = zwiększ jasność
capslock = capslock
custom = własny
err_alloc = nieudana alokacja pamięci
err_autologin_session = nie znaleziono sesji autologowania

View File

@@ -3,6 +3,9 @@
capslock = capslock
err_alloc = erro na atribuição de memória

View File

@@ -3,6 +3,9 @@
capslock = caixa alta
err_alloc = alocação de memória malsucedida

View File

@@ -22,6 +22,9 @@ capslock = capslock

View File

@@ -3,6 +3,9 @@ brightness_down = уменьшить яркость
brightness_up = увеличить яркость
capslock = capslock
custom = пользовательский
err_alloc = не удалось выделить память
err_autologin_session = не найдена сессия с автологином

View File

@@ -3,6 +3,9 @@
capslock = capslock
err_alloc = neuspijesna alokacija memorije

View File

@@ -3,6 +3,9 @@ brightness_down = minska ljusstyrka
brightness_up = öka ljusstyrka
capslock = capslock
custom = anpassad
err_alloc = minnesallokering misslyckades
err_args = tolkning av kommandoargument misslyckades
err_autologin_session = autologin-session hittades inte

View File

@@ -3,6 +3,9 @@ brightness_down = parlakligi azalt
brightness_up = parlakligi arttir
capslock = capslock
err_alloc = basarisiz bellek ayirma

View File

@@ -3,6 +3,9 @@
capslock = capslock
err_alloc = невдале виділення пам'яті

View File

@@ -3,6 +3,9 @@
capslock = 大写锁定
err_alloc = 内存分配失败