Compare commits

..
Author SHA1 Message Date
The412Banner 078a2d18dd fix(battlenet): Install or Resume of a game Battle.net already has updates that install instead of failing with error 801 2026-11-25 07:05:42 +00:00
MaxsTechReview 19d8819137 fix(battlenet): drop the unused runtime drive and list its games under the runtime path (#3188)
* fix(battlenet): drop the unused runtime drive and list its games under the runtime path

* fix(battlenet): read product.db paths decoded and keep alias-saved folders

* fix(battlenet): keep drives for paths that climb out of the runtime

* fix(battlenet): keep a drive referenced with any separator spelling

* fix(battlenet): check decoded config values before dropping a drive
2026-11-24 23:29:32 -05:00
Kurt Himebauch 1b80b506cb Default gamescope cursor drawing to on (#3187) 2026-11-24 21:40:15 -05:00
4b289a4802 fix(battlenet): games installed inside the runtime stay listed after a native session (#3148)
* fix(battlenet): games installed inside the runtime stay listed after a native session

* test(battlenet): expect the shared folder for a lone Forever install

---------

Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
Co-authored-by: maxjivi05 <maxjividen@gmail.com>
2026-11-24 21:12:33 -05:00
MaxsTechReview 238ef76c5c fix(preload): apps that reload libudev no longer crash in the input wrappers (#3180)
fix(preload): keep libudev loaded while the input wrappers use it

Programs that close libudev and open it again crashed in the next wrapped
udev call: the wrappers kept function pointers into the unmapped copy.
Pin libudev with RTLD_NODELETE when it is opened so those pointers and
the stored handle stay valid.
2026-11-24 20:19:53 -05:00
Kurt Himebauch 906e66e3cf fix(library): added-games selection edge cases from #2818 review (#3177)
fix(library): saved exes skip store games that are updating
2026-11-24 19:26:44 -05:00
Kurt Himebauch c0d14f9632 fix(xbox): an application element with attributes on the next line still counts (#3175)
* fix(xbox): an application element with attributes on the next line still counts

* fix(xbox): repair the patch hunk for the pretty-printed manifest test
2026-11-24 19:26:04 -05:00
Kurt Himebauch 70bda85dd5 fix(desktop): the SteamOS panel layout replaces an older or Kubuntu-default panel (#3173)
* fix(desktop): a Kubuntu-default panel gets the SteamOS layout and launcher icon

* fix(desktop): lay out Plasma's stock panel with the SteamOS pins, once, over an older panel

* fix(desktop): keep Plasma's wide-screen cap and input-method panel in the SteamOS layout

* fix(desktop): stamp the panel layout only after the old panel is backed up, never over a backup
2026-11-24 19:25:59 -05:00
16 changed files with 684 additions and 34 deletions

No files matched your search

@@ -190,7 +190,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
private var prootNoSeccomp by mutableStateOf(false)
private var prootFastPath by mutableStateOf(true)
private var nativeUserland by mutableStateOf(true)
private var cursorComposite by mutableStateOf(false)
private var cursorComposite by mutableStateOf(true)
private var guestHostname by mutableStateOf(SessionPrefs.DEFAULT_GUEST_HOSTNAME)
private var phantomWarning by mutableStateOf<String?>(null)
private var phantomProcessStatus by mutableStateOf(PhantomProcessStatus.NOT_APPLICABLE)
@@ -239,6 +239,7 @@ object AddedGames {
for (entry in AddedExes.list(context)) {
val folder = File(entry.folder)
if (folder.path in removed || !folder.isDirectory) continue
if (StoreGameSidecar.read(folder)?.isInstalled == false) continue
scanGame(context, folder, out, single = entry, reuse = true)
}
for (folder in libraryDepotInstalls(context)) if (folder.path !in removed) scanGame(context, folder, out, reuse = true)
@@ -337,9 +338,10 @@ object AddedGames {
val owner = ownerFolder(app, exe)
if (owner != null && owner.path !in SessionPrefs.removedAddedGames(app)) {
single(app, owner.path)?.takeIf { canonical(it.exe) == path }?.let {
if (guestPath(app, it.exe) != null) {
SessionPrefs.setAddedGameExe(app, owner.path, it.exe.path)
AddedExes.put(app, AddedExes.Entry(owner.path, it.exe.path))
val keep = listOf(it.exe, exe).firstOrNull { f -> guestPath(app, f) != null }
if (keep != null) {
SessionPrefs.setAddedGameExe(app, owner.path, keep.path)
AddedExes.put(app, AddedExes.Entry(owner.path, keep.path))
}
return AddResult.Existing(it)
}
@@ -207,7 +207,8 @@ object BattleNet {
val taken = HashSet<File>()
fun options(title: Title, folder: File) = listOfNotNull(folder, title.flavor?.let { File(folder, it) }?.takeIf { it.isDirectory })
for ((code, game) in games) {
val keep = saved[code]?.let(::File)?.takeIf { it in options(game.first, game.second) && it !in taken } ?: continue
val want = saved[code]?.let { runCatching { File(it).canonicalFile }.getOrNull() } ?: continue
val keep = options(game.first, game.second).firstOrNull { runCatching { it.canonicalFile }.getOrNull() == want }?.takeIf { it !in taken } ?: continue
out[code] = keep
taken.add(keep)
}
@@ -244,6 +245,14 @@ object BattleNet {
"/" + rootfs.relativize(resolved).joinToString("/")
}
}.trimEnd('/')
if (mapped?.startsWith("/") == true) {
val rootfs = LinuxRuntime.rootDir(context)
runCatching {
val home = rootfs.canonicalFile.toPath()
val host = File("$target/$relative").canonicalFile.toPath()
if (host.startsWith(home)) File(rootfs, home.relativize(host).toString()) else null
}.getOrNull()?.let { return it }
}
return com.droiddeck.launcher.frontend.AddedGames.hostPath(context, "$target/$relative")
}
@@ -1042,7 +1042,7 @@ object SessionPrefs {
prefs(context).edit().putBoolean("prootFastPath", on).apply()
}
fun cursorComposite(context: Context): Boolean = prefs(context).getBoolean("cursorComposite", false)
fun cursorComposite(context: Context): Boolean = prefs(context).getBoolean("cursorComposite", true)
fun setCursorComposite(context: Context, on: Boolean) {
prefs(context).edit().putBoolean("cursorComposite", on).apply()
@@ -114,8 +114,11 @@ object BattleNetInstall {
internal const val UPDATE_FOLDER = "updateFolder"
internal const val STALLED = "stalled"
internal fun registered(context: Context, id: String): BattleNet.Game? =
runCatching { BattleNet.games(context).firstOrNull { it.uid == id } }.getOrNull()
internal fun installUid(context: Context, game: InstalledStoreGame): String =
runCatching { BattleNet.games(context).firstOrNull { it.uid == game.sidecar.id }?.installUid }.getOrNull() ?: game.sidecar.id
registered(context, game.sidecar.id)?.installUid ?: game.sidecar.id
fun uninstall(context: Context, game: InstalledStoreGame): Boolean {
if (product(game.sidecar.id) == null || !BattleNet.installed(context)) return false
@@ -243,6 +246,7 @@ internal class BattleNetInstaller(
private val ended = java.util.concurrent.CountDownLatch(1)
private var before = 0L
private var kept = -1L
@Volatile private var registered: BattleNet.Game? = null
override fun run(handle: DownloadQueue.JobHandle): String? {
started.set(true)
@@ -259,12 +263,17 @@ internal class BattleNetInstaller(
if (!BattleNet.installed(app)) throw IllegalStateException(app.getString(R.string.bnet_dl_client_first))
val title = BattleNet.title(item.id)
val product = title?.product ?: throw IllegalStateException(app.getString(R.string.bnet_dl_failed, item.id))
val uid = item.extra[BattleNetInstall.INSTALL_UID] ?: title.uid
if (!update) folder.mkdirs()
val guest = AddedGames.guestPath(app, folder) ?: throw IllegalStateException(app.getString(R.string.bnet_dl_failed, folder.path))
val (country, region) = BattleNetInstall.country(Locale.getDefault())
val args = if (update) listOf("agent-update", uid)
else listOf("agent-install", uid, product, guest, BattleNetInstall.localeTag(app), country, region)
val registered = (if (update) null else BattleNetInstall.registered(app, title.uid)).also { this.registered = it }
val updating = update || registered != null
val target = registered?.folder ?: folder
val uid = registered?.installUid ?: item.extra[BattleNetInstall.INSTALL_UID] ?: title.uid
val args = if (updating) listOf("agent-update", uid)
else {
folder.mkdirs()
val guest = AddedGames.guestPath(app, folder) ?: throw IllegalStateException(app.getString(R.string.bnet_dl_failed, folder.path))
val (country, region) = BattleNetInstall.country(Locale.getDefault())
listOf("agent-install", uid, product, guest, BattleNetInstall.localeTag(app), country, region)
}
var done: JSONObject? = null
var reason: String? = null
val code = BattleNetInstall.run(app, args, cancelled) { line ->
@@ -280,13 +289,13 @@ internal class BattleNetInstaller(
}
if (cancelled.get()) return null
if (done == null) throw IllegalStateException(BattleNetInstall.failure(app, reason, code))
handle.log("Battle.net: ${item.title} ${if (update) "updated" else "installed"} ${done?.optString("version").orEmpty()}".trimEnd())
handle.log("Battle.net: ${item.title} ${if (updating) "updated" else "installed"} ${done?.optString("version").orEmpty()}".trimEnd())
StoresState.post {
BattleNetInstall.updates.remove(item.id)
StoresState.notifyLibraryChanged(app)
}
BattleNetInstall.check(item.id, folder, force = true)
return folder.absolutePath
BattleNetInstall.check(item.id, target, force = true)
return target.absolutePath
}
private fun progress(handle: DownloadQueue.JobHandle, status: JSONObject) {
@@ -308,9 +317,14 @@ internal class BattleNetInstaller(
val uid = item.extra[BattleNetInstall.INSTALL_UID] ?: BattleNet.title(item.id)?.uid ?: return
Thread({
if (started.get() && !ended.await(END_WAIT_S, TimeUnit.SECONDS)) Log.w("BattleNetInstall", "the cancelled install of $uid is still stopping")
val gone = BattleNetInstall.agentUninstall(app, uid)
val existing = registered
val gone = existing == null && BattleNetInstall.agentUninstall(app, uid)
if (folder.isDirectory && (gone || folder.list().isNullOrEmpty())) com.droiddeck.launcher.core.FileUtils.delete(folder)
Log.i("BattleNetInstall", "cancelled install of $uid: ${if (gone) "removed" else "left for Battle.net to remove"}")
Log.i("BattleNetInstall", "cancelled install of $uid: " + when {
existing != null -> "Battle.net already had it in ${existing.folder}"
gone -> "removed"
else -> "left for Battle.net to remove"
})
}, "battlenet-cancel").start()
}
}
+1 -1
View File
@@ -672,7 +672,7 @@
<string name="perf_fastpath_needs_seccomp">Needs proot\'s seccomp filter.</string>
<string name="perf_fastpath_hint">Faster file lookups and less stutter. Turn off if a program can\'t find its files.</string>
<string name="perf_cursor_composite">Draw the cursor inside gamescope</string>
<string name="perf_cursor_composite_hint">Gamescope paints the pointer itself instead of handing it to Android. Turn on for a controller-driven cursor. Off is faster on a phone. Applies next session.</string>
<string name="perf_cursor_composite_hint">Gamescope paints the pointer itself instead of handing it to Android. Applies next session.</string>
<string name="perf_identity">Session identity</string>
<string name="perf_hostname">Host name</string>
<string name="perf_hostname_hint">The name Steam sees for this device. Blank restores %1$s.</string>
@@ -137,4 +137,30 @@ class AddedGamesStoreScanTest {
val game = AddedGames.scan(app).single { it.folder.absolutePath == folder.absolutePath }
assertEquals("/root/Games/Stores/GOG/Witcher Game", game.guestDir)
}
@Test fun aStoreGameThatIsUpdatingIsNotListedThroughItsSavedExe() {
val folder = install(Store.GOG, "upd", "Updating GOG", "Binaries/Game.exe", launcher = true)
val own = File(folder, "Binaries/Game.exe")
assertTrue(AddedGames.addExe(app, own) is AddedGames.AddResult.Existing)
assertTrue(AddedGames.scan(app).any { it.folder.absolutePath == folder.absolutePath })
StoreGameSidecar.read(folder)!!.copy(state = StoreGameSidecar.STATE_UPDATING).write(folder)
assertTrue(AddedGames.scan(app).none { it.folder.absolutePath == folder.absolutePath })
}
@Test fun reselectingTheMappedExeReplacesAnUnmappedAliasOfIt() {
val folder = install(Store.EPIC, "alias", "Alias Epic", "Binaries/Game.exe", launcher = true)
val own = File(folder, "Binaries/Game.exe")
val alias = File(java.nio.file.Files.createTempDirectory("alias").toFile(), "bin")
try {
java.nio.file.Files.createSymbolicLink(alias.toPath(), File(folder, "Binaries").toPath())
} catch (e: Exception) {
org.junit.Assume.assumeNoException(e)
}
val aliased = File(alias, "Game.exe")
assertNull(AddedGames.guestPath(app, aliased))
SessionPrefs.setAddedGameExe(app, folder.path, aliased.path)
assertTrue(AddedGames.addExe(app, own) is AddedGames.AddResult.Existing)
assertEquals(own.path, SessionPrefs.addedGameExe(app, folder.path))
assertEquals(own.path, AddedExes.list(app).single { it.folder == folder.path }.exe)
}
}
@@ -216,6 +216,41 @@ class BattleNetTest {
assertNull(BattleNet.hostFolder(context, "G:\\etc\\passwd"))
}
@Test fun aDriveAtTheAppDataFolderHoldingTheRuntimeListsTheGamesInside() {
val root = LinuxRuntime.rootDir(context)
val data = context.filesDir.parentFile!!
val pfx = File(BattleNet.prefix(context), "pfx")
val devices = File(pfx, "dosdevices").apply { mkdirs() }
java.nio.file.Files.createSymbolicLink(File(devices, "d:").toPath(), data.absoluteFile.toPath())
java.nio.file.Files.createSymbolicLink(File(devices, "e:").toPath(), java.nio.file.Paths.get("/root/Games/Card"))
val wow = File(root, "root/Games/Stores/Battle.net/World of Warcraft").apply { mkdirs() }
File(wow, "_forever_").mkdirs()
val drive = "D:/" + data.absoluteFile.toPath().relativize(wow.absoluteFile.toPath()).joinToString("/")
File(pfx, "drive_c/ProgramData/Battle.net/Agent").mkdirs()
File(pfx, "drive_c/ProgramData/Battle.net/Agent/product.db").writeBytes(message(
field(1, message(field(1, "wowf"), field(2, "wowf"), field(3, message(field(1, drive))))),
))
assertEquals(wow, BattleNet.hostFolder(context, drive))
assertEquals(wow, BattleNet.games(context).single().folder)
assertEquals(File(root, "root/Games/Card/Battle.net/X"), BattleNet.hostFolder(context, "E:\\Battle.net\\X"))
assertNull(BattleNet.hostFolder(context, "D:\\..\\etc"))
}
@Test fun aDriveAtAnAliasOfTheAppDataFolderListsTheGameUnderTheRuntimePath() {
val root = LinuxRuntime.rootDir(context)
val data = context.filesDir.parentFile!!
val alias = File(data.parentFile, "alias-" + data.name)
java.nio.file.Files.createSymbolicLink(alias.toPath(), data.absoluteFile.toPath())
try {
val devices = File(BattleNet.prefix(context), "pfx/dosdevices").apply { mkdirs() }
java.nio.file.Files.createSymbolicLink(File(devices, "d:").toPath(), alias.absoluteFile.toPath())
val game = File(root, "root/Games/Stores/Battle.net/StarCraft").apply { mkdirs() }
val drive = "D:\\" + data.absoluteFile.toPath().relativize(game.absoluteFile.toPath()).joinToString("\\")
assertEquals(game.path, BattleNet.hostFolder(context, drive)?.path)
} finally {
java.nio.file.Files.delete(alias.toPath())
}
}
@Test fun wowForeverIsListedBesideRetailInTheSharedWorldOfWarcraftFolder() {
val pfx = File(BattleNet.prefix(context), "pfx").apply { mkdirs() }
@@ -256,6 +291,25 @@ class BattleNetTest {
.map { Triple(it.uid, it.path, it.product) })
}
@Test fun aTitleBattleNetAlreadyInstalledIsFoundWithItsOwnUidAndFolder() {
val pfx = File(BattleNet.prefix(context), "pfx").apply { mkdirs() }
val wow = File(pfx, "drive_c/Games/World of Warcraft").apply { mkdirs() }
File(pfx, "drive_c/Games/StarCraft").mkdirs()
val db = File(pfx, "drive_c/ProgramData/Battle.net/Agent/product.db").apply { parentFile!!.mkdirs() }
db.writeBytes(message(
field(1, message(field(1, "wowf_live"), field(2, "wowf"), field(3, message(field(1, "C:/Games/World of Warcraft"))))),
field(1, message(field(1, "s1"), field(2, "s1"), field(3, message(field(1, "C:/Games/StarCraft"))),
field(4, message(field(1, message(varintField(1, 0))))))),
))
val forever = com.droiddeck.launcher.stores.battlenet.BattleNetInstall.registered(context, "wow_forever")!!
assertEquals("wowf_live", forever.installUid)
assertEquals(wow, forever.folder)
assertNull(com.droiddeck.launcher.stores.battlenet.BattleNetInstall.registered(context, "s1"))
assertNull(com.droiddeck.launcher.stores.battlenet.BattleNetInstall.registered(context, "wow"))
db.delete()
assertNull(com.droiddeck.launcher.stores.battlenet.BattleNetInstall.registered(context, "wow_forever"))
}
@Test fun aGameKeepsTheFolderItWasListedWithWhenAnotherVersionComesOrGoes() {
val root = File(context.filesDir, "World of Warcraft").apply { mkdirs() }
val retailDir = File(root, "_retail_").apply { mkdirs() }
@@ -274,6 +328,21 @@ class BattleNetTest {
assertEquals(mapOf("WoWF" to root), BattleNet.ownFolders(mapOf("WoWF" to (forever to root)), mapOf("WoWF" to "/elsewhere")))
}
@Test fun aFolderSavedThroughAnAliasOfTheAppDataFolderIsKept() {
val data = context.filesDir.parentFile!!
val root = File(context.filesDir, "World of Warcraft").apply { mkdirs() }
val foreverDir = File(root, "_forever_").apply { mkdirs() }
val forever = BattleNet.title("wow_forever")!!
val alias = File(data.parentFile, "alias-" + data.name)
java.nio.file.Files.createSymbolicLink(alias.toPath(), data.absoluteFile.toPath())
try {
val saved = File(alias, data.absoluteFile.toPath().relativize(foreverDir.absoluteFile.toPath()).toString()).path
assertEquals(mapOf("WoWF" to foreverDir), BattleNet.ownFolders(mapOf("WoWF" to (forever to root)), mapOf("WoWF" to saved)))
} finally {
java.nio.file.Files.delete(alias.toPath())
}
}
@Test fun theListedFolderIsRememberedAcrossScans() {
val pfx = File(BattleNet.prefix(context), "pfx").apply { mkdirs() }
val wow = File(pfx, "drive_c/Program Files (x86)/World of Warcraft").apply { mkdirs() }
+87
View File
@@ -34,6 +34,93 @@ ln -sf /usr/local/bin/droiddeck-steam-launch /usr/local/bin/steamdeck-steam 2>/d
ln -sf /usr/local/bin/droiddeck-steam-shim /usr/local/bin/steam 2>/dev/null
python3 /usr/local/bin/droiddeck-desktop-games 2>&1 | sed 's/^/[games] /'
python3 /usr/local/bin/droiddeck-desktop-programs 2>&1 | sed 's/^/[programs] /'
# Plasma lays out the SteamOS panel only for a profile without one. The layout is written at every
# start, and a panel made before this version (Kubuntu's own, or the first SteamOS one without the
# pager, clock and Plasma's stock pins) is set aside once so Plasma lays out the current one.
dd_layout=/usr/share/plasma/look-and-feel/com.valve.vapor.desktop/contents/layouts
if [ -d "$dd_layout" ]; then
cat > "$dd_layout/org.kde.plasma.desktop-layout.js" <<'LAYOUT'
var desktops = desktopsForActivity(currentActivity());
for (var i = 0; i < desktops.length; i++) {
desktops[i].wallpaperPlugin = "org.kde.image";
desktops[i].currentConfigGroup = ["Wallpaper", "org.kde.image", "General"];
desktops[i].writeConfig("Image", "file:///usr/share/wallpapers/DroidDeck");
}
var panel = new Panel;
var panelScreen = panel.screen;
panel.location = "bottom";
panel.height = 2 * Math.ceil(gridUnit * 2.5 / 2);
const maximumAspectRatio = 21 / 9;
if (panel.formFactor === "horizontal") {
const geo = screenGeometry(panelScreen);
const maximumWidth = Math.ceil(geo.height * maximumAspectRatio);
if (geo.width > maximumWidth) {
panel.alignment = "center";
panel.minimumLength = maximumWidth;
panel.maximumLength = maximumWidth;
}
}
var kickoff = panel.addWidget("org.kde.plasma.kickoff");
kickoff.currentConfigGroup = ["Shortcuts"];
kickoff.writeConfig("global", "Alt+F1");
kickoff.currentConfigGroup = ["General"];
kickoff.writeConfig("icon", "distributor-logo-steamdeck");
kickoff.writeConfig("favorites", [
"preferred://browser",
"applications:org.kde.dolphin.desktop",
"applications:org.kde.konsole.desktop",
"applications:org.kde.kate.desktop",
"applications:org.kde.discover.desktop",
"applications:systemsettings.desktop",
]);
panel.addWidget("org.kde.plasma.pager");
var tasks = panel.addWidget("org.kde.plasma.icontasks");
tasks.currentConfigGroup = ["General"];
tasks.writeConfig("launchers", [
"applications:steamdeck-steam.desktop",
"applications:systemsettings.desktop",
"applications:org.kde.discover.desktop",
"preferred://filemanager",
"preferred://browser",
"applications:org.kde.konsole.desktop",
"applications:org.kde.kate.desktop",
]);
panel.addWidget("org.kde.plasma.marginsseparator");
const inputMethodLanguages = ["as", "bn", "bo", "brx", "doi", "gu", "hi", "ja", "kn", "ko", "kok", "ks", "lep", "mai",
"ml", "mni", "mr", "ne", "or", "pa", "sa", "sat", "sd", "si", "ta", "te", "th", "ur", "vi", "zh_CN", "zh_TW"];
if (inputMethodLanguages.indexOf(languageId) != -1) {
panel.addWidget("org.kde.plasma.kimpanel");
}
var tray = panel.addWidget("org.kde.plasma.systemtray");
var trayId = tray.readConfig("SystrayContainmentId");
if (trayId) {
var trayContainment = desktopById(trayId);
trayContainment.currentConfigGroup = ["General"];
trayContainment.writeConfig("scaleIconsToFit", true);
}
var clock = panel.addWidget("org.kde.plasma.digitalclock");
clock.currentConfigGroup = ["Appearance"];
clock.writeConfig("dateFormat", "isoDate");
panel.addWidget("org.kde.plasma.showdesktop");
LAYOUT
fi
dd_panel_rc="${XDG_CONFIG_HOME:-$HOME/.config}/plasma-org.kde.plasma.desktop-appletsrc"
dd_panel_stamp="${XDG_CONFIG_HOME:-$HOME/.config}/droiddeck-panel-layout"
if [ "$(cat "$dd_panel_stamp" 2>/dev/null)" != steamos-2 ]; then
dd_panel_backup="$dd_panel_rc.before-steamos-2"
[ -e "$dd_panel_backup" ] && dd_panel_backup="$dd_panel_backup.$$"
if [ ! -f "$dd_panel_rc" ] || mv "$dd_panel_rc" "$dd_panel_backup"; then
mkdir -p "$(dirname "$dd_panel_stamp")" && echo steamos-2 > "$dd_panel_stamp"
fi
fi
# startplasma applies this file over the session environment, and keeps what an earlier session wrote.
kwriteconfig6 --file plasma-localerc --group Formats --key LANG "${LANG:-C.UTF-8}"
if [ -n "${LANGUAGE:-}" ]; then
@@ -299,6 +299,27 @@ def map_drive(root, volume):
return None
def rootfs():
host = os.environ.get("DDNATV_ROOT")
return os.path.realpath(host) if host else None
def guest_path(path):
host = rootfs()
if not host or not inside(path, host):
return None
return "/" + path[len(host):].strip("/")
def rootfs_drive(root, text):
found = re.match(r"(?i)^([abd-y]):[\\/]", text)
host = rootfs()
if not found or not host:
return False
link = os.path.join(dosdevices(root), found.group(1).lower() + ":")
return os.path.islink(link) and inside(host, os.path.realpath(link))
def install_path(root, library):
library = library.rstrip("/") or "/"
try:
@@ -308,6 +329,9 @@ def install_path(root, library):
return "Z:" + library
if volume == "/":
return "Z:" + library
host = rootfs()
if host and inside(host, volume):
return "Z:" + (guest_path(path) or library)
drive = mapped_drive(root, path, volume)
if drive is None and not wine_processes(os.path.join(prefix(root), "pfx")):
drive = map_drive(root, volume)
@@ -586,11 +610,15 @@ def drive_folder(root, value):
text = value.decode("utf-8")
except UnicodeDecodeError:
return value
if not re.match(r"(?i)^z:[\\/]", text):
holds_root = rootfs_drive(root, text)
if not holds_root and not re.match(r"(?i)^z:[\\/]", text):
return value
folder = windows_path(root, text)
if not folder or not os.path.isdir(folder):
return value
if holds_root:
guest = guest_path(os.path.realpath(folder))
return value if guest is None else ("Z:" + guest).encode("utf-8")
moved = install_path(root, folder)
return value if moved.startswith("Z:") else moved.replace("\\", "/").encode("utf-8")
@@ -608,11 +636,115 @@ def move_installs(root):
return False
except (OSError, ValueError):
return False
write_bytes(path, moved)
return True
def rootfs_drives(root):
host = rootfs()
folder = dosdevices(root)
if not host:
return {}
try:
names = sorted(os.listdir(folder))
except OSError:
return {}
drives = {}
for name in names:
link = os.path.join(folder, name)
if len(name) == 2 and name[0].lower() in DRIVES and name[1] == ":" and os.path.islink(link):
target = os.path.realpath(link)
if inside(host, target):
drives[name[0].lower()] = host[len(target):].strip("/")
return drives
def write_bytes(path, data):
with open(path + ".tmp", "wb") as f:
f.write(moved)
f.write(data)
shutil.copymode(path, path + ".tmp")
os.replace(path + ".tmp", path)
return True
def install_folders(root):
try:
with open(os.path.join(drive_c(root), *PRODUCT_DB), "rb") as f:
data = f.read()
except FileNotFoundError:
return []
folders = []
rewrite_field(data, INSTALL_FOLDER, lambda value: folders.append(value) or value)
return folders
def json_strings(value):
if isinstance(value, str):
yield value
elif isinstance(value, dict):
for key, item in value.items():
yield key
yield from json_strings(item)
elif isinstance(value, list):
for item in value:
yield from json_strings(item)
def escapes(tail):
depth = 0
for part in re.split(rb"[\\/]+", tail):
if part == b"..":
depth -= 1
if depth < 0:
return True
elif part and part != b".":
depth += 1
return False
def drop_rootfs_drives(root):
pfx = os.path.join(prefix(root), "pfx")
drives = rootfs_drives(root)
if not drives or wine_processes(pfx):
return []
try:
folders = install_folders(root)
except ValueError:
return []
texts = {}
for path in (os.path.join(pfx, "system.reg"), os.path.join(pfx, "user.reg"), os.path.join(drive_c(root), *CONFIG)):
try:
with open(path, "rb") as f:
texts[path] = f.read()
except FileNotFoundError:
pass
sep = rb"(?:\\\\|/)"
changed = dict(texts)
for letter, rest in drives.items():
head = rb"(?<![A-Za-z0-9])[" + letter.encode() + letter.upper().encode() + rb"]:"
inner = b"".join(sep + re.escape(part.encode()) for part in rest.split("/") if part)
for path in changed:
changed[path] = re.sub(head + inner + rb"(?=(" + sep + rb"[^\"\r\n]*))",
lambda m: m.group(0) if escapes(m.group(1)) else b"Z:", changed[path])
for path, data in changed.items():
if data != texts[path]:
write_bytes(path, data)
seen = list(changed.values())
config = os.path.join(drive_c(root), *CONFIG)
if config in changed:
try:
seen += [text.encode("utf-8", "replace") for text in json_strings(json.loads(changed[config].decode("utf-8-sig")))]
except ValueError:
return []
dropped = []
for letter in sorted(drives):
drive = letter.encode() + letter.upper().encode()
used = rb"(?<![A-Za-z0-9])[" + drive + rb"]:[\\/]"
if any(re.match(rb"[" + drive + rb"]:[\\/]", folder.lstrip()) for folder in folders):
continue
if not any(re.search(used, data) for data in seen):
os.unlink(os.path.join(dosdevices(root), letter + ":"))
dropped.append(letter)
return dropped
def wow_folders(root):
@@ -725,9 +857,14 @@ def configure(root, library=None):
return
try:
if move_installs(root):
say("Battle.net's installed games on a mapped volume now use its Wine drive")
say("Battle.net's installed games now use the Wine drive of their volume")
except OSError as error:
say("Battle.net's installed games not moved to their Wine drive: %s" % error)
try:
for letter in drop_rootfs_drives(root):
say("Wine drive %s: held the runtime and is no longer used; removed" % letter.upper())
except OSError as error:
say("Battle.net's unused runtime drive not removed: %s" % error)
try:
wallpaper(root)
except OSError as error:
+5 -3
View File
@@ -419,9 +419,11 @@ static void *real_dlsym(void);
* searches, so the handle the program opened is the only way back to the real implementation. */
static _Atomic(void *) udev_handle;
__attribute__((visibility("hidden"))) void bl_inputudev_note_dlopen(const char *path, void *handle) {
if (handle != NULL && path != NULL && strstr(path, "libudev") != NULL)
atomic_store_explicit(&udev_handle, handle, memory_order_release);
__attribute__((visibility("hidden"))) void bl_inputudev_note_dlopen(const char *path, void *handle,
void *(*open)(const char *, int)) {
if (handle == NULL || path == NULL || strstr(path, "libudev") == NULL) return;
if (open(path, RTLD_LAZY | RTLD_NOLOAD | RTLD_NODELETE) == NULL) return;
atomic_store_explicit(&udev_handle, handle, memory_order_release);
}
static void *next_symbol(const char *name) {
+3 -2
View File
@@ -100,7 +100,8 @@ static long path_statx(int dirfd, const char *path, int flags, unsigned int mask
return next_statx(dirfd, path, flags, mask, out);
}
void bl_inputudev_note_dlopen(const char *path, void *handle) __attribute__((weak, visibility("hidden")));
void bl_inputudev_note_dlopen(const char *path, void *handle, void *(*open)(const char *, int))
__attribute__((weak, visibility("hidden")));
void *dlopen(const char *filename, int flags) {
void *handle;
@@ -114,7 +115,7 @@ void *dlopen(const char *filename, int flags) {
flags &= ~RTLD_DEEPBIND;
}
handle = real_dlopen != NULL ? real_dlopen(filename, flags) : NULL;
if (handle != NULL && bl_inputudev_note_dlopen != NULL) bl_inputudev_note_dlopen(filename, handle);
if (handle != NULL && bl_inputudev_note_dlopen != NULL) bl_inputudev_note_dlopen(filename, handle, real_dlopen);
return handle;
}
+128
View File
@@ -376,6 +376,134 @@ class DriveTest(Temp):
self.assertEqual(os.readlink(self.devices / "d:"), str(self.card))
self.assertFalse(BNET["move_installs"](self.root))
def test_the_volume_holding_the_native_rootfs_gets_no_drive(self):
rootfs = self.card / "files/linuxfs"
library = rootfs / "root/Games/Stores/Battle.net"
library.mkdir(parents=True)
with mock.patch.dict(os.environ, {"DDNATV_ROOT": str(rootfs)}):
self.assertEqual(BNET["install_path"](self.root, str(library)), "Z:/root/Games/Stores/Battle.net")
self.assertEqual(BNET["install_path"](self.root, str(self.library)), "Z:" + str(self.library))
self.assertFalse(self.devices.exists())
self.assertEqual(BNET["install_path"](self.root, str(self.library)), "D:\\Games\\Battle.net")
def test_games_moved_to_a_drive_holding_the_native_rootfs_go_back_to_the_root_drive(self):
rootfs = self.card / "files/linuxfs"
game = rootfs / "root/Games/Stores/Battle.net/World of Warcraft"
game.mkdir(parents=True)
card = self.tmp / "sd"
(card / "Diablo").mkdir(parents=True)
self.devices.mkdir(parents=True)
os.symlink(str(self.card), self.devices / "d:")
os.symlink(str(card), self.devices / "e:")
client = self.product("battle.net", "C:/Program Files (x86)/Battle.net")
sd = self.product("d3", "E:/Diablo")
gone = self.product("gone", "D:/files/linuxfs/root/Games/Missing")
path = self.database(client, self.product("wowf", "D:/files/linuxfs/root/Games/Stores/Battle.net/World of Warcraft"), sd, gone)
before = path.read_bytes()
self.assertFalse(BNET["move_installs"](self.root))
self.assertEqual(path.read_bytes(), before)
with mock.patch.dict(os.environ, {"DDNATV_ROOT": str(rootfs)}):
self.assertTrue(BNET["move_installs"](self.root))
self.assertEqual(path.read_bytes(), client + self.product("wowf", "Z:/root/Games/Stores/Battle.net/World of Warcraft")
+ sd + gone + self.field(7, b"tail"))
self.assertFalse(BNET["move_installs"](self.root))
def rootfs_prefix(self):
rootfs = self.card / "files/linuxfs"
game = rootfs / "root/Games/Stores/Battle.net/World of Warcraft"
game.mkdir(parents=True)
card = self.tmp / "sd"
card.mkdir()
self.devices.mkdir(parents=True)
for letter, target in (("d", self.card), ("e", card), ("s", self.card)):
os.symlink(str(target), self.devices / (letter + ":"))
pfx = self.devices.parent
system = pfx / "system.reg"
system.write_text('[Software\\\\Uninstall\\\\wow] 1\n'
'"InstallLocation"="D:\\\\files\\\\linuxfs\\\\root\\\\Games\\\\Stores\\\\Battle.net\\\\World of Warcraft"\n'
'"DisplayIcon"="\\"d:\\\\files\\\\linuxfs\\\\root\\\\Games\\\\Wow.exe\\""\n'
'"Card"="E:\\\\Diablo"\n"Other"="AD:\\\\files\\\\linuxfs\\\\x"\n')
system.chmod(0o640)
config = Path(BNET["drive_c"](self.root)).joinpath(*BNET["CONFIG"])
config.parent.mkdir(parents=True)
config.write_text(json.dumps({"Client": {"Install": {"DefaultInstallPath": "D:\\files\\linuxfs\\root\\Games\\Stores\\Battle.net"}}}))
self.database(self.product("wowf", "D:/files/linuxfs/root/Games/Stores/Battle.net/World of Warcraft"))
return rootfs, system, config
def test_an_unused_drive_holding_the_native_rootfs_is_removed_once_its_paths_use_the_root_drive(self):
rootfs, system, config = self.rootfs_prefix()
before = system.read_text()
self.assertEqual(BNET["drop_rootfs_drives"](self.root), [])
self.assertEqual(system.read_text(), before)
with mock.patch.dict(os.environ, {"DDNATV_ROOT": str(rootfs)}):
self.running = [(5, ["C:\\ProgramData\\Battle.net\\Agent\\Agent.exe"])]
self.assertEqual(BNET["drop_rootfs_drives"](self.root), [])
self.running = []
self.assertEqual(BNET["drop_rootfs_drives"](self.root), [])
self.assertTrue(os.path.islink(self.devices / "d:"))
self.assertTrue(BNET["move_installs"](self.root))
self.assertEqual(BNET["drop_rootfs_drives"](self.root), ["d"])
self.assertEqual(sorted(os.listdir(self.devices)), ["e:", "s:"])
self.assertEqual(system.read_text(), before.replace("D:\\\\files\\\\linuxfs\\\\root", "Z:\\\\root")
.replace("d:\\\\files\\\\linuxfs\\\\root", "Z:\\\\root"))
self.assertEqual(system.stat().st_mode & 0o777, 0o640)
self.assertEqual(json.loads(config.read_text())["Client"]["Install"]["DefaultInstallPath"], "Z:\\root\\Games\\Stores\\Battle.net")
self.assertTrue(self.card.is_dir())
self.assertTrue((rootfs / "root/Games/Stores/Battle.net/World of Warcraft").is_dir())
def test_a_drive_holding_the_native_rootfs_stays_while_a_path_outside_the_runtime_uses_it(self):
rootfs, system, _ = self.rootfs_prefix()
system.write_text(system.read_text() + '"Elsewhere"="D:\\\\Other\\\\Game"\n')
with mock.patch.dict(os.environ, {"DDNATV_ROOT": str(rootfs)}):
self.assertTrue(BNET["move_installs"](self.root))
self.assertEqual(BNET["drop_rootfs_drives"](self.root), [])
self.assertTrue(os.path.islink(self.devices / "d:"))
self.assertIn('"InstallLocation"="Z:\\\\root\\\\Games', system.read_text())
self.assertIn('"Elsewhere"="D:\\\\Other\\\\Game"', system.read_text())
def test_a_drive_holding_the_native_rootfs_stays_while_a_game_outside_the_runtime_is_installed_on_it(self):
rootfs, _, _ = self.rootfs_prefix()
for folder in ("D:/Other/" + "x" * 40, "D:\\Other\\" + "x" * 39, " D:/Other/" + "x" * 39):
with self.subTest(folder=folder):
self.database(self.product("wowf", "D:/files/linuxfs/root/Games/Stores/Battle.net/World of Warcraft"),
self.product("other", folder))
with mock.patch.dict(os.environ, {"DDNATV_ROOT": str(rootfs)}):
BNET["move_installs"](self.root)
self.assertEqual(BNET["drop_rootfs_drives"](self.root), [])
self.assertTrue(os.path.islink(self.devices / "d:"))
def test_a_path_that_climbs_out_of_the_runtime_keeps_its_drive(self):
rootfs, system, _ = self.rootfs_prefix()
up = '"Up"="D:\\\\files\\\\linuxfs\\\\root\\\\..\\\\..\\\\Other"\n'
system.write_text(system.read_text() + up)
with mock.patch.dict(os.environ, {"DDNATV_ROOT": str(rootfs)}):
BNET["move_installs"](self.root)
self.assertEqual(BNET["drop_rootfs_drives"](self.root), [])
self.assertTrue(os.path.islink(self.devices / "d:"))
self.assertIn(up, system.read_text())
self.assertIn('"InstallLocation"="Z:\\\\root\\\\Games', system.read_text())
def test_a_config_path_with_escaped_characters_keeps_its_drive(self):
rootfs, _, config = self.rootfs_prefix()
with mock.patch.dict(os.environ, {"DDNATV_ROOT": str(rootfs)}):
BNET["move_installs"](self.root)
settings = config.read_text()
for text in (settings[:-1] + ', "Other": "D:\\/Other\\/Game"}', settings[:-1] + ', "Other": "D\\u003a/Other/Game"}', '{"Client": '):
with self.subTest(text=text):
config.write_text(text)
self.assertEqual(BNET["drop_rootfs_drives"](self.root), [])
self.assertTrue(os.path.islink(self.devices / "d:"))
config.write_text(settings)
self.assertEqual(BNET["drop_rootfs_drives"](self.root), ["d"])
def test_an_unreadable_database_keeps_the_drive(self):
rootfs, _, _ = self.rootfs_prefix()
path = Path(BNET["drive_c"](self.root)) / "ProgramData/Battle.net/Agent/product.db"
path.write_bytes(b"\x0a\xff")
with mock.patch.dict(os.environ, {"DDNATV_ROOT": str(rootfs)}):
self.assertEqual(BNET["drop_rootfs_drives"](self.root), [])
self.assertTrue(os.path.islink(self.devices / "d:"))
def test_registrations_stay_while_the_prefix_runs_or_the_database_is_unreadable(self):
game = self.library / "World of Warcraft"
game.mkdir()
+110
View File
@@ -0,0 +1,110 @@
import os
from pathlib import Path
import subprocess
import tempfile
import unittest
ROOT = Path(__file__).resolve().parents[1]
DESKTOP = (ROOT / 'linuxfs/desktop/droiddeck-desktop').read_text()
OVERLAY_LAYOUT = (ROOT / 'ubuntu/overlay-desktop/usr/share/plasma/look-and-feel/com.valve.vapor.desktop'
'/contents/layouts/org.kde.plasma.desktop-layout.js').read_text()
LAYOUT_DIR = '/usr/share/plasma/look-and-feel/com.valve.vapor.desktop/contents/layouts'
RC = 'plasma-org.kde.plasma.desktop-appletsrc'
STAMP = 'droiddeck-panel-layout'
def block(first, last):
start = DESKTOP.index(first)
return DESKTOP[start:DESKTOP.index(last, start) + len(last)]
def run(script, home):
environment = {key: value for key, value in os.environ.items() if key != 'XDG_CONFIG_HOME'}
environment['HOME'] = str(home)
result = subprocess.run(['bash', '-c', script], env=environment, capture_output=True, text=True, timeout=5)
if result.returncode != 0:
raise AssertionError(result.stderr)
class DesktopSteamosPanelTest(unittest.TestCase):
def reset(self, home, panel=None, stamp=None):
config = home / '.config'
config.mkdir()
if panel is not None:
(config / RC).write_text(panel)
if stamp is not None:
(config / STAMP).write_text(stamp)
run(block('dd_panel_rc=', '\nfi\n'), home)
return config
def test_an_older_panel_is_set_aside_once_so_plasma_lays_out_the_current_one(self):
for panel in ('icon=start-here-kubuntu\n', 'icon=distributor-logo-steamdeck\n'):
with tempfile.TemporaryDirectory() as home:
config = self.reset(Path(home), panel)
self.assertFalse((config / RC).exists())
self.assertEqual(panel, (config / (RC + '.before-steamos-2')).read_text())
self.assertEqual('steamos-2', (config / STAMP).read_text().strip())
def test_an_earlier_backup_is_never_overwritten(self):
with tempfile.TemporaryDirectory() as home:
config = Path(home) / '.config'
config.mkdir()
(config / (RC + '.before-steamos-2')).write_text('original backup')
(config / RC).write_text('icon=start-here-kubuntu\n')
run(block('dd_panel_rc=', '\nfi\n'), Path(home))
self.assertEqual('original backup', (config / (RC + '.before-steamos-2')).read_text())
self.assertFalse((config / RC).exists())
self.assertEqual(1, len([entry for entry in config.iterdir() if entry.name.startswith(RC + '.before-steamos-2.')]))
self.assertEqual('steamos-2', (config / STAMP).read_text().strip())
def test_the_stamp_is_not_written_when_the_panel_could_not_be_moved(self):
with tempfile.TemporaryDirectory() as home:
config = Path(home) / '.config'
config.mkdir()
(config / RC).write_text('icon=start-here-kubuntu\n')
script = block('dd_panel_rc=', '\nfi\n').replace('mv "$dd_panel_rc"', 'false "$dd_panel_rc"')
run(script, Path(home))
self.assertTrue((config / RC).exists())
self.assertFalse((config / STAMP).exists())
def test_a_panel_laid_out_by_this_version_is_left_alone(self):
with tempfile.TemporaryDirectory() as home:
config = self.reset(Path(home), 'icon=my-logo\n', 'steamos-2\n')
self.assertEqual('icon=my-logo\n', (config / RC).read_text())
self.assertFalse((config / (RC + '.before-steamos-2')).exists())
def test_a_profile_without_a_panel_only_gets_the_stamp(self):
with tempfile.TemporaryDirectory() as home:
config = self.reset(Path(home))
self.assertEqual([STAMP], [entry.name for entry in config.iterdir()])
def test_the_layout_written_at_each_start_is_the_overlays(self):
with tempfile.TemporaryDirectory() as home:
target = Path(home) / 'layouts'
target.mkdir()
run(block('dd_layout=', '\nfi\n').replace(LAYOUT_DIR, target.as_posix()), home)
written = (target / 'org.kde.plasma.desktop-layout.js').read_text()
self.assertEqual(OVERLAY_LAYOUT.replace('\r\n', '\n').rstrip('\n'), written.rstrip('\n'))
def test_the_layout_follows_plasmas_stock_panel_with_the_steam_deck_launcher(self):
for widget in ('kickoff', 'pager', 'icontasks', 'marginsseparator', 'systemtray', 'digitalclock', 'showdesktop'):
self.assertIn('org.kde.plasma.' + widget, OVERLAY_LAYOUT)
self.assertIn('distributor-logo-steamdeck', OVERLAY_LAYOUT)
for pin in ('steamdeck-steam', 'systemsettings', 'org.kde.discover', 'preferred://filemanager', 'preferred://browser'):
self.assertIn(pin, OVERLAY_LAYOUT)
def test_the_layout_keeps_plasmas_stock_wide_screen_cap_and_input_method_panel(self):
self.assertIn('const maximumAspectRatio = 21 / 9;', OVERLAY_LAYOUT)
self.assertIn('panel.maximumLength = maximumWidth;', OVERLAY_LAYOUT)
self.assertIn('org.kde.plasma.kimpanel', OVERLAY_LAYOUT)
for language in ('ja', 'ko', 'th', 'zh_CN', 'zh_TW', 'hi'):
self.assertIn('"' + language + '"', OVERLAY_LAYOUT)
def test_the_panel_is_prepared_before_plasma_starts(self):
for marker in ('dd_layout=', 'dd_panel_rc='):
self.assertLess(DESKTOP.index(marker), DESKTOP.index('dbus-run-session -- startplasma-wayland'))
if __name__ == '__main__':
unittest.main()
+37
View File
@@ -223,6 +223,9 @@ PROGRAM = r"""
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <link.h>
#include <stdint.h>
#include <sys/mman.h>
#include <sys/sysmacros.h>
#include <unistd.h>
@@ -466,6 +469,36 @@ static void run_probe(void) {
printf("pad %d\n", new_device(&udev, PAD) != NULL);
}
static int loaded_span(struct dl_phdr_info *info, size_t size, void *data) {
uintptr_t *span = data;
int i;
(void)size;
if (info->dlpi_addr != span[0]) return 0;
for (i = 0; i < info->dlpi_phnum; i++)
if (info->dlpi_phdr[i].p_type == PT_LOAD && info->dlpi_phdr[i].p_vaddr + info->dlpi_phdr[i].p_memsz > span[1])
span[1] = info->dlpi_phdr[i].p_vaddr + info->dlpi_phdr[i].p_memsz;
return 1;
}
static void run_reload(const char *path) {
struct link_map *map = NULL;
uintptr_t span[2] = {0, 0};
void *first = enumerate_new(NULL);
void *second;
dlinfo(lib, RTLD_DI_LINKMAP, &map);
span[0] = map->l_addr;
dl_iterate_phdr(loaded_span, span);
dlclose(lib);
mmap((void *)span[0], span[1], PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED_NOREPLACE, -1, 0);
lib = dlopen(path, RTLD_NOW | RTLD_LOCAL);
enumerate_new = sym("udev_enumerate_new");
list = sym("udev_enumerate_get_list_entry");
second = enumerate_new(NULL);
printf("reload %s %s\n", entry_name(list(first)), entry_name(list(second)));
}
int main(int argc, char **argv) {
char link[4096];
@@ -510,6 +543,7 @@ int main(int argc, char **argv) {
else if (strcmp(argv[1], "every") == 0) run_every(argc - 3, argv + 3);
else if (strcmp(argv[1], "stable") == 0) run_stable();
else if (strcmp(argv[1], "enumerate") == 0) run_enumerate();
else if (strcmp(argv[1], "reload") == 0) run_reload(argv[2]);
else run_udev();
fflush(stdout);
return 0;
@@ -650,6 +684,9 @@ class InputUdevPreloadTest(unittest.TestCase):
"nothing added scan -1",
])
def test_a_program_that_closes_and_reopens_libudev_keeps_working(self):
self.assertEqual(self.run_program("reload"), ["reload real0 real1"])
def test_only_the_steam_client_and_its_remote_play_client_get_the_real_libudev(self):
for path, pad in (("steamrt64/steam", 0), ("steamrtarm64/steam", 0), ("steamrt64/streaming_client", 0),
("steamrtarm64/streaming_client", 0), ("steamrt64/steam-probe", 1),
@@ -5,11 +5,23 @@ for (var i = 0; i < desktops.length; i++) {
desktops[i].writeConfig("Image", "file:///usr/share/wallpapers/DroidDeck");
}
var dock = new Panel;
dock.location = "bottom";
dock.height = 2 * Math.ceil(gridUnit * 2.5 / 2);
var panel = new Panel;
var panelScreen = panel.screen;
panel.location = "bottom";
panel.height = 2 * Math.ceil(gridUnit * 2.5 / 2);
var kickoff = dock.addWidget("org.kde.plasma.kickoff");
const maximumAspectRatio = 21 / 9;
if (panel.formFactor === "horizontal") {
const geo = screenGeometry(panelScreen);
const maximumWidth = Math.ceil(geo.height * maximumAspectRatio);
if (geo.width > maximumWidth) {
panel.alignment = "center";
panel.minimumLength = maximumWidth;
panel.maximumLength = maximumWidth;
}
}
var kickoff = panel.addWidget("org.kde.plasma.kickoff");
kickoff.currentConfigGroup = ["Shortcuts"];
kickoff.writeConfig("global", "Alt+F1");
kickoff.currentConfigGroup = ["General"];
@@ -23,20 +35,36 @@ kickoff.writeConfig("favorites", [
"applications:systemsettings.desktop",
]);
var tasks = dock.addWidget("org.kde.plasma.icontasks");
panel.addWidget("org.kde.plasma.pager");
var tasks = panel.addWidget("org.kde.plasma.icontasks");
tasks.currentConfigGroup = ["General"];
tasks.writeConfig("launchers", [
"applications:steamdeck-steam.desktop",
"applications:systemsettings.desktop",
"applications:org.kde.discover.desktop",
"preferred://filemanager",
"preferred://browser",
"applications:org.kde.konsole.desktop",
"applications:org.kde.kate.desktop",
]);
var tray = dock.addWidget("org.kde.plasma.systemtray");
panel.addWidget("org.kde.plasma.marginsseparator");
const inputMethodLanguages = ["as", "bn", "bo", "brx", "doi", "gu", "hi", "ja", "kn", "ko", "kok", "ks", "lep", "mai",
"ml", "mni", "mr", "ne", "or", "pa", "sa", "sat", "sd", "si", "ta", "te", "th", "ur", "vi", "zh_CN", "zh_TW"];
if (inputMethodLanguages.indexOf(languageId) != -1) {
panel.addWidget("org.kde.plasma.kimpanel");
}
var tray = panel.addWidget("org.kde.plasma.systemtray");
var trayId = tray.readConfig("SystrayContainmentId");
if (trayId) {
var trayContainment = desktopById(trayId);
trayContainment.currentConfigGroup = ["General"];
trayContainment.writeConfig("scaleIconsToFit", true);
}
var clock = panel.addWidget("org.kde.plasma.digitalclock");
clock.currentConfigGroup = ["Appearance"];
clock.writeConfig("dateFormat", "isoDate");
panel.addWidget("org.kde.plasma.showdesktop");