summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2023-01-08 12:10:40 +0100
committerDave Davenport <qball@gmpclient.org>2023-01-08 12:10:40 +0100
commit9fda280be1f7416672740b382203342f16328464 (patch)
tree6b5764424542d3227437693497e581df21ae7e7e
parent236c12bfb2999e56ee9e177176472f9f2701be42 (diff)
[DMenu|Script] Add per row urgent/active option.
Instead of having a global list of entries to highlight urgent/active, you can now to it per row.
-rw-r--r--doc/rofi-script.54
-rw-r--r--doc/rofi-script.5.markdown2
-rw-r--r--include/modes/dmenuscriptshared.h5
-rw-r--r--source/modes/dmenu.c8
-rw-r--r--source/modes/script.c16
5 files changed, 34 insertions, 1 deletions
diff --git a/doc/rofi-script.5 b/doc/rofi-script.5
index 6e8b9b17..2e7f22f2 100644
--- a/doc/rofi-script.5
+++ b/doc/rofi-script.5
@@ -165,6 +165,10 @@ The following options are supported:
\fBnonselectable\fP: If true the row cannot activated.
.IP \(bu 2
\fBinfo\fP: Info that, on selection, gets placed in the \fB\fCROFI_INFO\fR environment variable. This entry does not get searched.
+.IP \(bu 2
+\fBurgent\fP: Set urgent flag on entry (true/false)
+.IP \(bu 2
+\fBactive\fP: Set active flag on entry (true/false)
.RE
diff --git a/doc/rofi-script.5.markdown b/doc/rofi-script.5.markdown
index d021f781..a8e663ee 100644
--- a/doc/rofi-script.5.markdown
+++ b/doc/rofi-script.5.markdown
@@ -112,6 +112,8 @@ The following options are supported:
* **meta**: Specify invisible search terms.
* **nonselectable**: If true the row cannot activated.
* **info**: Info that, on selection, gets placed in the `ROFI_INFO` environment variable. This entry does not get searched.
+ * **urgent**: Set urgent flag on entry (true/false)
+ * **active**: Set active flag on entry (true/false)
multiple entries can be passed using the `\x1f` separator.
diff --git a/include/modes/dmenuscriptshared.h b/include/modes/dmenuscriptshared.h
index a1808d21..e40e2954 100644
--- a/include/modes/dmenuscriptshared.h
+++ b/include/modes/dmenuscriptshared.h
@@ -21,6 +21,11 @@ typedef struct {
/** non-selectable */
gboolean nonselectable;
+
+ /** urgent */
+ gboolean urgent;
+ /** active */
+ gboolean active;
} DmenuScriptEntry;
/**
* @param sw Unused
diff --git a/source/modes/dmenu.c b/source/modes/dmenu.c
index e6245013..4bab2c2f 100644
--- a/source/modes/dmenu.c
+++ b/source/modes/dmenu.c
@@ -168,6 +168,8 @@ static void read_add(DmenuModePrivateData *pd, char *data, gsize len) {
pd->cmd_list[pd->cmd_list_length].icon_name = NULL;
pd->cmd_list[pd->cmd_list_length].meta = NULL;
pd->cmd_list[pd->cmd_list_length].info = NULL;
+ pd->cmd_list[pd->cmd_list_length].active = FALSE;
+ pd->cmd_list[pd->cmd_list_length].urgent = FALSE;
pd->cmd_list[pd->cmd_list_length].nonselectable = FALSE;
char *end = data;
while (end < data + len && *end != '\0') {
@@ -448,6 +450,12 @@ static char *get_display_data(const Mode *data, unsigned int index, int *state,
if (pd->do_markup) {
*state |= MARKUP;
}
+ if ( pd->cmd_list[index].urgent ) {
+ *state |= URGENT;
+ }
+ if ( pd->cmd_list[index].active ) {
+ *state |= ACTIVE;
+ }
char *my_retv =
(get_entry ? dmenu_format_output_string(pd, retv[index].entry, index,
pd->multi_select)
diff --git a/source/modes/script.c b/source/modes/script.c
index 5e2131de..4e152565 100644
--- a/source/modes/script.c
+++ b/source/modes/script.c
@@ -94,7 +94,13 @@ void dmenuscript_parse_entry_extras(G_GNUC_UNUSED Mode *sw,
} else if (strcasecmp(key, "info") == 0) {
entry->info = value;
} else if (strcasecmp(key, "nonselectable") == 0) {
- entry->nonselectable = strcasecmp(value, "true") == 0;
+ entry->nonselectable = g_ascii_strcasecmp(value, "true") == 0;
+ g_free(value);
+ } else if (strcasecmp(key, "urgent") == 0) {
+ entry->urgent = g_ascii_strcasecmp(value, "true") == 0;
+ g_free(value);
+ } else if (strcasecmp(key, "active") == 0) {
+ entry->active = g_ascii_strcasecmp(value, "true") == 0;
g_free(value);
} else {
g_free(value);
@@ -231,6 +237,8 @@ static DmenuScriptEntry *execute_executor(Mode *sw, char *arg,
retv[(*length)].icon_name = NULL;
retv[(*length)].meta = NULL;
retv[(*length)].info = NULL;
+ retv[(*length)].active = FALSE;
+ retv[(*length)].urgent = FALSE;
retv[(*length)].icon_fetch_uid = 0;
retv[(*length)].icon_fetch_size = 0;
retv[(*length)].nonselectable = FALSE;
@@ -413,6 +421,12 @@ static char *_get_display_value(const Mode *sw, unsigned int selected_line,
*state |= URGENT;
}
}
+ if ( pd->cmd_list[selected_line].urgent ) {
+ *state |= URGENT;
+ }
+ if ( pd->cmd_list[selected_line].active ) {
+ *state |= ACTIVE;
+ }
if (pd->do_markup) {
*state |= MARKUP;
}