mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-25 07:46:01 +00:00
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
This commit is contained in:
1 parent
9e6f81540f
commit
70bda85dd5
3 files changed
+231
-6
No files matched your search
@@ -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
|
||||
|
||||
@@ -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()
|
||||
+34
-6
@@ -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");
|
||||
Reference in new issue
Block a user