mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
osd: add desktop entry name option
Looks desktop entry name up from libsfdo.
This commit is contained in:
parent
57aee700f7
commit
7b5c76d573
3 changed files with 33 additions and 0 deletions
|
|
@ -270,6 +270,9 @@ this is for compatibility with Openbox.
|
|||
- *trimmed_identifier* Show trimmed identifier. Trimming removes
|
||||
the first two nodes of 'org.' strings.
|
||||
|
||||
- *desktop_entry_name* Show application name from freedesktop.org desktop
|
||||
entry/file. Falls back to trimmed identifier (trimmed_identifier).
|
||||
|
||||
- *title* Show window title if different to app_id
|
||||
|
||||
- *workspace* Show workspace name
|
||||
|
|
@ -289,6 +292,8 @@ this is for compatibility with Openbox.
|
|||
- 's' - state of window (short form), values [M|m|F] (1 space)
|
||||
- 'I' - wm-class/app-id
|
||||
- 'i' - wm-class/app-id trimmed, remove "org." if available
|
||||
- 'n' - desktop entry/file application name, falls back to
|
||||
wm-class/app-id trimmed
|
||||
- 'W' - workspace name
|
||||
- 'w' - workspace name (if more than 1 ws configured)
|
||||
- 'O' - output name
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ enum window_switcher_field_content {
|
|||
LAB_FIELD_TYPE_SHORT,
|
||||
LAB_FIELD_IDENTIFIER,
|
||||
LAB_FIELD_TRIMMED_IDENTIFIER,
|
||||
LAB_FIELD_DESKTOP_ENTRY_NAME,
|
||||
LAB_FIELD_TITLE,
|
||||
LAB_FIELD_TITLE_SHORT,
|
||||
LAB_FIELD_WORKSPACE,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@
|
|||
#include "view.h"
|
||||
#include "workspaces.h"
|
||||
#include "labwc.h"
|
||||
#if HAVE_LIBSFDO
|
||||
#include "desktop-entry.h"
|
||||
#endif
|
||||
#include "osd.h"
|
||||
|
||||
/* includes '%', terminating 's' and NULL byte, 8 is enough for %-9999s */
|
||||
|
|
@ -44,6 +47,20 @@ get_app_id_or_class(struct view *view, bool trim)
|
|||
return identifier;
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_desktop_name(struct view *view)
|
||||
{
|
||||
#if HAVE_LIBSFDO
|
||||
const char *app_id = view_get_string_prop(view, "app_id");
|
||||
const char *name = desktop_entry_name_lookup(view->server, app_id);
|
||||
if (name) {
|
||||
return name;
|
||||
}
|
||||
#endif
|
||||
|
||||
return get_app_id_or_class(view, /* trim */ true);
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_type(struct view *view, bool short_form)
|
||||
{
|
||||
|
|
@ -164,6 +181,13 @@ field_set_identifier_trimmed(struct buf *buf, struct view *view, const char *for
|
|||
buf_add(buf, get_app_id_or_class(view, /*trim*/ true));
|
||||
}
|
||||
|
||||
static void
|
||||
field_set_desktop_entry_name(struct buf *buf, struct view *view, const char *format)
|
||||
{
|
||||
/* custom type conversion-specifier: n */
|
||||
buf_add(buf, get_desktop_name(view));
|
||||
}
|
||||
|
||||
static void
|
||||
field_set_title(struct buf *buf, struct view *view, const char *format)
|
||||
{
|
||||
|
|
@ -263,6 +287,7 @@ static const struct field_converter field_converter[LAB_FIELD_COUNT] = {
|
|||
[LAB_FIELD_WIN_STATE] = { 's', field_set_win_state },
|
||||
[LAB_FIELD_IDENTIFIER] = { 'I', field_set_identifier },
|
||||
[LAB_FIELD_TRIMMED_IDENTIFIER] = { 'i', field_set_identifier_trimmed },
|
||||
[LAB_FIELD_DESKTOP_ENTRY_NAME] = { 'n', field_set_desktop_entry_name},
|
||||
[LAB_FIELD_WORKSPACE] = { 'W', field_set_workspace },
|
||||
[LAB_FIELD_WORKSPACE_SHORT] = { 'w', field_set_workspace_short },
|
||||
[LAB_FIELD_OUTPUT] = { 'O', field_set_output },
|
||||
|
|
@ -296,6 +321,8 @@ osd_field_arg_from_xml_node(struct window_switcher_field *field,
|
|||
field->content = LAB_FIELD_IDENTIFIER;
|
||||
} else if (!strcmp(content, "trimmed_identifier")) {
|
||||
field->content = LAB_FIELD_TRIMMED_IDENTIFIER;
|
||||
} else if (!strcmp(content, "desktop_entry_name")) {
|
||||
field->content = LAB_FIELD_DESKTOP_ENTRY_NAME;
|
||||
} else if (!strcmp(content, "title")) {
|
||||
/* Keep old defaults */
|
||||
field->content = LAB_FIELD_TITLE_SHORT;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue