|
| 1 | +<!-- |
| 2 | +SPDX-FileCopyrightText: 2024 max-ishere |
| 3 | +
|
| 4 | +SPDX-License-Identifier: GPL-3.0-or-later |
| 5 | +--> |
| 6 | +# ReGreet configuration docs |
| 7 | + |
| 8 | +## Clock |
| 9 | + |
| 10 | +The clock widget can be customized to specify the |
| 11 | +[time display format](https://docs.rs/jiff/0.1.14/jiff/fmt/strtime/index.html#conversion-specifications), |
| 12 | +how often to update the clock, overrides to the system timezone and a custom fixed label width so that the non-monospace |
| 13 | +font does not cause annoying width changes in the UI. |
| 14 | + |
| 15 | +```toml |
| 16 | +[widget.clock] |
| 17 | +# strftime format argument |
| 18 | +format = "%a %H:%M" |
| 19 | + |
| 20 | +# How often to update the text |
| 21 | +resolution = "500ms" |
| 22 | + |
| 23 | +# Override system timezone (IANA Time Zone Database name, aka /etc/zoneinfo path) |
| 24 | +# Remove to use the system time zone. |
| 25 | +timezone = "America/Chicago" |
| 26 | + |
| 27 | +# Ask GTK to make the label at least this wide. This helps keeps the parent element layout and width consistent. |
| 28 | +# Experiment with different widths, the interpretation of this value is entirely up to GTK. |
| 29 | +label_width = 150 |
| 30 | +``` |
| 31 | + |
| 32 | +## Power menu |
| 33 | + |
| 34 | +The first step in configuring the power menu is to select the backend to use. The backend is specified as part of the |
| 35 | +path under `widget.power-menu.<backend>`. Please note that only 1 backend can be active at a time. |
| 36 | + |
| 37 | +For your convenience, most backends allow you to specify an action that is automatically translated into the supported |
| 38 | +languages. The correct icon is also selected. Actions that will poweroff your system will ask for confirmation before |
| 39 | +they are executed. The actions are listed in the table below. |
| 40 | + |
| 41 | +| Config value | Confirmation required | |
| 42 | +|-----------------|-----------------------| |
| 43 | +| poweroff | Yes | |
| 44 | +| halt | Yes | |
| 45 | +| reboot | Yes | |
| 46 | +| reboot-firmware | Yes | |
| 47 | +| suspend | No | |
| 48 | +| hibernate | No | |
| 49 | +| hybrid-sleep | No | |
| 50 | + |
| 51 | +The convention most backends' configs follow is having a single `actions` key, which is an array of actions. This simple |
| 52 | +structure allows you to easily add, remove, and reorder the buttons in the menu without having to verbosely specify all |
| 53 | +the attributes like you can do with the [custom](#custom) backend. |
| 54 | + |
| 55 | +### Systemd |
| 56 | + |
| 57 | +Machines using Systemd as the init system can specify the following line to use the default configuration. |
| 58 | + |
| 59 | +```toml |
| 60 | +[widget.power-menu.systemd] |
| 61 | +``` |
| 62 | + |
| 63 | +The displayed actions can be changed using the `actions` key. [See above](#power-menu) for more details |
| 64 | + |
| 65 | +```toml |
| 66 | +[widget.power-menu.systemd] |
| 67 | +actions = ["suspend", "poweroff", "reboot-firmware"] |
| 68 | +``` |
| 69 | + |
| 70 | +### Unix |
| 71 | + |
| 72 | +This backend should work on most systems as it does not use commands shipped with any specific init system. Instead, the |
| 73 | +Linux `shutdown` command is used. |
| 74 | + |
| 75 | +```toml |
| 76 | +[widget.power-menu.unix] |
| 77 | +``` |
| 78 | + |
| 79 | +> [!NOTE] |
| 80 | +> The only actions supported by this backend are poweroff, reboot, and halt. |
| 81 | +> |
| 82 | +> When other values are specified they are logged as warnings and silently skipped. |
| 83 | +
|
| 84 | +```toml |
| 85 | +[widget.power-menu.systemd] |
| 86 | +actions = ["poweroff", "reboot", "halt"] |
| 87 | +``` |
| 88 | + |
| 89 | +### Custom |
| 90 | + |
| 91 | +The custom backend allows you to fully customize the power menu. If none of the other backends suit your needs or |
| 92 | +require additional customizations, consider using this backend. |
| 93 | + |
| 94 | +It is necesary to set the `backend` key to the backend that you are implementing. The backend string can have any value |
| 95 | +and is only used as part of the label in the power menu. The actions can be specified in the `commands` key. |
| 96 | + |
| 97 | +The power menu button (as well as `commands`) has the following fields: |
| 98 | + |
| 99 | +- `String` Label |
| 100 | +- `String` Icon (optional) |
| 101 | +- `bool` Should this entry be confirmed? |
| 102 | +- `Vec<String>` Command to execute |
| 103 | + |
| 104 | +The label, icon and confirmation can be inferred by ReGreet automatically if you set the `action` field. |
| 105 | + |
| 106 | +```toml |
| 107 | +[widget.power-menu.custom] |
| 108 | +backend = "Custom" # Required value |
| 109 | + |
| 110 | +[[widget.power-menu.custom.commands]] |
| 111 | +action = "poweroff" |
| 112 | +command = ["shutdown", "--now"] |
| 113 | +# `action` Infers: |
| 114 | +# label = "..." ## NOTE: label and action are mutually exclusive |
| 115 | +# icon = "..." |
| 116 | +# confirm = ... |
| 117 | +``` |
| 118 | + |
| 119 | +Overrides (that are different from the action defaults) can be specified for the icon and the confirm, but not the |
| 120 | +label. The logic is that if you are specifying a custom label, you are likely also specifying a custom command that |
| 121 | +ReGreet does not know how to interpret into the inferable fields. |
| 122 | + |
| 123 | +The icon can be hidden altogether by setting it to an empty string. |
| 124 | + |
| 125 | +```toml |
| 126 | +[[widget.power-menu.custom.commands]] |
| 127 | +action = "poweroff" |
| 128 | +command = ["shutdown", "--now"] |
| 129 | +icon = "" # no icon |
| 130 | +confirm = false |
| 131 | +# Infers: |
| 132 | +# label = Poweroff" ## NOTE: label and action are mutually exclusive |
| 133 | +``` |
0 commit comments