Last active
December 25, 2023 14:50
-
-
Save shalva97/a705590f2c0e309374cccc7f6bd667cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
val prefix = "kwriteconfig5 --file \$HOME/.config/kde.org/UserFeedback.org.kde.plasmashell.conf" | |
val config = """ | |
[Greeter][Wallpaper][org.kde.image][General] | |
Image=file:///home/shalva/Pictures/lock-screen-wallpaper.jpg | |
""".trimIndent() | |
var configCommand = StringBuilder() | |
var groupCommand = "" | |
config.lines().filter { it.isNotEmpty() }.forEach { | |
if (it.startsWith("[")) { | |
groupCommand = "" | |
it.replace("]", "") | |
.split("[") | |
.filter { it.isNotEmpty() } | |
.forEach { group -> | |
groupCommand += "--group \"$group\" " | |
} | |
} else { | |
("$prefix $groupCommand--key \"" + it.split("=") | |
.joinToString("\" \"").plus("\"\n")).run(configCommand::append) | |
} | |
} | |
print(configCommand) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
try it onlin