Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locate plasma panel settings save function in KDE4 code #12

Open
midenok opened this issue May 27, 2014 · 22 comments
Open

Locate plasma panel settings save function in KDE4 code #12

midenok opened this issue May 27, 2014 · 22 comments
Assignees

Comments

@midenok
Copy link
Member

midenok commented May 27, 2014

  1. do cp -a ~/.kde /tmp/

  2. right-click on panel, 'Task Manager Settings', invert 'Only show tasks from the current screen' flag, press OK.

  3. compare /tmp/.kde and ~/.kde:

     diff -Nuard /tmp/.kde ~/.kde
    

    Locate the changes reflected by flag change.

  4. locate the process that does that change. How -- your suggestion. Or you can ask me.

  5. hook on file write: in GDB b write, do the change, show the stack trace to me.

@midenok
Copy link
Member Author

midenok commented May 28, 2014

Please, confirm.

@mechanician
Copy link

Ok! I'll do it later.

@mechanician
Copy link

Do you mean panel on my custom kde? That may be strange, but I can't find there any panel...
I've tried to use both Xnest and Xephyr. By the way, as you said, Xephyr does have more pleasant appearance, but there are only some icons on black background. On the top there is some panel, but it has only two items "Activity Bar Settings" and "Unlock Panel" in right-click menu my_kde4_desktop_xephyr.png. After "Activity Bar Settings" is clicked, keyboard shortcut menu appears my_kde4_desktop_xephyr_2.png and there is not 'Only show tasks from the current screen' flag...
So what's to be done?

@midenok
Copy link
Member Author

midenok commented Jun 3, 2014

I guess it is because some components are missing. You can still proceed pp. 1-4 on your main installation. Please, tell me the results.

@mechanician
Copy link

I couldn't figure out how to determine the process that makes changes in ~/.kde ... How it should be done?

@midenok
Copy link
Member Author

midenok commented Jun 3, 2014

It depends on result from p. 3. Please, show me the diff (use Github Gist service).

@mechanician
Copy link

@midenok
Copy link
Member Author

midenok commented Jun 3, 2014

So, it's a showOnlyCurrentScreen inside .kde/share/config/plasma-desktop-appletsrc. There are several approaches to figure out which process makes changes:

  1. try (as root):

    lsof /home/mechanician/.kde/share/config/plasma-desktop-appletsrc
    

    If it will not show anything, this means, that file is opened each time.

  2. if 1. didn't help, try (as user):

    rcfile=/home/mechanician/.kde/share/config/plasma-desktop-appletsrc
    mv $rcfile $rcfile.bak
    mkfifo $rcfile
    

    Then try to change the setting. It should freeze (hahaha). Then use method from p.1.

  3. Grep sources for showOnlyCurrentScreen. The most reliable, though most boring (i.e. long) method.

    grep -r showOnlyCurrentScreen path_to_sources
    

    Supplement for p.1:

lsof +d /home/mechanician/.kde/share/config

will list all processes with open files inside that dir.

@mechanician
Copy link

Obtained results are below:

~$ sudo lsof +d  /home/mechanician/.kde/share/config
COMMAND    PID        USER   FD   TYPE DEVICE SIZE/OFF    NODE NAME
plasma-de 1739 mechanician   12w   REG    8,1       37 1179881 /home/mechanician/.kde/share/config/plasma-desktop-appletsrc.lock

But: to alive panel I had to kill above process and after that resart plasma-desktop. May be there is more correct way to "break" created pipe?

@midenok
Copy link
Member Author

midenok commented Jun 3, 2014

So, what was the sequence in detail? You tried p.1 and found nothing? This means that process doesn't hold config open, right? Then you tried p.2 and this above result is from p.2? This strange because I see only .lock and no pipe!

Anyway, you found what was required. I thought they may be routed config through dbus to a special service and now I see that they modify it directly.

There is nothing wrong to kill a process. But, if you're curious, you could feed real config through pipe and see what happens:

rcfile=/home/mechanician/.kde/share/config/plasma-desktop-appletsrc
cat $rcfile.bak > $rcfile &
cat $rcfile > $rcfile.new

I don't think that it will work as expected, because seek() don't work on pipes. But it may unfreeze process and give you a chance to return back normal config.

@midenok
Copy link
Member Author

midenok commented Jun 3, 2014

I guess I know what's going on with absent pipe in lsof. Maybe open() is blocked unless both ends open it (3 variants: rw-rw, r-w or w-r). So the file was not open yet at that time -- hence no fd in lsof!

F.ex. if you did:

chmod o+w $rcfile
cu -l $rcfile

After that it may be plasma-desktop-appletsrc appeared in lsof. cu -l opens file for rw. But plasma-desktop after successful open() would block on read() (since you don't feed anything through cu).

@mechanician
Copy link

Exactly. Firstly I tried p.1 and there was nothing, so I went to p. 2. As you said, after cu -l the pipe appeared in lsof:

~$ lsof /home/mechanician/.kde/share/config/plasma-desktop-appletsrc
COMMAND    PID        USER   FD   TYPE DEVICE SIZE/OFF    NODE NAME
plasma-de 2023 mechanician   18r  FIFO    8,1      0t0 1179940 /home/mechanician/.kde/share/config/plasma-desktop-appletsrc
cu        3782 mechanician    3u  FIFO    8,1      0t0 1179940 /home/mechanician/.kde/share/config/plasma-desktop-appletsrc
cu        3783 mechanician    3u  FIFO    8,1      0t0 1179940 /home/mechanician/.kde/share/config/plasma-desktop-appletsrc

@midenok
Copy link
Member Author

midenok commented Jun 4, 2014

Great!

Regarding p.5 what branch did you compiled? KDE Workspace should contain necessary widget. Try to add it manually:

  1. Right click on desktop -> Add panel -> Empty panel;
  2. Right click on panel -> Add widgets -> Task manager.

@mechanician
Copy link

Difficult to say about branсh, but may be the following is what you asked... :

~/kde4/src/kde-workspace$ git branch
* 4.11
  master
~/kde4/src/kde-baseapps$ git branch
* 4.13
  master

About adding the widget manually: when 'add widget' is clicked nothing happens.

@midenok
Copy link
Member Author

midenok commented Jun 5, 2014

Please, ensure that files under kde-workspace/plasma/desktop/applets/tasks was compiled and installed. It should create library plasma_applet_tasks.so. As I suspect, key file there is plasma-tasks-default.desktop which indicates applet presence. If it was installed to right place (and KDE knows where to find it) then it should work. Maybe, you could grep KDE error output for 'tasks'... Also, watch error output when you hit 'Add widgets'.

@mechanician
Copy link

Yes, there are those files:

kde-workspace/lib/plasma_applet_tasks.so
kde-workspace/plasma/desktop/applets/tasks/plasma-tasks-default.desktop

How to check if the last one is installed to right place and KDE knows about it?

While Xephyr was working no any phrases with 'task' occurred in error output .
But the following error is written to error output when 'Add widgets' is clicked:

kwin(9096) KWin::x11ErrorHandler: kwin: X Error ( "error: BadDamage [DAMAGE+0], request: XDamageDestroy[DAMAGE+2], resource: 0x1a00156" )

@midenok
Copy link
Member Author

midenok commented Jun 6, 2014

These locations are inside build tree. Where they are inside installation tree?

@mechanician
Copy link

/home/mechanician/kde/installs/trunk/lib32/kde4/plasma_applet_tasks.so
/home/mechanician/kde/installs/trunk/share/kde4/services/plasma-tasks-default.desktop

@midenok
Copy link
Member Author

midenok commented Jun 6, 2014

Can you please examine with lsof and strace how plasma-desktop behaves regarding /home/mechanician/kde/installs/trunk/share/kde4/services? To successfully start plasma-desktop under strace you need to know environment and arguments. Copy environment from working process (/proc/<PID>/environ, replace 0 with CR). Get arguments from /proc/<PID>/cmdline. Then kill running process and spawn your own under strace (don't forget to export copied environment). Grep strace output for all interesting items (/services/ dir, .desktop files). strace can filter on certain syscalls (f.ex. -e trace=file), refer to man page for details.

P.S. be ready to deal with respawners. KDE4 respawns plasma-desktop when it get killed. Find parent of plasma-destop and send him SIGSTOP before killing plasma-desktop. Use SIGCONT to reactivate stopped process.

@midenok
Copy link
Member Author

midenok commented Jun 25, 2014

Please, confirm.

@mechanician
Copy link

Hi! Sorry for the late answer.
Actually now it is a lack of spare time: a lot of affairs must be accomplished. I'll continue the task as soon as I have some free time.

@midenok
Copy link
Member Author

midenok commented Jun 26, 2014

Great! Welcome back any time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants