Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Lens
Commits
e950d3a7
Unverified
Commit
e950d3a7
authored
3 years ago
by
Juho Heikka
Committed by
GitHub
3 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Expose Electron powerMonitor API to extensions (#4844)
parent
ab61f843
master
better-release-script
catalog-entity-detail-registry
consolidate-running-of-setups-on-application-start
dependabot/npm_and_yarn/react-select-5.3.2
dependabot/npm_and_yarn/react-window-1.8.7
dependabot/npm_and_yarn/types/node-14.18.16
dependabot/npm_and_yarn/types/webpack-env-1.16.4
di-stores
docs/api-all-exported
enhancement-node-vertical-metric-bars
entity-settings
extensions/lens-version-check
feature/auto-update
feature/context-providers
fix-change-os-theme-crash
fix-linter-errors
fix-optimise-update-events-from-buffer
fix-reload-list-items-on-mount
fix-remove-watch-flush-headers
fix-reseting-select-value
fix-resource-applier
fix/log-store-loading
fix/search_input_autofocus
front-end-routes-ocp
front-end-routes-ocp-2
front-end-routes-ocp-3
helm-repo-manager-removal
issue-1909
issue-3498
issue-3797
issue-4997
issue-5141
issue-5165
issue-5173
issue-5177
issue-5238
more-places-to-check-for-updates
release/v5.4
remove-unused-telemetry
show-extension-preferences-in-separate-page
squashed-update-injectable
turn-on-strict
ui-table-empty-state-lines
update-electon-builder-to-3-0-8
validate-cluster-model
websocket-catalog-sync
v5.5.0-beta.0
v5.4.6
v5.4.5
v5.4.4
v5.4.3
v5.4.2
v5.4.1
v5.4.0
v5.4.0-beta.5
v5.4.0-beta.4
v5.4.0-beta.3
v5.4.0-beta.2
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/extensions/main-api/index.ts
+2
-0
src/extensions/main-api/index.ts
src/extensions/main-api/power.ts
+51
-0
src/extensions/main-api/power.ts
with
53 additions
and
0 deletions
+53
-0
src/extensions/main-api/index.ts
+
2
-
0
View file @
e950d3a7
...
...
@@ -6,6 +6,7 @@
import
*
as
Catalog
from
"
./catalog
"
;
import
*
as
Navigation
from
"
./navigation
"
;
import
*
as
K8sApi
from
"
./k8s-api
"
;
import
*
as
Power
from
"
./power
"
;
import
{
IpcMain
as
Ipc
}
from
"
../ipc/ipc-main
"
;
import
{
LensMainExtension
as
LensExtension
}
from
"
../lens-main-extension
"
;
...
...
@@ -15,4 +16,5 @@ export {
K8sApi
,
Ipc
,
LensExtension
,
Power
,
};
This diff is collapsed.
Click to expand it.
src/extensions/main-api/power.ts
0 → 100644
+
51
-
0
View file @
e950d3a7
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import
{
powerMonitor
}
from
"
electron
"
;
import
type
{
Disposer
}
from
"
../../common/utils/disposer
"
;
/**
* Event listener for system power events
*/
export
type
PowerEventListener
=
()
=>
void
;
/**
* Adds event listener to system suspend events
* @param listener function which will be called on system suspend
* @returns function to remove event listener
*/
export
const
onSuspend
=
(
listener
:
PowerEventListener
):
Disposer
=>
{
powerMonitor
.
on
(
"
suspend
"
,
listener
);
return
()
=>
{
powerMonitor
.
off
(
"
suspend
"
,
listener
);
};
};
/**
* Adds event listener to system resume event
* @param listener function which will be called on system resume
* @returns function to remove event listener
*/
export
const
onResume
=
(
listener
:
PowerEventListener
):
Disposer
=>
{
powerMonitor
.
on
(
"
resume
"
,
listener
);
return
()
=>
{
powerMonitor
.
off
(
"
resume
"
,
listener
);
};
};
/**
* Adds event listener to the event which is emitted when
* the system is about to reboot or shut down
* @param listener function which will be called on system shutdown
* @returns function to remove event listener
*/
export
const
onShutdown
=
(
listener
:
PowerEventListener
):
Disposer
=>
{
powerMonitor
.
on
(
"
shutdown
"
,
listener
);
return
()
=>
{
powerMonitor
.
off
(
"
shutdown
"
,
listener
);
};
};
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help