{"id":20047226,"url":"https://github.com/hirschmann/powereventprovider","last_synced_at":"2025-05-05T10:31:13.499Z","repository":{"id":91376626,"uuid":"207886433","full_name":"hirschmann/powereventprovider","owner":"hirschmann","description":"Power Event Provider service for Windows","archived":false,"fork":false,"pushed_at":"2019-09-11T19:10:35.000Z","size":222,"stargazers_count":42,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-08T21:15:49.663Z","etag":null,"topics":["c-sharp","dotnet","event-log","powerevents","service","task-scheduler","windows"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hirschmann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-11T19:04:45.000Z","updated_at":"2025-04-08T06:57:21.000Z","dependencies_parsed_at":"2023-07-25T01:00:30.695Z","dependency_job_id":null,"html_url":"https://github.com/hirschmann/powereventprovider","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hirschmann%2Fpowereventprovider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hirschmann%2Fpowereventprovider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hirschmann%2Fpowereventprovider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hirschmann%2Fpowereventprovider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hirschmann","download_url":"https://codeload.github.com/hirschmann/powereventprovider/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252480417,"owners_count":21754773,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-sharp","dotnet","event-log","powerevents","service","task-scheduler","windows"],"created_at":"2024-11-13T11:34:36.529Z","updated_at":"2025-05-05T10:31:13.487Z","avatar_url":"https://github.com/hirschmann.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Power Event Provider\n\nPower Event Provider is a Windows service which posts power events such as power scheme changes, battery status changes, display state changes, etc. into the Windows event log.\nBesides for monitoring purposes, these events can also be used as triggers for the Windows task scheduler. This makes it possible to run any application or script when a power event occurs.\n\n## Available events\n\nPower Event Provider supports 5 groups of events. Not all events are supported on each and every system.\n\n### Power schemes\n\nEvent                                                  | ID\n-------------------------------------------------------|---------\nPower scheme personality changed: **Power saver**      | 1000\nPower scheme personality changed: **Automatic**        | 1001\nPower scheme personality changed: **High performance** | 1002\n\n### Power line status\n\nEvent                                                  | ID\n-------------------------------------------------------|---------\nPower line status changed: **AC power source**         | 2000\nPower line status changed: **Battery**                 | 2001\nPower line status changed: **UPS power source**        | 2002\nPower line status changed: **Out of range**            | 2003\n\n### Notebook lid state\n\nEvent                                                  | ID\n-------------------------------------------------------|---------\nNotebook lid state changed: **Closed**                 | 3000\nNotebook lid state changed: **Open**                   | 3001\n\n### Battery percentage\n\nEvent                                                  | ID\n-------------------------------------------------------|---------\nRemaining battery percentage changed: **1%**         | 4*001*\nRemaining battery percentage changed: **2%**         | 4*002*\n...|...\nRemaining battery percentage changed: **99%**         | 4*099*\nRemaining battery percentage changed: **100%**         | 4*100*\n\n:bulb: Battery percentage events are disabled by default to avoid spamming the event log.\n\n### Display state\n\nEvent                                                  | ID\n-------------------------------------------------------|---------\nDisplay state changed: **Off**                         | 5000\nDisplay state changed: **On**                          | 5001\nDisplay state changed: **Dimmed**                      | 5002\n\n## Download\n\nYou can download the PowerEventProvider setup from github: [link (github)](https://github.com/hirschmann/powereventprovider/releases)\n\n## Configuration\n\nYou can enable/disable monitoring of event groups by editing the *PowerEventProvider.exe.config* file in the PowerEventProvider installation directory.\nJust set event groups which should show in the event log to **True**.\n\nAfter changing the config file, the *PowerEventProvider* service must be restarted (e.g. via Windows task manager or *services.msc*) in order for the changes to take effect.\n\nThe default configuration looks like this:\n\n```xml\n\u003c?xml version=\"1.0\"?\u003e\n\u003cconfiguration\u003e\n    \u003cconfigSections\u003e\n        \u003csectionGroup name=\"applicationSettings\" type=\"System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" \u003e\n            \u003csection name=\"PowerEventProviderService.Properties.Settings\" type=\"System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\" requirePermission=\"false\" /\u003e\n        \u003c/sectionGroup\u003e\n    \u003c/configSections\u003e\n    \u003cstartup\u003e\n        \u003csupportedRuntime version=\"v4.0\" sku=\".NETFramework,Version=v4.0,Profile=Client\"/\u003e\n    \u003c/startup\u003e\n    \u003capplicationSettings\u003e\n        \u003cPowerEventProviderService.Properties.Settings\u003e\n            \u003csetting name=\"MonitorBatteryPercentage\" serializeAs=\"String\"\u003e\n                \u003cvalue\u003eFalse\u003c/value\u003e\n            \u003c/setting\u003e\n            \u003csetting name=\"MonitorDisplayState\" serializeAs=\"String\"\u003e\n                \u003cvalue\u003eTrue\u003c/value\u003e\n            \u003c/setting\u003e\n            \u003csetting name=\"MonitorLidswitchState\" serializeAs=\"String\"\u003e\n                \u003cvalue\u003eTrue\u003c/value\u003e\n            \u003c/setting\u003e\n            \u003csetting name=\"MonitorPowerSchemePersonality\" serializeAs=\"String\"\u003e\n                \u003cvalue\u003eTrue\u003c/value\u003e\n            \u003c/setting\u003e\n            \u003csetting name=\"MonitorPowerSource\" serializeAs=\"String\"\u003e\n                \u003cvalue\u003eTrue\u003c/value\u003e\n            \u003c/setting\u003e\n        \u003c/PowerEventProviderService.Properties.Settings\u003e\n    \u003c/applicationSettings\u003e\n\u003c/configuration\u003e\n```\n\n## Viewing power events in the event log\n\n### Powershell\n\nYou can list all PowerEventProvider event log entries by entering the following line in powershell:\n\n```powershell\nget-eventlog -logname Application -source PowerEventProvider\n```\n\n### Event Viewer\n\nIf you prefer GUI over command line, you can create a custom view for PowerEventProvider related events in the Windows Event Viewer.\n\nOpen the Windows event log (*eventvwr.msc*) and create a custom view:\n\n![Create a custom view](images/event-viewer-create-view.png)\n\nSelect a log (*Application*) and a source (*PowerEventProvider*) to view:\n\n![Select a log](images/event-viewer-select-source.png)\n\nOpen your custom view:\n\n![Open the custom view](images/event-viewer.png)\n\n## Using events as scheduled task triggers\n\nSince PowerEventProvider was created as a companion application for [NoteBook FanControl (NBFC)](https://github.com/hirschmann/nbfc), this example shows how to switch NBFC profiles when a notebook's power source changes.\n\nOpen the Windows task scheduler (*taskschd.msc*):\n\n![Create a task](images/task-create.png)\n\nGive the task a name and select the user account which should be used to run the task:\n\n![Task - general settings](images/task-general.png)\n\nCreate a new trigger and select \"Begin the task: On an event\". Then select a log (*Application*) and a event source (*PowerEventProvider*).\nTo run the task as soon as the notebook's power source switches to \"battery\", set the *Event ID* to *2001*:\n\n![Task - trigger](images/task-trigger.png)\n\nCreate a new action and select \"Start a program\". Then put in the path to the NBFC command line interface as program to run: `\"C:\\Program Files (x86)\\NoteBook FanControl\\nbfc.exe\"`  \n\nFinally, set `config --apply \"\u003csome config name\u003e\"` as arguments. In this case I wanted the fan to be more silent when the notebook is not in it's docking station, so the argument was `config --apply \"HP ProBook 6465b silent\"`.\n\n![Task - action](images/task-action.png)\n\nAt last - in this case - it's important to untick all conditions, because the task should run immediately when the power source changes without any delays.\n\n![Task - action](images/task-conditions.png)\n\nThe task settings can be left at default values:\n\n![Task - action](images/task-settings.png)\n\nAfter completing these steps, you can test if everything is working properly by unplugging your notebook. NBFC should switch to the profile you have defined in the task.\n\nTo make NBFC switch back to the default profile when you plug in your notebook, just create a second task which is triggered by event ID 2000 (instead of 2001) and sets the default configuration for your notebook (in my case: `config --apply \"HP ProBook 6465b\"`).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhirschmann%2Fpowereventprovider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhirschmann%2Fpowereventprovider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhirschmann%2Fpowereventprovider/lists"}