Skip to content

Commit 9f06def

Browse files
committed
misc: sync some changes from main repo + remove config.os.pkgs
1 parent ce00623 commit 9f06def

File tree

3 files changed

+21
-50
lines changed

3 files changed

+21
-50
lines changed

app/src/main/java/org/toni/customfetch_android_lib/Config.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,6 @@ data class OsUptimeConfig(
4949
@SerialName("secs") var secondsFormat: String = " seconds"
5050
)
5151

52-
@Serializable
53-
data class OsPkgsConfig(
54-
@SerialName("pkg-managers") var pkgManagers: ArrayList<String> = arrayListOf("pacman", "dpkg", "flatpak"),
55-
@SerialName("pacman-dirs") var pacmanDirs: ArrayList<String> = arrayListOf("/var/lib/pacman/local/"),
56-
@SerialName("dpkg-files") var dpkgFiles: ArrayList<String> = arrayListOf("/var/lib/dpkg/status", "/data/data/com.termux/files/usr/var/lib/dpkg/status"),
57-
@SerialName("flatpak-dirs") var flatpakDirs: ArrayList<String> = arrayListOf("/var/lib/flatpak/app/", "~/.local/share/flatpak/app/"),
58-
@SerialName("apk-files") var apkFiles: ArrayList<String> = arrayListOf("/var/lib/apk/db/installed")
59-
)
60-
6152
@Serializable
6253
data class GuiConfig(
6354
@SerialName("font") var font: String = "Monospace 12",
@@ -88,7 +79,6 @@ data class Config(
8879
@SerialName("config") val t: ConfigTable = ConfigTable(),
8980
@SerialName("auto.disk") val autoDisk: AutoDiskConfig = AutoDiskConfig(),
9081
@SerialName("os.uptime") val osUptime: OsUptimeConfig = OsUptimeConfig(),
91-
@SerialName("os.pkgs") val osPkgs: OsPkgsConfig = OsPkgsConfig(),
9282
@SerialName("gui") val gui: GuiConfig = GuiConfig(),
9383
)
9484

app/src/main/java/org/toni/customfetch_android_lib/LongFile.kt

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -497,27 +497,6 @@ hours = " hours"
497497
mins = " mins"
498498
secs = " seconds"
499499
500-
# ${'$'}<os.pkgs> config
501-
[os.pkgs]
502-
# Ordered list of which packages installed count should be displayed in ${'$'}<os.pkgs>
503-
# remember to not enter the same name twice, else the world will finish
504-
# Choices: pacman, flatpak, dpkg, apk
505-
#
506-
# Pro-tip: if your package manager isn't listed here, yet,
507-
# use the bash command tag in the layout
508-
# e.g "Packages: ${'$'}(pacman -Q | wc -l) (pacman)"
509-
pkg-managers = ["pacman", "dpkg", "flatpak"]
510-
511-
# Distros and package manager specific
512-
# package manager paths for getting the packages count from path.
513-
# They are arrays so you can add multiple paths.
514-
#
515-
# If you don't know what these ares, leave them by default settings
516-
pacman-dirs = ["/var/lib/pacman/local/"]
517-
dpkg-files = ["/var/lib/dpkg/status", "/data/data/com.termux/files/usr/var/lib/dpkg/status"]
518-
flatpak-dirs = ["/var/lib/flatpak/app/", "~/.local/share/flatpak/app/"]
519-
apk-files = ["/var/lib/apk/db/installed"]
520-
521500
# Desktop/Android app options
522501
[gui]
523502
@@ -529,7 +508,7 @@ font = "Liberation Mono Normal 12"
529508
530509
# These are the colors you can use in the GUI mode.
531510
# They overwrite the terminal colors from above.
532-
# They can only have hexcodes colors
511+
# They can only have hex codes colors
533512
black = "!#000005"
534513
red = "!#ff2000"
535514
green = "!#00ff00"

app/src/main/java/org/toni/customfetch_android_lib/Main.kt

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private fun manageConfigStuff(context: Context, config: Config) {
154154
config.autoDisk.displayTypes.let {
155155
if (it.contains("regular"))
156156
config.autoDisk.displayTypesInt = config.autoDisk.displayTypesInt or DiskVolumeType.REGULAR.value
157-
if (it.contains("removable"))
157+
if (it.contains("removable") || it.contains("external"))
158158
config.autoDisk.displayTypesInt = config.autoDisk.displayTypesInt or DiskVolumeType.EXTERNAL.value
159159
if (it.contains("hidden"))
160160
config.autoDisk.displayTypesInt = config.autoDisk.displayTypesInt or DiskVolumeType.HIDDEN.value
@@ -170,23 +170,6 @@ private fun detectDistroFile(config: Config): String {
170170
return "${config.t.dataDir}/ascii/android.txt"
171171
}
172172

173-
fun mainRenderStr(context: Context, argsStr: String): String {
174-
createConfig()
175-
val args = argsStr.split(' ').toTypedArray()
176-
val toml = Toml {
177-
ignoreUnknownKeys = true
178-
}
179-
val tomlConfig = Paths.get(parseConfigArg(context, args)).readText()
180-
.replace("\\e[", "\\u001B[") // Escape ANSI codes
181-
val config: Config
182-
try {
183-
config = toml.decodeFromString(Config.serializer(), tomlConfig)
184-
} catch (e: SerializationException) {
185-
return e.message.toString()
186-
}
187-
return parseArgs(context, args, config)
188-
}
189-
190173
private fun tokenizeUserCommand(input: String): Array<String> {
191174
val tokens = mutableListOf<String>()
192175
val current = StringBuilder()
@@ -220,6 +203,25 @@ private fun tokenizeUserCommand(input: String): Array<String> {
220203
return tokens.toTypedArray()
221204
}
222205

206+
fun mainRenderStr(context: Context, argsStr: String): String {
207+
createConfig()
208+
209+
val args = tokenizeUserCommand(argsStr)
210+
val toml = Toml {
211+
ignoreUnknownKeys = true
212+
}
213+
val tomlConfig = Paths.get(parseConfigArg(context, args)).readText()
214+
.replace("\\e[", "\\u001B[") // Escape ANSI codes
215+
val config: Config
216+
try {
217+
config = toml.decodeFromString(Config.serializer(), tomlConfig)
218+
} catch (e: SerializationException) {
219+
return e.message.toString()
220+
}
221+
return parseArgs(context, args, config)
222+
}
223+
224+
223225
fun mainRender(context: Context, appWidgetId: Int, argsStr: String): List<SpannableStringBuilder> {
224226
createConfig()
225227

0 commit comments

Comments
 (0)