Skip to content

Commit 34b8d40

Browse files
committed
use system() rather than popen() in FunKey menu
Signed-off-by: Michel-FK <[email protected]>
1 parent e06aedd commit 34b8d40

File tree

1 file changed

+6
-36
lines changed

1 file changed

+6
-36
lines changed

fk_menu.c

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,6 @@ int FK_RunMenu(SDL_Surface *screen)
867867
int start_scroll=0;
868868
uint8_t screen_refresh = 1;
869869
char shell_cmd[100];
870-
FILE *fp;
871870
uint8_t menu_confirmation = 0;
872871
stop_menu_loop = 0;
873872
#ifdef HAS_MENU_THEME
@@ -1012,11 +1011,7 @@ int FK_RunMenu(SDL_Surface *screen)
10121011

10131012
/// ----- Shell cmd ----
10141013
sprintf(shell_cmd, "%s %d", SHELL_CMD_VOLUME_SET, volume_percentage);
1015-
fp = popen(shell_cmd, "r");
1016-
if (fp == NULL) {
1017-
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
1018-
}
1019-
pclose(fp);
1014+
system(shell_cmd);
10201015

10211016
/// ------ Refresh screen ------
10221017
screen_refresh = 1;
@@ -1031,11 +1026,7 @@ int FK_RunMenu(SDL_Surface *screen)
10311026

10321027
/// ----- Shell cmd ----
10331028
sprintf(shell_cmd, "%s %d", SHELL_CMD_BRIGHTNESS_SET, brightness_percentage);
1034-
fp = popen(shell_cmd, "r");
1035-
if (fp == NULL) {
1036-
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
1037-
}
1038-
pclose(fp);
1029+
system(shell_cmd);
10391030

10401031
/// ------ Refresh screen ------
10411032
screen_refresh = 1;
@@ -1089,11 +1080,7 @@ int FK_RunMenu(SDL_Surface *screen)
10891080

10901081
/// ----- Shell cmd ----
10911082
sprintf(shell_cmd, "%s %d", SHELL_CMD_VOLUME_SET, volume_percentage);
1092-
fp = popen(shell_cmd, "r");
1093-
if (fp == NULL) {
1094-
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
1095-
}
1096-
pclose(fp);
1083+
system(shell_cmd);
10971084

10981085
/// ------ Refresh screen ------
10991086
screen_refresh = 1;
@@ -1108,11 +1095,7 @@ int FK_RunMenu(SDL_Surface *screen)
11081095

11091096
/// ----- Shell cmd ----
11101097
sprintf(shell_cmd, "%s %d", SHELL_CMD_BRIGHTNESS_SET, brightness_percentage);
1111-
fp = popen(shell_cmd, "r");
1112-
if (fp == NULL) {
1113-
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
1114-
}
1115-
pclose(fp);
1098+
system(shell_cmd);
11161099

11171100
/// ------ Refresh screen ------
11181101
screen_refresh = 1;
@@ -1201,15 +1184,7 @@ int FK_RunMenu(SDL_Surface *screen)
12011184
menu_screen_refresh(screen, menuItem, prevItem, scroll, menu_confirmation, 1);
12021185

12031186
/// ----- Shell cmd ----
1204-
/*fp = popen(usb_sharing?SHELL_CMD_USB_UNMOUNT:SHELL_CMD_USB_MOUNT, "r");
1205-
if (fp == NULL) {
1206-
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
1207-
}
1208-
else{
1209-
pclose(fp);
1210-
usb_sharing = !usb_sharing;
1211-
}*/
1212-
1187+
/*system(usb_sharing?SHELL_CMD_USB_UNMOUNT:SHELL_CMD_USB_MOUNT);*/
12131188
bool res = Utils::executeRawPath(usb_sharing?SHELL_CMD_USB_UNMOUNT:SHELL_CMD_USB_MOUNT);
12141189
if (!res) {
12151190
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
@@ -1302,12 +1277,7 @@ int FK_RunMenu(SDL_Surface *screen)
13021277
menu_screen_refresh(screen, menuItem, prevItem, scroll, menu_confirmation, 1);
13031278

13041279
/// ----- Shell cmd ----
1305-
sprintf(shell_cmd, "%s", SHELL_CMD_POWERDOWN);
1306-
fp = popen(shell_cmd, "r");
1307-
if (fp == NULL) {
1308-
MENU_ERROR_PRINTF("Failed to run command %s\n", shell_cmd);
1309-
}
1310-
pclose(fp);
1280+
system(SHELL_CMD_POWERDOWN);
13111281
return MENU_RETURN_EXIT;
13121282
}
13131283
else{

0 commit comments

Comments
 (0)