Try some ECMAScript to configure the desktop.

This commit is contained in:
Andreas B. Mundt 2023-08-16 20:50:44 +02:00
parent cb172935c7
commit 54ccda1abf
2 changed files with 118 additions and 2 deletions

View file

@ -0,0 +1,110 @@
// configure plasma defaults
function forEachWidgetInContainmentList(containmentList, callback) {
for (var containmentIndex = 0; containmentIndex < containmentList.length; containmentIndex++) {
var containment = containmentList[containmentIndex];
var widgets = containment.widgets();
for (var widgetIndex = 0; widgetIndex < widgets.length; widgetIndex++) {
var widget = widgets[widgetIndex];
callback(widget, containment);
if (widget.type === "org.kde.plasma.systemtray") {
systemtrayId = widget.readConfig("SystrayContainmentId");
if (systemtrayId) {
forEachWidgetInContainmentList([desktopById(systemtrayId)], callback)
}
}
}
}
}
function forEachWidget(callback) {
forEachWidgetInContainmentList(desktops(), callback);
forEachWidgetInContainmentList(panels(), callback);
}
function forEachWidgetByType(type, callback) {
forEachWidget(function(widget, containment) {
if (widget.type == type) {
callback(widget, containment);
}
});
}
function widgetSetProperty(args) {
if (!(args.widgetType && args.configGroup && args.configKey)) {
return;
}
forEachWidgetByType(args.widgetType, function(widget){
widget.currentConfigGroup = [args.configGroup];
/*
//--- Delete when done debugging
const oldValue = widget.readConfig(args.configKey);
print("" + widget.type + " (id: " + widget.id + "):");
print("\t[" + args.configGroup + "] " + args.configKey + ": " +
oldValue + " => " + args.configValue + "\n");
//--- End Debug
*/
widget.writeConfig(args.configKey, args.configValue);
});
}
// configure task bar starters:
widgetSetProperty({
widgetType: "org.kde.plasma.icontasks",
configGroup: "General",
configKey: "launchers",
configValue: [
"applications:systemsettings.desktop",
"preferred://browser",
"applications:thunderbird.desktop",
"applications:libreoffice-startcenter.desktop",
"preferred://filemanager"
//"applications:org.kde.konsole.desktop",
//"applications:org.kde.discover.desktop"
],
});
// kickoff is the default menu:
/* this does not work (anymore?)
widgetSetProperty({
widgetType: "org.kde.plasma.kickoff",
configGroup: "General",
configKey: "favorites",
configValue: ["applications:libreoffice-startcenter.desktop",],
});
*/
widgetSetProperty({
widgetType: "org.kde.plasma.kickoff",
configGroup: "General",
configKey: "systemFavorites",
configValue: ["reboot", "shutdown", "logout"],
});
// prepare a folder view on the desktop:
var allDesktops = desktops();
for (var desktopIndex = 0; desktopIndex < allDesktops.length; desktopIndex++) {
var d = allDesktops[desktopIndex];
d.addWidget("org.kde.plasma.folder", 50, 50, 456, 600)
print("Folder app generated!\n")
}
widgetSetProperty({
widgetType: "org.kde.plasma.folder",
configGroup: "General",
configKey: "url",
configValue: "/lmn/media/",
});
widgetSetProperty({
widgetType: "org.kde.plasma.folder",
configGroup: "General",
configKey: "labelMode",
configValue: "0",
});
// /usr/share/plasma/shells/org.kde.plasma.desktop/contents/updates/fvs-config.js

View file

@ -194,6 +194,12 @@
dest: /usr/local/bin/ dest: /usr/local/bin/
mode: 0755 mode: 0755
- name: Copy fvs-config.js to configure plasma
ansible.builtin.copy:
src: fvs-config.js
dest: /usr/share/plasma/shells/org.kde.plasma.desktop/contents/updates/fvs-config.js
mode: 0644
################# general settings ################## ################# general settings ##################
- name: Protect grub menu entries - name: Protect grub menu entries
blockinfile: blockinfile:
@ -211,7 +217,7 @@
firstmatch: true firstmatch: true
notify: Run update-grub notify: Run update-grub
- name: grub timeout - name: Grub timeout
lineinfile: lineinfile:
dest: /etc/default/grub dest: /etc/default/grub
regexp: '^(GRUB_TIMEOUT=).*' regexp: '^(GRUB_TIMEOUT=).*'
@ -219,7 +225,7 @@
backrefs: yes backrefs: yes
notify: Run update-grub notify: Run update-grub
- name: keyboard compose key - name: Keyboard compose key
lineinfile: lineinfile:
dest: /etc/default/keyboard dest: /etc/default/keyboard
regexp: '^(XKBOPTIONS=).*' regexp: '^(XKBOPTIONS=).*'