diff --git a/CHANGELOG.md b/CHANGELOG.md index f9d32ee7a..9d5ebd2b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Features: * Add `Brightness` module support * Add `Battery` module support for FreeBSD * Add `--disk-show-unknown` option for Disk module +* Add `--disk-show-subvolumes` option for Disk module * Add `--gpu-hide-integrated` option (#379) * Add `--gpu-hide-discrete` option (#379) * Detect terminal version when available diff --git a/completions/bash b/completions/bash index 66649337a..b4f1548f7 100644 --- a/completions/bash +++ b/completions/bash @@ -194,6 +194,7 @@ __fastfetch_completion() "--disk-folders" "--disk-show-removable" "--disk-show-hidden" + "--disk-show-subvolumes" "--gpu-hide-integrated" "--gpu-hide-discrete" "--disk-show-unknown" diff --git a/src/common/init.c b/src/common/init.c index d08cbaf09..efef9190a 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -156,6 +156,7 @@ static void defaultConfig(FFinstance* instance) instance->config.diskShowRemovable = true; instance->config.diskShowHidden = false; instance->config.diskShowUnknown = false; + instance->config.diskShowSubvolumes = false; ffStrbufInitA(&instance->config.batteryDir, 0); diff --git a/src/data/config_user.txt b/src/data/config_user.txt index 435143dc4..0ea7b3973 100644 --- a/src/data/config_user.txt +++ b/src/data/config_user.txt @@ -231,22 +231,13 @@ # Default is true. #--terminal-version true -# Disk option -# Sets if removable volume should be printed +# Disk show options +# Sets if certain types of disk should be printed # Must be either true or false -# Default is true. +# Default is false except for --disk-show-removable. #--disk-show-removable true - -# Disk option -# Sets if hidden volume should be printed -# Must be either true or false -# Default is false. #--disk-show-hidden false - -# Disk option -# Sets if unknown (unable to detect sizes) volume should be printed -# Must be either true or false -# Default is false. +#--disk-show-subvolumes false #--disk-show-unknown false # Disk option diff --git a/src/data/help.txt b/src/data/help.txt index 441c1c6cf..b8a546c9c 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -100,35 +100,36 @@ Library options: Set the path of a library to load --lib-cjson Module specific options: - --title-fqdn : Set if the title should use fully qualified domain name. Default is false - --separator-string : Set the string printed by the separator module - --os-file : Set the path to the file containing OS information - --shell-version : Set if shell version should be detected and printed - --terminal-version : Set if terminal version should be detected and printed - --disk-folders : A colon (semicolon on Windows) separated list of folder paths for the disk output. Default is "/:/home" ("C:\\;D:\\ ..." on Windows) - --disk-show-removable : Set if removable volume should be printed. Default is true - --disk-show-hidden : Set if hidden volumes should be printed. Default is false - --disk-show-unknown : Set if unknown (unable to detect sizes) volumes should be printed. Default is false - --battery-dir : The directory where the battery folders are. Standard: /sys/class/power_supply/ - --cpu-temp : Detect and display CPU temperature if supported. Default is false - --gpu-temp : Detect and display GPU temperature if supported. Default is false - --gpu-hide-integrated : Hide integrated GPU if supported. Default is false - --gpu-hide-discrete : Hide discrete GPU if supported. Default is false - --battery-temp : Detect and display Battery temperature if supported. Default is false - --localip-show-ipv4 : Show IPv4 addresses in local ip module. Default is true - --localip-show-ipv6 : Show IPv6 addresses in local ip module. Default is false - --localip-show-loop : Show loop back addresses (127.0.0.1) in local ip module. Default is false - --localip-name-prefix : Show IPs with given name prefix only. Default is empty - --public-ip-timeout: Time in milliseconds to wait for the public ip server to respond. Default is disabled (0) - --public-ip-url: The URL of public IP detection server to be used. - --weather-timeout: Time in milliseconds to wait for the weather server to respond. Default is disabled (0) - --weather-output-format: The output weather format to be used. It must be URI encoded. - --player-name: The name of the player to use - --gl : Set the OpenGL context creation library to use. Must be auto, egl, glx or osmesa. Default is auto - --percent-type : Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only. Default is 1 - --command-shell : Set the shell program to execute the command text. Default is cmd for Windows, csh for FreeBSD, bash for others - --command-key : Set the module key to display, can be specified mulitple times - --command-text : Set the command text to be executed, can be specified mulitple times + --title-fqdn : Set if the title should use fully qualified domain name. Default is false + --separator-string : Set the string printed by the separator module + --os-file : Set the path to the file containing OS information + --shell-version : Set if shell version should be detected and printed + --terminal-version : Set if terminal version should be detected and printed + --disk-folders : A colon (semicolon on Windows) separated list of folder paths for the disk output. Default is "/:/home" ("C:\\;D:\\ ..." on Windows) + --disk-show-removable : Set if removable volume should be printed. Default is true + --disk-show-hidden : Set if hidden volumes should be printed. Default is false + --disk-show-subvolumes : Set if subvolumes should be printed. Default is false + --disk-show-unknown : Set if unknown (unable to detect sizes) volumes should be printed. Default is false + --battery-dir : The directory where the battery folders are. Standard: /sys/class/power_supply/ + --cpu-temp : Detect and display CPU temperature if supported. Default is false + --gpu-temp : Detect and display GPU temperature if supported. Default is false + --gpu-hide-integrated : Hide integrated GPU if supported. Default is false + --gpu-hide-discrete : Hide discrete GPU if supported. Default is false + --battery-temp : Detect and display Battery temperature if supported. Default is false + --localip-show-ipv4 : Show IPv4 addresses in local ip module. Default is true + --localip-show-ipv6 : Show IPv6 addresses in local ip module. Default is false + --localip-show-loop : Show loop back addresses (127.0.0.1) in local ip module. Default is false + --localip-name-prefix : Show IPs with given name prefix only. Default is empty + --public-ip-timeout: Time in milliseconds to wait for the public ip server to respond. Default is disabled (0) + --public-ip-url: The URL of public IP detection server to be used. + --weather-timeout: Time in milliseconds to wait for the weather server to respond. Default is disabled (0) + --weather-output-format: The output weather format to be used. It must be URI encoded. + --player-name: The name of the player to use + --gl : Set the OpenGL context creation library to use. Must be auto, egl, glx or osmesa. Default is auto + --percent-type : Set the percentage output type. 1 for percentage number, 2 for bar, 3 for both, 6 for bar only. Default is 1 + --command-shell : Set the shell program to execute the command text. Default is cmd for Windows, csh for FreeBSD, bash for others + --command-key : Set the module key to display, can be specified mulitple times + --command-text : Set the command text to be executed, can be specified mulitple times Parsing is not case sensitive. E.g. "--lib-PCI" is equal to "--Lib-Pci" If a value starts with a ?, it is optional. "true" will be used if not set. diff --git a/src/detection/disk/disk.h b/src/detection/disk/disk.h index c061ce6c9..f4230ce46 100644 --- a/src/detection/disk/disk.h +++ b/src/detection/disk/disk.h @@ -9,7 +9,8 @@ typedef enum FFDiskType { FF_DISK_TYPE_REGULAR, FF_DISK_TYPE_HIDDEN, - FF_DISK_TYPE_EXTERNAL + FF_DISK_TYPE_EXTERNAL, + FF_DISK_TYPE_SUBVOLUME } FFDiskType; typedef struct FFDisk diff --git a/src/detection/disk/disk_linux.c b/src/detection/disk/disk_linux.c index 72d6c3f27..1907657d7 100644 --- a/src/detection/disk/disk_linux.c +++ b/src/detection/disk/disk_linux.c @@ -28,6 +28,21 @@ static void strbufAppendMountPoint(FFstrbuf* mountpoint, const char* source) } } +#ifndef __ANDROID__ +static bool isSubvolume(const char* options) +{ + const char* prefix = "subvol=/@"; //Btrfs subvolume + const char* subvolume = strstr(options, prefix); + if(subvolume == NULL) + return false; + + subvolume += strlen(prefix); + + //If there is no space or comma after the @, it is a btrfs subvolume + return *subvolume != ' ' && *subvolume != ','; +} +#endif + void ffDetectDisksImpl(FFDiskResult* disks) { FILE* mountsFile = fopen("/proc/mounts", "r"); @@ -82,19 +97,21 @@ void ffDetectDisksImpl(FFDiskResult* disks) ++currentPos; #ifdef __ANDROID__ - if(ffStrbufEqualS(&disk->mountpoint, "/") || ffStrbufEqualS(&disk->mountpoint, "/storage/emulated")) - disk->type = FF_DISK_TYPE_REGULAR; - else if(ffStrbufStartsWithS(&disk->mountpoint, "/mnt/media_rw/")) - disk->type = FF_DISK_TYPE_EXTERNAL; - else - disk->type = FF_DISK_TYPE_HIDDEN; + if(ffStrbufEqualS(&disk->mountpoint, "/") || ffStrbufEqualS(&disk->mountpoint, "/storage/emulated")) + disk->type = FF_DISK_TYPE_REGULAR; + else if(ffStrbufStartsWithS(&disk->mountpoint, "/mnt/media_rw/")) + disk->type = FF_DISK_TYPE_EXTERNAL; + else + disk->type = FF_DISK_TYPE_HIDDEN; #else - if(strstr(currentPos, "nosuid") != NULL || strstr(currentPos, "nodev") != NULL) - disk->type = FF_DISK_TYPE_EXTERNAL; - else if(ffStrbufStartsWithS(&disk->mountpoint, "/boot") || ffStrbufStartsWithS(&disk->mountpoint, "/efi")) - disk->type = FF_DISK_TYPE_HIDDEN; - else - disk->type = FF_DISK_TYPE_REGULAR; + if(isSubvolume(currentPos)) + disk->type = FF_DISK_TYPE_SUBVOLUME; + else if(strstr(currentPos, "nosuid") != NULL || strstr(currentPos, "nodev") != NULL) + disk->type = FF_DISK_TYPE_EXTERNAL; + else if(ffStrbufStartsWithS(&disk->mountpoint, "/boot") || ffStrbufStartsWithS(&disk->mountpoint, "/efi")) + disk->type = FF_DISK_TYPE_HIDDEN; + else + disk->type = FF_DISK_TYPE_REGULAR; #endif //Detects stats diff --git a/src/fastfetch.c b/src/fastfetch.c index d80537e41..486245dd2 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -1266,6 +1266,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con instance->config.diskShowRemovable = optionParseBoolean(value); else if(strcasecmp(key, "--disk-show-hidden") == 0) instance->config.diskShowHidden = optionParseBoolean(value); + else if(strcasecmp(key, "--disk-show-subvolumes") == 0) + instance->config.diskShowSubvolumes = optionParseBoolean(value); else if(strcasecmp(key, "--disk-show-unknown") == 0) instance->config.diskShowUnknown = optionParseBoolean(value); else if(strcasecmp(key, "--battery-dir") == 0) diff --git a/src/fastfetch.h b/src/fastfetch.h index 93be159df..084ec26f3 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -180,6 +180,7 @@ typedef struct FFconfig bool diskShowRemovable; bool diskShowHidden; bool diskShowUnknown; + bool diskShowSubvolumes; FFstrbuf batteryDir; diff --git a/src/modules/disk.c b/src/modules/disk.c index df7614d5c..c1e074812 100644 --- a/src/modules/disk.c +++ b/src/modules/disk.c @@ -137,6 +137,9 @@ static void printAutodetected(FFinstance* instance, const FFlist* disks) if(disk->type == FF_DISK_TYPE_EXTERNAL && !instance->config.diskShowRemovable) continue; + if(disk->type == FF_DISK_TYPE_SUBVOLUME && !instance->config.diskShowSubvolumes) + continue; + if(disk->type == FF_DISK_TYPE_HIDDEN && !instance->config.diskShowHidden) continue;