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

Add check that looks if rofi is running inside rofi script mode.

This commit is contained in:
Dave Davenport 2020-05-21 09:35:55 +02:00
parent a4c5a92199
commit 3604b12fde
3 changed files with 20 additions and 1 deletions

View file

@ -1,5 +1,9 @@
#!/usr/bin/env bash
if [ -z "${ROFI_OUTSIDE}" ]
then
echo "run this script in rofi".
exit
fi
echo -en "\x00no-custom\x1ftrue\n"
echo "${ROFI_RETV}"

View file

@ -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);
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 ) ) {
argv = g_realloc ( argv, ( argc + 2 ) * sizeof ( char* ) );

View file

@ -788,6 +788,17 @@ int main ( int argc, char *argv[] )
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.
// This has two possible causes.
// 1 the user specifies it on the command-line.