Skip to content

Commit

Permalink
legiond: add alternative ac_path
Browse files Browse the repository at this point in the history
  • Loading branch information
st0nie committed Nov 18, 2024
1 parent 5511215 commit 58e7aaf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions extra/service/legiond/modules/powerstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ POWER_STATE get_powerstate()
FILE *fp;

fp = fopen(ac_path, "r");
if (fp == NULL)
fp = fopen(ac_path_alt, "r");

int ac_state;
if (fscanf(fp, "%d", &ac_state) != 1) {
printf("failed to get AC status\n");
Expand Down
1 change: 1 addition & 0 deletions extra/service/legiond/modules/powerstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ typedef enum _POWER_STATE {
#define P_ERROR_AC -2

#define ac_path "/sys/class/power_supply/ADP0/online"
#define ac_path_alt "/sys/class/power_supply/ADP0/online"
#define profile_path "/sys/firmware/acpi/platform_profile"

POWER_STATE get_powerstate();
Expand Down

0 comments on commit 58e7aaf

Please sign in to comment.