This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[Solved ] js Scripting Help customize default plasma-desktop

Tags: None
(comma "," separated)
User avatar
hteles
Registered Member
Posts
38
Karma
0
OS
Hello Guys,


Given the following plasma init script to create a very basic and kiosked KDE4 Enviroment, how can i disable unlock widgets and activity actions from the ActionPlugins ( right button Popup Menu?
I already know that i have to write the following keys :

[ActionPlugins][RightButton;NoModifier]
_add panel=true
_context=true
_lock_screen=true
_logout=true
_run_command=false
_sep1=true
_sep2=true
_sep3=true
_wallpaper=true
add sibling containment=false
add widgets=false
configure=true
configure shortcuts=false
lock widgets=false
manage activities=false
remove=true

Also i dont want to put [$i] at the plasma-desktop-appletsrc file because i have to delete this file every logon because of this problem -> viewtopic.php?f=67&t=102286
So, at every logon, i have a script that deletes ~/.kde/share/config/plasma-desktop-appletsrc


This is my 00-defaultLayout.js at share/apps/plasma-desktop/init

var activity = new Activity("folderview");

activity.writeConfig("ActionPluginsSource", "Local");
activity.writeConfig("MidButton;NoModifier", "");
activity.writeConfig("RightButton;NoModifier", "");
activity.writeConfig("wheel:Vertical;NoModifier", "");
activity.writeConfig("immutability", "2");
activity.writeConfig("locked", "true");

var panel = new Panel("panel");
panel.location = "bottom";
panel.writeConfig("ActionPluginsSource", "Local");
panel.writeConfig("MidButton;NoModifier", "");
panel.writeConfig("RightButton;NoModifier", "");
panel.writeConfig("immutability", "2");

var launcher = panel.addWidget("simplelauncher");
launcher.writeConfig("format", "Description");
launcher.writeConfig("showMenuTitles", "true");
launcher.writeConfig("maxRecentApps", "3");
launcher.writeConfig("immutability", "2");

launcher.writeConfig("views", "RecentlyUsedApplications,RecentlyUsedDocuments,Applications,Favorites,LockScreen,Logout");
launcher.writeConfig("icon", "java");

panel.addWidget("showdesktop");

//var accesso = panel.addWidget("quickaccess");
//acesso.writeConfig=("url", "Desktop://");
//acesso.writeConfig=("icon", "folder-bookmark");
//acesso.writeConfig=("iconSize", "22);

panel.addWidget("icontasks");

systray = panel.addWidget("systemtray");
systray.writeConfig("DefaultAppletsAdded", "true");
systray.writeConfig("Share", "false");
systray.writeConfig("ShowApplicationStatus", "true");
systray.writeConfig("ShowCommunications", "false");
systray.writeConfig("ShowHardware", "true");
systray.writeConfig("ShowSystemServices", "false");
systray.writeConfig("ShowUnknown", "false");
//systray.writeConfig("alwaysShown", "'Applet' de Impressoras");
systray.writeConfig("hidden", "notifier,notifications");

clock = panel.addWidget("digital-clock");
clock.writeConfig("showDate", "true");
clock.writeConfig("displayEvents", "false");
clock.writeConfig("dateStyle", "4");
clock.writeConfig("displayHolidays", "true");
clock.writeConfig("holidaysRegions", "pt_pt");
clock.writeConfig("holidaysRegionsDaysOff", "pt_pt");

Xiqueiro = panel.addWidget("trash");
Xiqueiro.writeConfig("immutability", "2");

ByeBye = activity.addWidget("py-cashew");
ByeBye.writeConfig("geometry", "396,161,200,200");
ByeBye.writeConfig("immutability", "2");

Thanks for any help guys,
just want to script the ActionPlugins rightbutton, but i can't seem to manage it.

Last edited by hteles on Mon Jun 18, 2012 3:31 pm, edited 1 time in total.
User avatar
hteles
Registered Member
Posts
38
Karma
0
OS
Hi guys,

since we are talking about a terminal remote login via X2GO or NX/Freenx i've found a workaround. In any of this remote solutions there is the possibility to execut a command insted of the default Xsession on the server.

I've managed to do-it like this, remember since i can't adjust panel i have do delete plasma-desktop-appletsrc every single login.

lauchkde.sh


Code: Select all
#/bin/bash

cat > ~/.kde/share/config/plasma-desktop-appletsrc << EOF
[ActionPlugins]
MidButton;NoModifier=paste
RightButton;NoModifier=contextmenu

[ActionPlugins][RightButton;NoModifier]
_add panel=false
_context=true
_lock_screen=true
_logout=true
_run_command=true
_sep1=true
_sep2=true
_sep3=true
_wallpaper=true
add sibling containment=false
add widgets=false
configure=false
configure shortcuts=false
lock widgets=false
manage activities=false
remove=true
EOF

startkde


One less to go trying to kiosk kde4 as our previous kde3 kiosk enviroment.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
You should be able to use Kiosk action restrictions to disable the Unlock widgets and Activity related actions.
Please file a bug at bugs.kde.org if this is not the case.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
hteles
Registered Member
Posts
38
Karma
0
OS
bcooksley wrote:You should be able to use Kiosk action restrictions to disable the Unlock widgets and Activity related actions.
Please file a bug at bugs.kde.org if this is not the case.


Hi, thanks for your reply.

Indeed you can use [$i] at the top of your plasma-desktop-appletsrc file but if you want to have a lot of diferente identities login to your machine that will be hard to doit, unless you put that at /etc/skel.

The are some parts of KDE4 Kiosk that are not working very well till now. Stuff like kmenuedit, unlock widgets,

Please read this thread if you have the time. http://mail.kde.org/pipermail/plasma-devel/2012-June/019873.html

regards,
hteles
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
I'm subscribed to the plasma-devel list and have seen your emails. Aaron should be able to help you find your answers however.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
hteles
Registered Member
Posts
38
Karma
0
OS
Hi dear users.

I've sorta managed to do what i was trying to accomplish, that it was:

1)Disable "unlock widgets" & Activities option from right button on the desktop. I've managed to do it without putting [$i] at plasma-desktop-appletsrc, and the file is always generated at every login to skip the other *problem* that i'm facing with plasma-update script.

2) Disable "unlock widget" on right mouse button on the panel, clock and task bar.

*The problem* that i'm facing with plasma-updates not working are related to dbus, as everything works on a real display.


So, here it goes my plasma-desktop-appletsrc, and the script i call before startkde, this could be imported to startkde too.

Code: Select all
function remove()
{
  for (i in activityIds) {
   activityById(activityIds[i]).remove()
    }
}


function RemoveOldActivity()
{
    for (i in activityIds) {
       p = activityById(activityIds[i]);
       if (typeof p === "undefined") {
       print("E: Couldn't find first Activity");
       remove() //load the remove function in case of problems
       }
        else    {
          activityById(activityIds[i]).remove()
                }
                           }
}

function Myactivity()
{

RemoveOldActivity();
sleep(2);
var activity = new Activity("folderview");

activity.writeConfig("ActionPluginsSource", "Local");
activity.writeConfig("MidButton;NoModifier", "");
activity.writeConfig("RightButton;NoModifier", "contextmenu");
activity.writeConfig("wheel:Vertical;NoModifier", "");
activity.writeConfig("immutability", "2");
activity.writeConfig("locked", "true");

var panel = new Panel("panel");
panel.location = "bottom";
panel.height = 42;
panel.writeConfig("ActionPluginsSource", "Local");
panel.writeConfig("MidButton;NoModifier", "");
panel.writeConfig("RightButton;NoModifier", "");
panel.writeConfig("immutability", "2");

var launcher = panel.addWidget("simplelauncher");
launcher.writeConfig("RightButton;NoModifier", "");
launcher.writeConfig("format", "Description");
launcher.writeConfig("showMenuTitles", "true");
launcher.writeConfig("maxRecentApps", "3");
launcher.writeConfig("immutability", "2");
launcher.writeConfig("views", "RecentlyUsedApplications,RecentlyUsedDocuments,Applications,Favorites,LockScreen,Logout");
launcher.writeConfig("icon", "java");

var Viewdesktop = panel.addWidget("showdesktop");
Viewdesktop.writeConfig("RightButton;NoModifier", "");

var Tasks = panel.addWidget("icontasks");
Tasks.writeConfig("RightButton;NoModifier", "");

var systray = panel.addWidget("systemtray");
systray.writeConfig("DefaultAppletsAdded", "true");
systray.writeConfig("Share", "false");
systray.writeConfig("ShowApplicationStatus", "true");
systray.writeConfig("ShowCommunications", "false");
systray.writeConfig("ShowHardware", "true");
systray.writeConfig("ShowSystemServices", "false");
systray.writeConfig("ShowUnknown", "false");
//systray.writeConfig("alwaysShown", "'Applet' de Impressoras");
systray.writeConfig("hidden", "notifier,notifications");
systray.writeConfig("RightButton;NoModifier", "");

var clock = panel.addWidget("digital-clock");
clock.writeConfig("showDate", "true");
clock.writeConfig("displayEvents", "false");
clock.writeConfig("dateStyle", "4");
clock.writeConfig("displayHolidays", "true");
clock.writeConfig("holidaysRegions", "pt_pt");
clock.writeConfig("holidaysRegionsDaysOff", "pt_pt");
clock.writeConfig("RightButton;NoModifier", "");

var Xiqueiro = panel.addWidget("trash");
Xiqueiro.writeConfig("immutability", "2");
Xiqueiro.writeConfig("RightButton;NoModifier", "");

ByeBye = activity.addWidget("py-cashew");
ByeBye.writeConfig("geometry", "396,161,200,200");
ByeBye.writeConfig("immutability", "2");

lockout = panel.addWidget("lockout");
//lockout.writeConfig("showHibernateButton","true");
lockout.writeConfig("showLogoutButton","true");
lockout.writeConfig("showLockButton","true");
lockout.writeConfig("showSleepButton","false");
lockout.writeConfig("showSwitchUserButton","false");
lockout.writeConfig("iconSize", "48");

immutability = 2
locked = true

}


Myactivity();




Script that is called via X2GO.

Code: Select all

#/bin/bash

cat > ~/.kde/share/config/plasma-desktop-appletsrc << EOF
[ActionPlugins]
MidButton;NoModifier=
RightButton;NoModifier=contextmenu

[ActionPlugins][RightButton;NoModifier]
_add panel=false
_context=true
_lock_screen=true
_logout=true
_run_command=true
_sep1=true
_sep2=true
_sep3=true
_wallpaper=true
add sibling containment=false
add widgets=false
configure=false
configure shortcuts=false
lock widgets=false
manage activities=false
remove=true

[Containments][2][ActionPlugins]
RightButton;NoModifier[$i]=
EOF


startkde



Still remaing is that it is possible to edit classic kmenu but that one is easy to resolve with unix permissions.

regards,
hteles
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
As far as I am aware D-Bus relies on the content of the DBUS_SESSION_BUS_ADDRESS environment variable to discover the information needed to connect to the D-Bus server.

If this environment variable is not set, it will try to connect to the local X server, and examine global properties set there. You can see this yourself using the `dbus-launch` command (which will also start a D-Bus session server if it cannot locate a D-Bus server for your current session).

It also requires that you are running under the same user - session D-Bus server instances will only accept connections from the same user. (In terms of uid)


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
hteles
Registered Member
Posts
38
Karma
0
OS
bcooksley wrote:As far as I am aware D-Bus relies on the content of the DBUS_SESSION_BUS_ADDRESS environment variable to discover the information needed to connect to the D-Bus server.

If this environment variable is not set, it will try to connect to the local X server, and examine global properties set there. You can see this yourself using the `dbus-launch` command (which will also start a D-Bus session server if it cannot locate a D-Bus server for your current session).

It also requires that you are running under the same user - session D-Bus server instances will only accept connections from the same user. (In terms of uid)


I think that there are related problems with Kubuntu 12.04 Dbus & KDE 4.8. Right now i have to move along with this.

Thanks
nowardev
Registered Member
Posts
244
Karma
0
OS
xD

it seems that someone has read my javascript :PP
User avatar
hteles
Registered Member
Posts
38
Karma
0
OS

Wed Aug 01, 2012 10:07 am
nowardev wrote:xD

it seems that someone has read my javascript :PP


Lol, ;)

Maybe you could write one to resolve my problem :P

Very sad with kiosk interfaces right now.
User avatar
hteles
Registered Member
Posts
38
Karma
0
OS

Fri Aug 03, 2012 2:21 pm
nowardev wrote:xD

it seems that someone has read my javascript :PP


Hi wardev,

Do you know how to script Global Action Plugins?

Any idea how to put this in Plasma Init?


Code: Select all
[ActionPlugins][RightButton;NoModifier]
_add panel=false
_context=true
_lock_screen=true
_logout=true
_run_command=true
_sep1=true
_sep2=true
_sep3=true
_wallpaper=true
add sibling containment=false
add widgets=false
configure=false
configure shortcuts=false
lock widgets=false
manage activities=false
remove=true


What i've managed to do is this, but it only works at second login*, but image if you have to create 50 Users for a new machine, you have to take first login with all of the above acounts.
* At the first login the activities aren't locked neither the Context menu is stripped.


Code: Select all

var activity = new Activity("folderview");
activity.writeConfig("ActionPluginsSource", "Local");
activity.writeConfig("MidButton;NoModifier", "");
activity.writeConfig("RightButton;NoModifier", "contextmenu");
activity.writeConfig("wheel:Vertical;NoModifier", "");
activity.writeConfig("immutability", "2");

activity.currentConfigGroup = Array ("ActionPlugins", "RightButton;NoModifier");
activity.writeConfig("configure", "false");
activity.writeConfig("configure shortcuts", "false");
activity.writeConfig("unlock widgets", "false");
activity.writeConfig("manage activities","false");
activity.writeConfig("lock widgets", "false");
activity.writeConfig("manage activities","false");
activity.writeConfig("remove", "true");

activity.currentConfigGroup = Array("Wallpaper", "image");
activity.writeConfig("wallpaper", "/usr/share/wallpapers/spikelnx.jpg");
activity.writeConfig("wallpaperposition", "0");

var panel = new Panel("panel");
panel.location = "bottom";
panel.height = 45;
panel.writeConfig("ActionPluginsSource", "Local");
panel.writeConfig("MidButton;NoModifier", "");
panel.writeConfig("RightButton;NoModifier", "");
panel.writeConfig("immutability", "2");

panel.currentConfigGroup = Array ("ActionPlugins", "RightButton;NoModifier");
panel.writeConfig("configure", "false");
panel.writeConfig("configure shortcuts", "false");
panel.writeConfig("unlock widgets", "false");
panel.writeConfig("manage activities","false");
panel.writeConfig("lock widgets", "false");
panel.writeConfig("manage activities","false");
panel.writeConfig("remove", "true");



Lots of the Plasma Stuff are really bugged. Also reloadConfig() does have same bad behaviour too at some steps.

Regards,
Helmer Teles
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Under a running user session, does restarting Plasma (kquitapp plasma-desktop; plasma-desktop &) have the same impact as logging out and back in?


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
nowardev
Registered Member
Posts
244
Karma
0
OS

Re:

Sat Aug 04, 2012 12:28 pm
mmm i managed to create my own version of kubuntu but i had less stuff to do
i did for example

http://code.google.com/p/kde-peace-sett ... tLayout.js



hteles wrote:
nowardev wrote:xD

it seems that someone has read my javascript :PP


Hi wardev,

Do you know how to script Global Action Plugins?

Any idea how to put this in Plasma Init?


Code: Select all
[ActionPlugins][RightButton;NoModifier]
_add panel=false
_context=true
_lock_screen=true
_logout=true
_run_command=true
_sep1=true
_sep2=true
_sep3=true
_wallpaper=true
add sibling containment=false
add widgets=false
configure=false
configure shortcuts=false
lock widgets=false
manage activities=false
remove=true


What i've managed to do is this, but it only works at second login*, but image if you have to create 50 Users for a new machine, you have to take first login with all of the above acounts.
* At the first login the activities aren't locked neither the Context menu is stripped.


Code: Select all

var activity = new Activity("folderview");
activity.writeConfig("ActionPluginsSource", "Local");
activity.writeConfig("MidButton;NoModifier", "");
activity.writeConfig("RightButton;NoModifier", "contextmenu");
activity.writeConfig("wheel:Vertical;NoModifier", "");
activity.writeConfig("immutability", "2");

activity.currentConfigGroup = Array ("ActionPlugins", "RightButton;NoModifier");
activity.writeConfig("configure", "false");
activity.writeConfig("configure shortcuts", "false");
activity.writeConfig("unlock widgets", "false");
activity.writeConfig("manage activities","false");
activity.writeConfig("lock widgets", "false");
activity.writeConfig("manage activities","false");
activity.writeConfig("remove", "true");

activity.currentConfigGroup = Array("Wallpaper", "image");
activity.writeConfig("wallpaper", "/usr/share/wallpapers/spikelnx.jpg");
activity.writeConfig("wallpaperposition", "0");

var panel = new Panel("panel");
panel.location = "bottom";
panel.height = 45;
panel.writeConfig("ActionPluginsSource", "Local");
panel.writeConfig("MidButton;NoModifier", "");
panel.writeConfig("RightButton;NoModifier", "");
panel.writeConfig("immutability", "2");

panel.currentConfigGroup = Array ("ActionPlugins", "RightButton;NoModifier");
panel.writeConfig("configure", "false");
panel.writeConfig("configure shortcuts", "false");
panel.writeConfig("unlock widgets", "false");
panel.writeConfig("manage activities","false");
panel.writeConfig("lock widgets", "false");
panel.writeConfig("manage activities","false");
panel.writeConfig("remove", "true");



Lots of the Plasma Stuff are really bugged. Also reloadConfig() does have same bad behaviour too at some steps.

Regards,
Helmer Teles
User avatar
hteles
Registered Member
Posts
38
Karma
0
OS

Mon Aug 06, 2012 11:29 am
nowardev wrote:mmm i managed to create my own version of kubuntu but i had less stuff to do
i did for example

http://code.google.com/p/kde-peace-sett ... tLayout.js



Hi,

This is for a remote desktop AKA Linux Terminal Server where users connect remotely from Internet.
Everytime a user connects to his session it could be running on a diferent resolution/desktop/Tablet, etc.

Diferent resolution is one of my problems with plasma-panel, because the trick whith plasma-update script to resize the panel it only works one time. xD
After the script is runned it will not run anymore. :D

Edited:
P.S: This setup is using kiosk framework with several profiles, some groups have to use Thunderbird other have to use Evolution, etc, etc.
User avatar
hteles
Registered Member
Posts
38
Karma
0
OS

Mon Aug 06, 2012 11:40 am
bcooksley wrote:Under a running user session, does restarting Plasma (kquitapp plasma-desktop; plasma-desktop &) have the same impact as logging out and back in?


Hi,

i will report ASAP. I updated to KDE 4.9.0 from kubuntu backports to see if there were improvements, but all i see is regressions in kiosk framework probably because ot qt quick new interfaces.

For instance, now you can add widgets where in 4.8 you couldn't with kiosk restrictions, the logout menu presents logout and reboot.

Will go back to 4.8 and will test kquitapp plasma-desktop; plasma-desktop & report back

P.S: This only happens at first login, after the second login the options in the menu to unlock widgets and manage activities disappear as it should as implemented kiosk restrictions applied


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]