1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

[script|dmenu] Add option to make row permanent.

fixes: #1952
This commit is contained in:
Dave Davenport 2024-02-28 20:47:18 +01:00
parent f2c0f75fd2
commit afc65ac125
6 changed files with 45 additions and 25 deletions

View file

@ -1,32 +1,29 @@
#!/usr/bin/env bash
if [ "$*" = "quit" ]
then
exit 0
if [ "$*" = "quit" ]; then
exit 0
fi
if [ "$@" ]
then
# Override the previously set prompt.
echo -en "\x00prompt\x1fChange prompt\n"
for a in {1..10}
do
echo "$a"
done
echo "quit"
if [ "$@" ]; then
# Override the previously set prompt.
echo -en "\x00prompt\x1fChange prompt\n"
for a in {1..10}; do
echo "$a"
done
echo "quit"
else
echo -en "\x00prompt\x1ftesting\n"
echo -en "\0urgent\x1f0,2\n"
echo -en "\0active\x1f1\n"
echo -en "\0markup-rows\x1ftrue\n"
echo -en "\0message\x1fSpecial <b>bold</b>message\n"
echo -en "\x00prompt\x1ftesting\n"
echo -en "\0urgent\x1f0,2\n"
echo -en "\0active\x1f1\n"
echo -en "\0markup-rows\x1ftrue\n"
echo -en "\0message\x1fSpecial <b>bold</b>message\n"
echo -en "aap\0icon\x1ffolder\n"
echo -en "blob\0icon\x1ffolder\x1fdisplay\x1fblub\n"
echo "noot"
echo "mies"
echo -en "-------------\0nonselectable\x1ftrue\n"
echo "testing"
echo "<b>Bold</b>"
echo "quit"
echo -en "aap\0icon\x1ffolder\n"
echo -en "blob\0icon\x1ffolder\x1fdisplay\x1fblub\n"
echo "noot"
echo "mies"
echo -en "-------------\0nonselectable\x1ftrue\x1fpermanent\x1ftrue\n"
echo "testing"
echo "<b>Bold</b>"
echo "quit"
fi

View file

@ -185,6 +185,8 @@ The following options are supported:
.IP \(bu 2
\fBnonselectable\fP: If true the row cannot activated.
.IP \(bu 2
\fBpermantent\fP: If true the row always shows, independent of filter.
.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 for filtering.
.IP \(bu 2

View file

@ -143,6 +143,8 @@ The following options are supported:
- **nonselectable**: If true the row cannot activated.
- **permantent**: If true the row always shows, independent of filter.
- **info**: Info that, on selection, gets placed in the `ROFI_INFO`
environment variable. This entry does not get searched for filtering.

View file

@ -26,6 +26,9 @@ typedef struct {
/** non-selectable */
gboolean nonselectable;
/** permanent */
gboolean permanent;
/** urgent */
gboolean urgent;
/** active */

View file

@ -139,6 +139,7 @@ static void read_add_block(DmenuModePrivateData *pd, Block **block, char *data,
(*block)->values[(*block)->length].meta = NULL;
(*block)->values[(*block)->length].info = NULL;
(*block)->values[(*block)->length].nonselectable = FALSE;
(*block)->values[(*block)->length].permanent = FALSE;
char *end = data;
while (end < data + len && *end != '\0') {
end++;
@ -668,6 +669,11 @@ static int dmenu_token_match(const Mode *sw, rofi_int_matcher **tokens,
/** Strip out the markup when matching. */
char *esc = NULL;
if (rmpd->cmd_list[index].permanent == TRUE) {
// Always match
return 1;
}
if (rmpd->do_markup) {
pango_parse_markup(rmpd->cmd_list[index].entry, -1, 0, NULL, &esc, NULL,
NULL);

View file

@ -101,6 +101,9 @@ void dmenuscript_parse_entry_extras(G_GNUC_UNUSED Mode *sw,
} else if (strcasecmp(key, "nonselectable") == 0) {
entry->nonselectable = g_ascii_strcasecmp(value, "true") == 0;
g_free(value);
} else if (strcasecmp(key, "permanent") == 0) {
entry->permanent = 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);
@ -252,6 +255,7 @@ static DmenuScriptEntry *execute_executor(Mode *sw, char *arg,
retv[(*length)].icon_fetch_uid = 0;
retv[(*length)].icon_fetch_size = 0;
retv[(*length)].nonselectable = FALSE;
retv[(*length)].permanent = FALSE;
if (buf_length > 0 && (read_length > (ssize_t)buf_length)) {
dmenuscript_parse_entry_extras(sw, &(retv[(*length)]),
buffer + buf_length,
@ -454,6 +458,12 @@ static int script_token_match(const Mode *sw, rofi_int_matcher **tokens,
ScriptModePrivateData *rmpd = sw->private_data;
/** Strip out the markup when matching. */
char *esc = NULL;
if (rmpd->cmd_list[index].permanent == TRUE) {
// Always match
return 1;
}
if (rmpd->do_markup) {
pango_parse_markup(rmpd->cmd_list[index].entry, -1, 0, NULL, &esc, NULL,
NULL);