3030#include  "wlr-screencopy-unstable-v1-client-protocol.h" 
3131#include  "ext-session-lock-v1-client-protocol.h" 
3232
33- #define  MAX_BATTERY_STR_LEN  5
3433#define  MAX_OUTPUT_SIZE  1024
3534
3635static  struct  swaylock_state  state ;
@@ -39,12 +38,12 @@ void update_script() {
3938	FILE  * pipe ;
4039	char  path [1035 ];
4140	char  output [MAX_OUTPUT_SIZE ];
42- 	char  * battery_str  =  (char  * )malloc ((MAX_OUTPUT_SIZE  +  1 ) *  sizeof (char ));
41+ 	char  * script_str  =  (char  * )malloc ((MAX_OUTPUT_SIZE  +  1 ) *  sizeof (char ));
4342
44- 	pipe  =  popen (state .args .battery_path , "r" );
43+ 	pipe  =  popen (state .args .script_path , "r" );
4544
4645	if  (pipe  ==  NULL ) {
47- 		fprintf (stderr , "Failed to run battery  script.\n" );
46+ 		fprintf (stderr , "Failed to run script.\n" );
4847		return ;
4948	}
5049
@@ -57,9 +56,9 @@ void update_script() {
5756
5857	pclose (pipe );
5958
60- 	snprintf (battery_str , MAX_OUTPUT_SIZE , "%s" , output );
59+ 	snprintf (script_str , MAX_OUTPUT_SIZE , "%s" , output );
6160
62- 	state .args .battery_str  =  battery_str ;
61+ 	state .args .script_str  =  script_str ;
6362}
6463
6564// returns a positive integer in milliseconds 
@@ -430,7 +429,7 @@ static const struct wl_callback_listener surface_frame_listener;
430429static  void  surface_frame_handle_done (void  * data , struct  wl_callback  * callback ,
431430		uint32_t  time ) {
432431
433- 	if  (state .args .display_battery ) {
432+ 	if  (state .args .display_script ) {
434433		update_script ();
435434	};
436435
@@ -1012,7 +1011,7 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
10121011		LO_TIME_EFFECTS ,
10131012		LO_INDICATOR ,
10141013		LO_CLOCK ,
1015- 		LO_BATTERY ,
1014+ 		LO_SCRIPT ,
10161015		LO_TIMESTR ,
10171016		LO_DATESTR ,
10181017		LO_FADE_IN ,
@@ -1093,7 +1092,7 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
10931092		{"time-effects" , no_argument , NULL , LO_TIME_EFFECTS },
10941093		{"indicator" , no_argument , NULL , LO_INDICATOR },
10951094		{"clock" , no_argument , NULL , LO_CLOCK },
1096- 		{"battery " , required_argument , NULL , LO_BATTERY },
1095+ 		{"script " , required_argument , NULL , LO_SCRIPT },
10971096		{"timestr" , required_argument , NULL , LO_TIMESTR },
10981097		{"datestr" , required_argument , NULL , LO_DATESTR },
10991098		{"fade-in" , required_argument , NULL , LO_FADE_IN },
@@ -1153,8 +1152,8 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
11531152			"Disable the unlock indicator.\n" 
11541153		"  --indicator                      " 
11551154			"Always show the indicator.\n" 
1156- 		"  --battery                         " 
1157- 			"Show the battery percentage .\n" 
1155+ 		"  --script                         " 
1156+ 			"Show the script output .\n" 
11581157		"  --clock                          " 
11591158			"Show time and date.\n" 
11601159		"  --timestr <format>               " 
@@ -1660,10 +1659,10 @@ static int parse_options(int argc, char **argv, struct swaylock_state *state,
16601659				state -> args .clock  =  true;
16611660			}
16621661			break ;
1663- 		case  LO_BATTERY :
1662+ 		case  LO_SCRIPT :
16641663			if  (state ) {
1665- 				state -> args .battery_path  =  strdup (optarg );
1666- 				state -> args .display_battery  =  true;
1664+ 				state -> args .script_path  =  strdup (optarg );
1665+ 				state -> args .display_script  =  true;
16671666			}
16681667			update_script ();
16691668			break ;
@@ -1894,9 +1893,9 @@ int main(int argc, char **argv) {
18941893		.allow_fade  =  true,
18951894		.password_grace_period  =  0 ,
18961895
1897- 		.display_battery  =  false,
1898- 		.battery_str  =  NULL ,
1899- 		.battery_path  =  NULL ,
1896+ 		.display_script  =  false,
1897+ 		.script_str  =  NULL ,
1898+ 		.script_path  =  NULL ,
19001899
19011900		.text_cleared  =  strdup ("Cleared" ),
19021901		.text_caps_lock  =  strdup ("Caps Lock" ),
0 commit comments