-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add Menu module #609
base: master
Are you sure you want to change the base?
Changes from all commits
9eb4c84
e3cde95
cfe2d45
3db7dd9
2acc1f5
72376a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
Application menu that shows installed programs and optionally custom entries. Clicking the menu button will open the main menu, clicking on any application category will open a sub-menu with any installed applications that match. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reminder for myself to add an image (no need to action anything) |
||
## Configuration | ||
|
||
> Type: `menu` | ||
|
||
| | Type | Default | Description | | ||
|--------------|------------|---------|-----------------------------------------------------------------------------------------------------| | ||
| `start` | `MenuEntry[]` | `[]` | List of menu entries | | ||
| `center` | `MenuEntry[]` | default XDG menu | List of menu entries. By default this shows a number of XDG entries that should cover all common applications | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you set this, does it append to or replace the XDG entries? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will replace the default entries. It might be worthwhile to list the default entries in the documentation in case you want some of them but not others. |
||
| `end` | `MenuEntry[]` | `[]` | List of menu entries | | ||
| `height` | `integer | null` | `null` | The height of the menu, leave null for it to resize dynamically | | ||
| `width` | `integer | null` | `null` | The width of the menu, leave null for it to resize dynamically | | ||
| `max_label_length` | `integer` | `25` | Maximum length for the label of an XDG entry | | ||
| `label` | `string | null` | `≡` | The label of the button that opens the menu | | ||
| `label_icon` | `string | null` | `null` | An icon (from icon theme) to display on the button which opens the application menu | | ||
| `label_icon_size` | `integer` | `16` | Size of the label_icon if one is supplied | | ||
|
||
|
||
> Type: `MenuEntry` | ||
|
||
| | Type | Default | Description | | ||
|--------------|------------|---------|-----------------------------------------------------------------------------------------------------| | ||
| `type` | `xdg_entry | xdg_other | custom` | | Type of the entry | | ||
| `label` | `string` | | Label of the entry's button | | ||
| `icon` | `string | null` | `null` | Icon for the entry's button | | ||
| `categories` | `string[]` | | If `xdg_entry` this is is the list of freedesktop.org categories to include in this entry's sub menu | | ||
| `on_click` | `string` | | If `custom` this is a shell command to execute when the entry's button is clicked | | ||
|
||
<details> | ||
|
||
<summary>JSON</summary> | ||
|
||
```json | ||
{ | ||
"start": [ | ||
{ | ||
"type": "menu", | ||
"start": [ | ||
{ | ||
"type": "custom", | ||
"label": "Terminal", | ||
"on_click": "xterm", | ||
} | ||
], | ||
"height": 440, | ||
"width": 200, | ||
"icon": "archlinux", | ||
"label": null | ||
} | ||
] | ||
} | ||
|
||
|
||
``` | ||
|
||
</details> | ||
|
||
<details> | ||
<summary>TOML</summary> | ||
|
||
```toml | ||
[[start.menu]] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not actually sure this is correct, the way ironbar handles TOML is a bit confusing to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ironbar is just using the standard Generally I write the corn config and then use its CLI to generate the other three formats, which isn't necessarily the most readable but at least ensures they're valid. I think here, you actually want something like (shortened and untested): [[start]]
type = "menu"
[[start.start]]
type = "custom" |
||
height = 400 | ||
width = 200 | ||
icon = "archlinux" | ||
label = null | ||
|
||
[[start.menu.start]] | ||
type = "custom" | ||
label = "Terminal" | ||
on_click = "xterm" | ||
``` | ||
|
||
</details> | ||
|
||
<details> | ||
<summary>YAML</summary> | ||
|
||
```yaml | ||
start: | ||
- type: "menu" | ||
start: | ||
- type: custom | ||
label: Terminal | ||
on_click: xterm | ||
height: 440 | ||
width: 200 | ||
icon: archlinux | ||
label: null | ||
``` | ||
|
||
</details> | ||
|
||
<details> | ||
<summary>Corn</summary> | ||
|
||
```corn | ||
{ | ||
start = [ | ||
{ | ||
type = "menu" | ||
start = [ | ||
{ | ||
type = "custom" | ||
label = "Terminal" | ||
on_click = "xterm" | ||
} | ||
] | ||
height = 440 | ||
width = 200 | ||
icon = "archlinux" | ||
label = null | ||
} | ||
] | ||
} | ||
``` | ||
|
||
</details> | ||
|
||
## Styling | ||
|
||
| Selector | Description | | ||
|-------------------------------|--------------------------------| | ||
| `.menu` | Menu button | | ||
| `.menu-popup` | Main container of the popup | | ||
| `.menu-popup_main` | Main menu of the menu | | ||
| `.menu-popup_main_start` | Container for `start` entries | | ||
| `.menu-popup_main_center` | Container for `center` entries | | ||
| `.menu-popup_main_end` | Container for `end` entries | | ||
| `.menu-popup_sub-menu` | All sub-menues | | ||
|
||
For more information on styling, please see the [styling guide](styling-guide). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
freedesktop_entry_parser is needed to parse .desktop entries which it doesn't seem ironbar was doing until now. There's one other rust library that can do that but this one seemed lighter-weight and more stable.
unicode-segmentation is needed for truncating menu entries which is really needed because some common .desktop files (like the JDK) have really long names. As far as I can tell there's no actually safe way to truncate unicode strings in the Rust stdlib.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is .desktop file parsing happening in the
desktop_file
module already. Did you not spot that, or does that not do what is necessary here?In some other modules (
music
,focused
) these are already using a (partially) commontruncate
option that hooks into GTK's in-built truncation/elipsize system. I'd prefer to use that here, although I'm open to integratingunicode-segmentation
and having awords
mode there.