From ea6805de8271a0b903f21c4845be40b15f24093b Mon Sep 17 00:00:00 2001 From: Linus Dierheimer Date: Thu, 2 Jun 2022 23:06:49 +0200 Subject: [PATCH] Escape bedrock option --- completions/bash | 1 + src/common/init.c | 1 + src/data/config.txt | 6 ++++++ src/data/help.txt | 1 + src/detection/os.c | 2 +- src/fastfetch.c | 2 ++ src/fastfetch.h | 1 + 7 files changed, 13 insertions(+), 1 deletion(-) diff --git a/completions/bash b/completions/bash index 06bb1f784..916e84dc1 100644 --- a/completions/bash +++ b/completions/bash @@ -130,6 +130,7 @@ __fastfetch_completion() "--localip-show-ipv4" "--localip-show-ipv6" "--localip-show-loop" + "--escape-bedrock" ) local FF_OPTIONS_STRING=( diff --git a/src/common/init.c b/src/common/init.c index 0fbf4570b..fc6d3d04c 100644 --- a/src/common/init.c +++ b/src/common/init.c @@ -124,6 +124,7 @@ static void defaultConfig(FFinstance* instance) instance->config.allowSlowOperations = false; instance->config.disableLinewrap = true; instance->config.hideCursor = true; + instance->config.escapeBedrock = true; ffStrbufInitA(&instance->config.osFormat, 0); ffStrbufInitA(&instance->config.osKey, 0); diff --git a/src/data/config.txt b/src/data/config.txt index 5f2759128..2126c621d 100644 --- a/src/data/config.txt +++ b/src/data/config.txt @@ -151,6 +151,12 @@ # Default is the first match starting with org.mpris.MediaPlayer2. #--player-name spotify +# Escape bedrock option +# Sets if fastfetch should escape the bedrock jail, if it detectes that it is running in one +# Must be true or false. +# Default is true. +#--escape-bedrock true + # Key options: # Sets the displayed key of a module # Can be any string. Some of theme take an argument like a format string. See "fastfetch --help format" for help. diff --git a/src/data/help.txt b/src/data/help.txt index 10a986515..a2aad9825 100644 --- a/src/data/help.txt +++ b/src/data/help.txt @@ -18,6 +18,7 @@ General options: --load-config : load a config file or a preset (+) --multithreading : use multiple threads to detect values --allow-slow-operations : allow operations that are usually very slow for more detailed output + --escape-bedrock : on bedrock linux, sets if it should escape the bedrock jail or not Logo options: -l,--logo : set the logo to use. The type is specified by --logo-type. If default: the name of a builtin logo or a path to a file diff --git a/src/detection/os.c b/src/detection/os.c index 1ef935b7e..bb09e8db7 100644 --- a/src/detection/os.c +++ b/src/detection/os.c @@ -124,7 +124,7 @@ const FFOSResult* ffDetectOS(const FFinstance* instance) { parseFile(instance->config.osFile.chars, &result); } - else if(ffFileExists(FASTFETCH_TARGET_DIR_ROOT"/bedrock/etc/bedrock-release", S_IFDIR)) { + else if(instance->config.escapeBedrock && ffFileExists(FASTFETCH_TARGET_DIR_ROOT"/bedrock/etc/bedrock-release", S_IFDIR)) { parseFile(FASTFETCH_TARGET_DIR_ROOT"/bedrock/etc/bedrock-release", &result); if(result.id.length == 0) diff --git a/src/fastfetch.c b/src/fastfetch.c index 3b351b66d..607b14afc 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -718,6 +718,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con data->multithreading = optionParseBoolean(value); else if(strcasecmp(key, "--allow-slow-operations") == 0) instance->config.allowSlowOperations = optionParseBoolean(value); + else if(strcasecmp(key, "--escape-bedrock") == 0) + instance->config.escapeBedrock = optionParseBoolean(value); //////////////// //Logo options// diff --git a/src/fastfetch.h b/src/fastfetch.h index 886bed4c1..76797ec93 100644 --- a/src/fastfetch.h +++ b/src/fastfetch.h @@ -62,6 +62,7 @@ typedef struct FFconfig bool allowSlowOperations; bool disableLinewrap; bool hideCursor; + bool escapeBedrock; FFstrbuf osFormat; FFstrbuf osKey;