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

[lexer] Add dmenu as enabled option for media type.

fixes: #1903
This commit is contained in:
Dave Davenport 2023-10-03 21:06:53 +02:00
parent a6d297591e
commit c78179dcc8
9 changed files with 38 additions and 9 deletions

View file

@ -2206,7 +2206,8 @@ It supports the following keys as constraint:
.IP \(bu 2 .IP \(bu 2
\fB\fCmonitor-id\fR: The monitor id, see rofi -help for id's. \fB\fCmonitor-id\fR: The monitor id, see rofi -help for id's.
.IP \(bu 2 .IP \(bu 2
\fB\fCenabled\fR: Boolean option to enable. Supports environment variable. \fB\fCenabled\fR: Boolean option to enable. Supports environment variable
or DMENU to detect if in dmenu mode.
.RE .RE
@ -2229,7 +2230,18 @@ added.
.RS .RS
.nf .nf
@media ( enabled: env(DO_LIGHT, false ) { @media ( enabled: env(DO_LIGHT, false )) {
}
.fi
.RE
.PP
.RS
.nf
@media ( enabled: DMENU) {
} }

View file

@ -1497,7 +1497,8 @@ It supports the following keys as constraint:
- `min-aspect-ratio` load when aspect ratio is over value. - `min-aspect-ratio` load when aspect ratio is over value.
- `max-aspect-ratio`: load when aspect ratio is under value. - `max-aspect-ratio`: load when aspect ratio is under value.
- `monitor-id`: The monitor id, see rofi -help for id's. - `monitor-id`: The monitor id, see rofi -help for id's.
- `enabled`: Boolean option to enable. Supports environment variable. - `enabled`: Boolean option to enable. Supports environment variable
or DMENU to detect if in dmenu mode.
@media takes an integer number or a fraction, for integer number `px` can be @media takes an integer number or a fraction, for integer number `px` can be
added. added.
@ -1509,7 +1510,13 @@ added.
``` ```
```css ```css
@media ( enabled: env(DO_LIGHT, false ) { @media ( enabled: env(DO_LIGHT, false )) {
}
```
```css
@media ( enabled: DMENU) {
} }
``` ```

View file

@ -49,6 +49,7 @@
#define LOG_DOMAIN "Parser" #define LOG_DOMAIN "Parser"
int last_state = 0; int last_state = 0;
extern int rofi_is_in_dmenu_mode;
const char *rasi_theme_file_extensions[] = {".rasi", ".rasinc", NULL}; const char *rasi_theme_file_extensions[] = {".rasi", ".rasinc", NULL};
/** /**
@ -298,6 +299,8 @@ CONFIGURATION (?i:configuration)
MEDIA_TYPES (monitor-id|(min|max)-(width|height|aspect-ratio)|enabled) MEDIA_TYPES (monitor-id|(min|max)-(width|height|aspect-ratio)|enabled)
DMENU (?i:dmenu)
%x INCLUDE %x INCLUDE
%x PROPERTIES %x PROPERTIES
%x PROPERTIES_ENV %x PROPERTIES_ENV
@ -513,6 +516,7 @@ if ( queue == NULL ) {
<SECTION>":" { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(PROPERTIES); return T_PSEP; } <SECTION>":" { g_queue_push_head ( queue, GINT_TO_POINTER (YY_START) ); BEGIN(PROPERTIES); return T_PSEP; }
<PROPERTIES>";" { BEGIN(GPOINTER_TO_INT ( g_queue_pop_head ( queue ))); return T_PCLOSE;} <PROPERTIES>";" { BEGIN(GPOINTER_TO_INT ( g_queue_pop_head ( queue ))); return T_PCLOSE;}
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT,MEDIA_ENV_VAR_CONTENT,MEDIA_ENV_VAR_DEFAULT>(true|false) { yylval->bval= g_strcmp0(yytext, "true") == 0; return T_BOOLEAN;} <PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT,MEDIA_ENV_VAR_CONTENT,MEDIA_ENV_VAR_DEFAULT>(true|false) { yylval->bval= g_strcmp0(yytext, "true") == 0; return T_BOOLEAN;}
<MEDIA_CONTENT>{DMENU} { yylval->bval = rofi_is_in_dmenu_mode; return T_BOOLEAN;}
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT,MEDIA_CONTENT>{NUMBER}\.{NUMBER} { yylval->fval = g_ascii_strtod(yytext, NULL); return T_DOUBLE;} <PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT,MEDIA_CONTENT>{NUMBER}\.{NUMBER} { yylval->fval = g_ascii_strtod(yytext, NULL); return T_DOUBLE;}
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT,MEDIA_CONTENT>{NUMBER} { yylval->ival = (int)g_ascii_strtoll(yytext, NULL, 10); return T_INT;} <PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT,MEDIA_CONTENT>{NUMBER} { yylval->ival = (int)g_ascii_strtoll(yytext, NULL, 10); return T_INT;}
<PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT,MEDIA_CONTENT>{UNARYMIN} { return T_MIN; } <PROPERTIES,PROPERTIES_ARRAY,PROPERTIES_ENV,PROPERTIES_VAR_DEFAULT,MEDIA_CONTENT>{UNARYMIN} { return T_MIN; }

View file

@ -139,7 +139,7 @@ NkBindings *bindings = NULL;
GMainLoop *main_loop = NULL; GMainLoop *main_loop = NULL;
/** Flag indicating we are in dmenu mode. */ /** Flag indicating we are in dmenu mode. */
static int dmenu_mode = FALSE; int rofi_is_in_dmenu_mode = FALSE;
/** Rofi's return code */ /** Rofi's return code */
int return_code = EXIT_SUCCESS; int return_code = EXIT_SUCCESS;
@ -789,7 +789,7 @@ static gboolean startup(G_GNUC_UNUSED gpointer data) {
} }
} }
// Dmenu mode. // Dmenu mode.
if (dmenu_mode == TRUE) { if (rofi_is_in_dmenu_mode == TRUE) {
// force off sidebar mode: // force off sidebar mode:
config.sidebar_mode = FALSE; config.sidebar_mode = FALSE;
int retv = dmenu_mode_dialog(); int retv = dmenu_mode_dialog();
@ -936,14 +936,14 @@ int main(int argc, char *argv[]) {
// This has two possible causes. // This has two possible causes.
// 1 the user specifies it on the command-line. // 1 the user specifies it on the command-line.
if (find_arg("-dmenu") >= 0) { if (find_arg("-dmenu") >= 0) {
dmenu_mode = TRUE; rofi_is_in_dmenu_mode = TRUE;
} }
// 2 the binary that executed is called dmenu (e.g. symlink to rofi) // 2 the binary that executed is called dmenu (e.g. symlink to rofi)
else { else {
// Get the base name of the executable called. // Get the base name of the executable called.
char *base_name = g_path_get_basename(argv[0]); char *base_name = g_path_get_basename(argv[0]);
const char *const dmenu_str = "dmenu"; const char *const dmenu_str = "dmenu";
dmenu_mode = (strcmp(base_name, dmenu_str) == 0); rofi_is_in_dmenu_mode = (strcmp(base_name, dmenu_str) == 0);
// Free the basename for dmenu detection. // Free the basename for dmenu detection.
g_free(base_name); g_free(base_name);
} }
@ -1103,7 +1103,7 @@ int main(int argc, char *argv[]) {
/** dirty hack for dmenu compatibility */ /** dirty hack for dmenu compatibility */
char *windowid = NULL; char *windowid = NULL;
if (!dmenu_mode) { if (!rofi_is_in_dmenu_mode) {
// setup_modes // setup_modes
if (setup_modes()) { if (setup_modes()) {
cleanup(); cleanup();

View file

@ -41,6 +41,7 @@
#include <widgets/widget-internal.h> #include <widgets/widget-internal.h>
#include <widgets/widget.h> #include <widgets/widget.h>
unsigned int test = 0; unsigned int test = 0;
int rofi_is_in_dmenu_mode = 0;
#define TASSERT(a) \ #define TASSERT(a) \
{ \ { \
assert(a); \ assert(a); \

View file

@ -59,6 +59,7 @@ unsigned int test = 0;
} \ } \
} }
int rofi_is_in_dmenu_mode = 0;
ThemeWidget *rofi_configuration = NULL; ThemeWidget *rofi_configuration = NULL;
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name, uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,

View file

@ -46,6 +46,7 @@
#include "rofi-icon-fetcher.h" #include "rofi-icon-fetcher.h"
static int test = 0; static int test = 0;
unsigned int normal_window_mode = 0; unsigned int normal_window_mode = 0;
int rofi_is_in_dmenu_mode = 0;
#define TASSERT(a) \ #define TASSERT(a) \
{ \ { \

View file

@ -47,6 +47,8 @@
#define REAL_COMPARE_DELTA 0.001 #define REAL_COMPARE_DELTA 0.001
int rofi_is_in_dmenu_mode = 0;
uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name, uint32_t rofi_icon_fetcher_query(G_GNUC_UNUSED const char *name,
G_GNUC_UNUSED const int size) { G_GNUC_UNUSED const int size) {
return 0; return 0;

View file

@ -40,6 +40,7 @@
#include <widgets/widget-internal.h> #include <widgets/widget-internal.h>
#include <widgets/widget.h> #include <widgets/widget.h>
unsigned int test = 0; unsigned int test = 0;
int rofi_is_in_dmenu_mode = 0;
#define TASSERT(a) \ #define TASSERT(a) \
{ \ { \
assert(a); \ assert(a); \