mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-11 13:50:48 -05:00
Add check that looks if rofi is running inside rofi script mode.
This commit is contained in:
parent
a4c5a92199
commit
3604b12fde
3 changed files with 20 additions and 1 deletions
|
@ -1,5 +1,9 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [ -z "${ROFI_OUTSIDE}" ]
|
||||||
|
then
|
||||||
|
echo "run this script in rofi".
|
||||||
|
exit
|
||||||
|
fi
|
||||||
echo -en "\x00no-custom\x1ftrue\n"
|
echo -en "\x00no-custom\x1ftrue\n"
|
||||||
echo "${ROFI_RETV}"
|
echo "${ROFI_RETV}"
|
||||||
|
|
|
@ -157,6 +157,10 @@ static DmenuScriptEntry *execute_executor ( Mode *sw, char *arg, unsigned int *l
|
||||||
env = g_environ_setenv ( env, "ROFI_RETV", str_value, TRUE);
|
env = g_environ_setenv ( env, "ROFI_RETV", str_value, TRUE);
|
||||||
g_free ( str_value );
|
g_free ( str_value );
|
||||||
|
|
||||||
|
str_value = g_strdup_printf("%d", (int) getpid());
|
||||||
|
env = g_environ_setenv ( env, "ROFI_OUTSIDE", str_value, TRUE);
|
||||||
|
g_free ( str_value );
|
||||||
|
|
||||||
|
|
||||||
if ( g_shell_parse_argv ( sw->ed, &argc, &argv, &error ) ) {
|
if ( g_shell_parse_argv ( sw->ed, &argc, &argv, &error ) ) {
|
||||||
argv = g_realloc ( argv, ( argc + 2 ) * sizeof ( char* ) );
|
argv = g_realloc ( argv, ( argc + 2 ) * sizeof ( char* ) );
|
||||||
|
|
|
@ -788,6 +788,17 @@ int main ( int argc, char *argv[] )
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const char *ro_pid = g_getenv("ROFI_OUTSIDE");
|
||||||
|
if ( ro_pid != NULL ) {
|
||||||
|
int ro_pidi = g_ascii_strtoll ( ro_pid, NULL, 0 );
|
||||||
|
if ( kill ( ro_pidi, 0 ) == 0 ) {
|
||||||
|
printf ( "Do not launch rofi from inside rofi.\r\n" );
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Detect if we are in dmenu mode.
|
// Detect if we are in dmenu mode.
|
||||||
// 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.
|
||||||
|
|
Loading…
Reference in a new issue