diff --git a/completions/bash b/completions/bash index c6e7b26dc..71f21649d 100644 --- a/completions/bash +++ b/completions/bash @@ -384,7 +384,6 @@ __fastfetch_completion() "--lib-pulse" "--lib-ddcutil" "--lib-nm" - "--battery-dir" ) local FF_OPTIONS_LOGO=( diff --git a/doc/json_schema.json b/doc/json_schema.json index dd097dbe6..78a4116b0 100644 --- a/doc/json_schema.json +++ b/doc/json_schema.json @@ -804,10 +804,6 @@ "const": "battery", "description": "Print battery capacity, status, etc" }, - "dir": { - "description": "The directory where the battery folders are. Standard: `/sys/class/power_supply/`. Linux only", - "type": "string" - }, "useSetupApi": { "description": "Set if `SetupAPI` should be used on Windows to detect battery info, which supports multi batteries, but slower. Windows only", "type": "boolean", diff --git a/src/data/help.json b/src/data/help.json index 44f264caf..3af8895cc 100644 --- a/src/data/help.json +++ b/src/data/help.json @@ -1026,15 +1026,6 @@ "default": "main" } }, - { - "long": "battery-dir", - "desc": "The directory where the battery folders are", - "remark": "Linux only", - "arg": { - "type": "path", - "default": "/sys/class/power_supply/" - } - }, { "long": "battery-use-setup-api", "desc": "Set if \"SetupAPI\" should be used on Windows to detect battery info", diff --git a/src/detection/battery/battery_linux.c b/src/detection/battery/battery_linux.c index 04b8a9a0a..e8bc4c223 100644 --- a/src/detection/battery/battery_linux.c +++ b/src/detection/battery/battery_linux.c @@ -101,14 +101,13 @@ static void parseBattery(FFstrbuf* dir, const char* id, FFBatteryOptions* option const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) { FF_STRBUF_AUTO_DESTROY baseDir = ffStrbufCreateA(64); - ffStrbufAppend(&baseDir, &options->dir); - ffStrbufEnsureEndsWithC(&baseDir, '/'); + ffStrbufAppend(&baseDir, "/sys/class/power_supply/"); uint32_t baseDirLength = baseDir.length; FF_AUTO_CLOSE_DIR DIR* dirp = opendir(baseDir.chars); if(dirp == NULL) - return "opendir(batteryDir) == NULL"; + return "opendir(\"/sys/class/power_supply/\") == NULL"; struct dirent* entry; while((entry = readdir(dirp)) != NULL) @@ -122,7 +121,7 @@ const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results) } if(results->length == 0) - return "batteryDir doesn't contain any battery folder"; + return "\"/sys/class/power_supply/\" doesn't contain any battery folder"; return NULL; } diff --git a/src/modules/battery/battery.c b/src/modules/battery/battery.c index 0946ad0c0..28d44679e 100644 --- a/src/modules/battery/battery.c +++ b/src/modules/battery/battery.c @@ -115,14 +115,6 @@ bool ffParseBatteryCommandOptions(FFBatteryOptions* options, const char* key, co return true; } - #ifdef __linux__ - if (ffStrEqualsIgnCase(subKey, "dir")) - { - ffOptionParseString(key, value, &options->dir); - return true; - } - #endif - #ifdef _WIN32 if (ffStrEqualsIgnCase(subKey, "use-setup-api")) { @@ -147,14 +139,6 @@ void ffParseBatteryJsonObject(FFBatteryOptions* options, yyjson_val* module) if (ffJsonConfigParseModuleArgs(key, val, &options->moduleArgs)) continue; - #ifdef __linux__ - if (ffStrEqualsIgnCase(key, "dir")) - { - ffStrbufSetS(&options->dir, yyjson_get_str(val)); - continue; - } - #endif - #ifdef _WIN32 if (ffStrEqualsIgnCase(key, "useSetupApi")) { @@ -180,11 +164,6 @@ void ffGenerateBatteryJsonConfig(FFBatteryOptions* options, yyjson_mut_doc* doc, ffJsonConfigGenerateModuleArgsConfig(doc, module, &defaultOptions.moduleArgs, &options->moduleArgs); - #ifdef __linux__ - if (!ffStrbufEqual(&defaultOptions.dir, &options->dir)) - yyjson_mut_obj_add_strbuf(doc, module, "dir", &options->dir); - #endif - #ifdef _WIN32 if (defaultOptions.useSetupApi != options->useSetupApi) yyjson_mut_obj_add_bool(doc, module, "useSetupApi", options->useSetupApi); @@ -257,9 +236,7 @@ void ffInitBatteryOptions(FFBatteryOptions* options) ffOptionInitModuleArg(&options->moduleArgs); options->temp = false; - #ifdef __linux__ - ffStrbufInitStatic(&options->dir, "/sys/class/power_supply/"); - #elif defined(_WIN32) + #ifdef _WIN32 options->useSetupApi = false; #endif } @@ -267,8 +244,4 @@ void ffInitBatteryOptions(FFBatteryOptions* options) void ffDestroyBatteryOptions(FFBatteryOptions* options) { ffOptionDestroyModuleArg(&options->moduleArgs); - - #ifdef __linux__ - ffStrbufDestroy(&options->dir); - #endif } diff --git a/src/modules/battery/option.h b/src/modules/battery/option.h index 89f05bab4..401816ae7 100644 --- a/src/modules/battery/option.h +++ b/src/modules/battery/option.h @@ -11,9 +11,7 @@ typedef struct FFBatteryOptions bool temp; - #ifdef __linux__ - FFstrbuf dir; - #elif defined(_WIN32) + #ifdef _WIN32 bool useSetupApi; #endif } FFBatteryOptions;