Reply to topic

Change desktop script not executed

User avatar Schoelje
Registered Member
Posts
31
Karma
0
OS

Change desktop script not executed

Tue Jan 22, 2013 12:36 pm
Hi,

I have created a .js file in /usr/share/test/kde4-profile/default/share/apps/plasma-desktop/init/

If I run this script in "desktop console", it runs perfectly and I made sure it's running as the last script in line.

I then created /etc/kde4rc:
Code: Select all
[Directories-default]
prefixes=/usr/share/test/kde4-profile/default/


After a lonout/login, I verified that this path is known by kde:
Code: Select all
kde4-config --path data


Of the test user I made sure the .kde directory is empty.

After a logout/login (or even reboot), the desktop is not changed.

If I create a symlink in /usr/share/kde4/apps/plasma-desktop/init/ to this script, it runs fine after a logout/login.

Does anybody know why my script isn't picked up and executed from the custom directory?

[EDIT]
Running KDE 4.8.4 on Debian testing

Script: 20-testLayout.js
Code: Select all
// Placed in /usr/share/test/default-settings/kde4-profile/default/share/apps/plasma-desktop/init/
// This script is run for new users, which do not have a .kde directory
// and it set's the default wallpaper for all activities

// Wallpaper theme: sub directory of /usr/share/wallpapers/
var wallpaper = "testwallpaper"
var launchericon = "/usr/share/test/logo.png"
var dolphindesktop = "/usr/share/applications/kde4/dolphin.desktop"

// Make existing activities more personal
a = activities()
for (i in a) {
  if (a[i].name == i18n("Desktop")) {
    // Add desktop folderview if no folderviews exist
    if (a[i].widgets("folderview").length == 0) {
      folderview = a[i].addWidget("folderview")
      folderview.writeConfig("url", "desktop:/")
    }
  }
  // Set wallpaper for all activities
  a[i].wallpaperPlugin = 'image'
  a[i].wallpaperMode = 'SingleImage'
  a[i].currentConfigGroup = Array('Wallpaper', 'image')
  a[i].writeConfig('wallpaper', wallpaper)
  a[i].writeConfig('wallpaperposition', '2')          //enables croping
  a[i].currentConfigGroup = new Array('ToolBox')
  a[i].writeConfig('corner', '1')
  a[i].writeConfig('offset', '0')
}

// Make existing panels more personal
p = panels()
for (i in p) {
  // Remove all current widgets from the panels
  w = p[i].widgets()
  for (j in w) {
    w[j].remove()
  }
 
  // Add widgets
  launcher = p[i].addWidget("launcher")
  launcher.globalShortcut = "Alt+F1"
  launcher.writeConfig("icon", launchericon)

  p[i].addWidget("showdesktop")
       
  var widget = p[i].addWidget("icon")
  widget.writeConfig("Url", dolphindesktop)
       
  var tasks = p[i].addWidget("tasks")
  tasks.writeConfig("showOnlyCurrentScreen", true);

  var systray = p[i].addWidget("systemtray")
  j = 0;
  if (hasBattery) {
    systray.currentConfigGroup = new Array("Applets", ++j)
    systray.writeConfig("plugin", "battery")
  }
  systray.currentConfigGroup = new Array("Applets", ++j)
  systray.writeConfig("plugin", "message-indicator")
  systray.currentConfigGroup = new Array("Applets", ++j)
  systray.writeConfig("plugin", "org.kde.networkmanagement")
  systray.currentConfigGroup = new Array("Applets", ++j)
  systray.writeConfig("plugin", "notifier")

  var clock = p[i].addWidget("digital-clock")
  clock.writeConfig("showDate", "false")
}


It should run after these are finished:
/usr/share/kde4/apps/plasma-desktop/init/00-defaultLayout.js
/usr/share/kde4/apps/plasma-desktop/init/10-desktop-base.js
User avatar Schoelje
Registered Member
Posts
31
Karma
0
OS
Unfortunately I underestimated the flexibility of the plasma desktop and came up with the script above which changes the default created desktop to suit my needs. After many, many tests I concluded that my script was already running while the activities object was not yet created which resulted in mostly the default desktop, sometimes my scripted desktop and sometimes even just my scripted panel.

I changed the script to act as if there is no desktop activity and no panels, as if it was the first script running...and that seemed to work, even without changing the name of the script (thus running as last):
Code: Select all
// Placed in /usr/share/test/default-settings/kde4-profile/default/share/apps/plasma-desktop/init/
// This script is run for new users, which do not have a .kde directory
// and it set's the default wallpaper for all activities

// Wallpaper theme: sub directory of /usr/share/wallpapers/
var wallpaper = "test"
var launchericon = "/usr/share/test/logo.png"
var dolphindesktop = "/usr/share/applications/kde4/dolphin.desktop"

for (var i = 0; i < screenCount; ++i) {
  desktop = new Activity
  desktop.name = i18n("Desktop")
  desktop.screen = i 
  desktop.wallpaperPlugin = 'image'
  desktop.wallpaperMode = 'SingleImage'
  desktop.currentConfigGroup = Array('Wallpaper', 'image')
  desktop.writeConfig('wallpaper', wallpaper)
  desktop.writeConfig('wallpaperposition', '2')          //enables croping
  desktop.currentConfigGroup = new Array('ToolBox')
  desktop.writeConfig('corner', '1')
  desktop.writeConfig('offset', '0')
 
  // Add desktop folderview if no folderviews exist
  var folderview
  if (desktop.widgets("folderview").length == 0) {
    folderview = desktop.addWidget("folderview")
  } else {
    folderview = desktop.widgets("folderview")
  }
  folderview.writeConfig("url", "desktop:/")

  panel = new Panel
  panel.screen = i
  panel.location = 'bottom'
  panel.height = panels()[i].height = screenGeometry(0).height > 1024 ? 35 : 27

  // Add SolydXK widgets
  launcher = panel.addWidget("launcher")
  launcher.globalShortcut = "Alt+F1"
  launcher.writeConfig("icon", launchericon)

  panel.addWidget("showdesktop")
       
  var widget = panel.addWidget("icon")
  widget.writeConfig("Url", dolphindesktop)
       
  var tasks = panel.addWidget("tasks")
  tasks.writeConfig("showOnlyCurrentScreen", true);

  var systray = panel.addWidget("systemtray")
  j = 0;
  if (hasBattery) {
    systray.currentConfigGroup = new Array("Applets", ++j)
    systray.writeConfig("plugin", "battery")
  }
  systray.currentConfigGroup = new Array("Applets", ++j)
  systray.writeConfig("plugin", "message-indicator")
  systray.currentConfigGroup = new Array("Applets", ++j)
  systray.writeConfig("plugin", "org.kde.networkmanagement")
  systray.currentConfigGroup = new Array("Applets", ++j)
  systray.writeConfig("plugin", "notifier")

  var clock = panel.addWidget("digital-clock")
  clock.writeConfig("showDate", "false")
}
User avatar Schoelje
Registered Member
Posts
31
Karma
0
OS
After a reboot I had the same problem.
It seems that there is a difference between logout/login and reboot.
I ended up diverting the two default scripts mentioned above.
Crude, but functional.

 
Reply to topic

Bookmarks



Who is online

Registered users: Alastair, apater, Baidu [Spider], Bing [Bot], Exabot [Bot], garthecho, ggael, Google [Bot], google01103, Horus, jitseniesen, Joif, kde-jriddell, ken300, La Ninje, Mamarok, mmistretta, Nuc!eoN, psbot [Picsearch], rbruce, renatoatilio, sacarde, sinclair, stephans, TheraHedwig, tienhung, wolfi323, Yahoo [Bot]