@@ -666,13 +666,13 @@ function applyProfile(profile = {}, useTransition = false, transitionSpeed = 1)
666
666
}
667
667
668
668
669
- function applyHotkeys ( ) {
669
+ function applyHotkeys ( monitorList = monitors ) {
670
670
if ( settings . hotkeys !== undefined ) {
671
671
globalShortcut . unregisterAll ( )
672
672
for ( let hotkey of Object . values ( settings . hotkeys ) ) {
673
673
try {
674
674
// Only apply if found
675
- if ( hotkey . monitor == "all" || hotkey . monitor == "turn_off_displays" || Object . values ( monitors ) . find ( m => m . id == hotkey . monitor ) ) {
675
+ if ( hotkey . monitor == "all" || hotkey . monitor == "turn_off_displays" || Object . values ( monitorList ) . find ( m => m . id == hotkey . monitor ) ) {
676
676
hotkey . active = globalShortcut . register ( hotkey . accelerator , ( ) => {
677
677
doHotkey ( hotkey )
678
678
} )
@@ -1254,29 +1254,38 @@ refreshMonitors = async (fullRefresh = false, bypassRateLimit = false) => {
1254
1254
let oldMonitors = Object . assign ( { } , monitors )
1255
1255
let newMonitors
1256
1256
1257
+ let failed = false
1257
1258
try {
1258
1259
newMonitors = await refreshMonitorsJob ( fullRefresh )
1259
- if ( ! newMonitors ) throw "No monitors!" ;
1260
+ if ( ! newMonitors ) {
1261
+ failed = true ;
1262
+ throw "No monitors recieved!" ;
1263
+ }
1260
1264
lastEagerUpdate = Date . now ( )
1261
1265
} catch ( e ) {
1262
1266
console . log ( 'Couldn\'t refresh monitors' , e )
1263
1267
}
1264
1268
1265
1269
isRefreshing = false
1266
- applyOrder ( )
1267
- applyRemaps ( )
1268
- applyHotkeys ( )
1269
-
1270
- for ( let id in newMonitors ) {
1271
- newMonitors [ id ] . brightness = normalizeBrightness ( newMonitors [ id ] . brightness , true , newMonitors [ id ] . min , newMonitors [ id ] . max )
1272
- }
1273
1270
1274
- // Only send update if something changed
1275
- if ( JSON . stringify ( newMonitors ) !== JSON . stringify ( oldMonitors ) ) {
1276
- setTrayPercent ( )
1277
- sendToAllWindows ( 'monitors-updated' , monitors )
1278
- } else {
1279
- console . log ( "===--- NO CHANGE ---===" )
1271
+ if ( ! failed ) {
1272
+ applyOrder ( newMonitors )
1273
+ applyRemaps ( newMonitors )
1274
+ applyHotkeys ( newMonitors )
1275
+
1276
+ for ( let id in newMonitors ) {
1277
+ newMonitors [ id ] . brightness = normalizeBrightness ( newMonitors [ id ] . brightness , true , newMonitors [ id ] . min , newMonitors [ id ] . max )
1278
+ }
1279
+
1280
+ monitors = newMonitors ;
1281
+
1282
+ // Only send update if something changed
1283
+ if ( JSON . stringify ( newMonitors ) !== JSON . stringify ( oldMonitors ) ) {
1284
+ setTrayPercent ( )
1285
+ sendToAllWindows ( 'monitors-updated' , monitors )
1286
+ } else {
1287
+ console . log ( "===--- NO CHANGE ---===" )
1288
+ }
1280
1289
}
1281
1290
1282
1291
if ( shouldShowPanel ) {
@@ -1285,7 +1294,6 @@ refreshMonitors = async (fullRefresh = false, bypassRateLimit = false) => {
1285
1294
}
1286
1295
1287
1296
console . log ( "\x1b[34m---------------------------------------------- \x1b[0m" )
1288
- monitors = newMonitors ;
1289
1297
return monitors ;
1290
1298
}
1291
1299
0 commit comments