@@ -111,11 +111,14 @@ const FrequencyIndicator = new Lang.Class({
111
111
error ( e . message ) ;
112
112
return ;
113
113
}
114
- this . on_power_state ( ) ;
114
+ this . on_power_state ( proxy . State , proxy . Percentage ) ;
115
115
if ( save && first_boot && ! guid_battery ) this . launch_app ( "--profile=user" ) ;
116
116
first_boot = false ;
117
117
GLib . timeout_add ( 0 , 8000 , ( ) => {
118
- powerID = this . power . connect ( 'g-properties-changed' , this . on_power_state . bind ( this ) ) ;
118
+ powerID = this . power . connect ( 'g-properties-changed' , ( o , a , b ) => {
119
+ debug ( "power g-properties-changed: %s:%s:%s" . format ( o , a , b ) ) ;
120
+ this . on_power_state ( this . power . State , this . power . Percentage ) ;
121
+ } ) ;
119
122
} ) ;
120
123
} ) ;
121
124
} ,
@@ -150,22 +153,29 @@ const FrequencyIndicator = new Lang.Class({
150
153
}
151
154
152
155
if ( ( key == LABEL_KEY ) && ! monitor_timeout ) this . statusLabel . set_text ( this . get_title ( ) ) ;
156
+
157
+ if ( ( key == "power-state" ) || ( key == "power-percentage" ) ) {
158
+ debug ( "power-state changed..." ) ;
159
+ this . on_power_state ( o . get_uint ( "power-state" ) , o . get_double ( "power-percentage" ) ) ;
160
+ }
153
161
} ,
154
162
155
- on_power_state : function ( ) {
163
+ on_power_state : function ( state , percentage ) {
156
164
let id = eprofiles [ 1 ] . guid ;
157
- debug ( "on_power_state: %d %.2f%%" . format ( this . power . State , this . power . Percentage ) ) ;
158
- if ( ! id || id == guid_battery ) return ;
159
- if ( this . power . State == 2 ) {
165
+ //debug ("on_power_state: %s %s%%".format (this.power.State, this.power.Percentage));
166
+ debug ( "on_power_state: %s %s%%" . format ( state , percentage ) ) ;
167
+ if ( ! id ) return ;
168
+ if ( state == 2 ) {
160
169
//on battery
161
- if ( this . power . Percentage < eprofiles [ 1 ] . percent ) {
170
+ if ( id == guid_battery ) return ;
171
+ if ( percentage < eprofiles [ 1 ] . percent ) {
162
172
this . schedule_profile ( '--no-save --profile=' + id ) ;
163
173
guid_battery = id ;
164
174
}
165
175
} else {
166
176
//restoring prev state
167
177
if ( guid_battery == this . guid ) return ;
168
- if ( this . power . Percentage >= eprofiles [ 1 ] . percent ) {
178
+ if ( percentage >= eprofiles [ 1 ] . percent ) {
169
179
this . schedule_profile ( '--profile=user' ) ;
170
180
guid_battery = this . guid ;
171
181
}
@@ -179,16 +189,16 @@ const FrequencyIndicator = new Lang.Class({
179
189
180
190
schedule_profile : function ( options ) {
181
191
if ( scheduleID ) this . unschedule_profile ( ) ;
182
- scheduleID = GLib . timeout_add ( 0 , 4000 , ( ) => {
192
+ scheduleID = GLib . timeout_add ( 0 , 5000 , ( ) => {
183
193
this . launch_app ( options ) ;
184
194
scheduleID = 0 ;
185
195
} ) ;
186
196
} ,
187
197
188
198
launch_app : function ( options ) {
189
199
let extra = "" ;
190
- if ( Logger . debug_lvl == 2 ) extra = " --debug" ;
191
- else if ( Logger . debug_lvl == 1 ) extra = " --verbose" ;
200
+ /* if (Logger.debug_lvl == 2) extra = " --debug";
201
+ else if (Logger.debug_lvl == 1) extra = " --verbose";*/
192
202
options = options || "--extension" ;
193
203
info ( "launch_app " + options + extra ) ;
194
204
GLib . spawn_command_line_async ( "%s %s" . format ( APP_PATH , options + extra ) ) ;
0 commit comments