Bug 359244 - Activities: When I stop my "Music" activity, I want the music player to stop playing music
Summary: Activities: When I stop my "Music" activity, I want the music player to stop ...
Status: RESOLVED NOT A BUG
Alias: None
Product: kactivitymanagerd
Classification: Plasma
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Ivan Čukić
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-02-10 19:58 UTC by Christian
Modified: 2016-02-23 12:24 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian 2016-02-10 19:58:01 UTC
Hi KDE - I'm new to activities, but I like the idea. I've defined some activities now and put some windows to activities. It's neat that all the windows of one "running" activity are hidden from view when I click on a window that belongs to a different activity.
But the "stop" button on the activities doesn't work the way I expect it to. Use case:
1. I select the "Music" activity and my music player is shown. I click on "Play" so it plays some music.
2. Now I activate the "Email" activity and the email window is shown, I do stuff there.
3. Suppose my phone rings. I want to stop the music. So I go to the Activities manager and "stop" the "Music" activity (that shows as "Used a while ago").

Expected result: "Music" activity is stopped and music stops playing.
Actual result: "Music" activity is shown as stopped, but the music continues playing. (The music player window is still in the task bar, too.)

Maybe I haven't completely understood activities. But what is the "stop" button on the activity supposed to do, if it doesn't stop the programs that belong to the activity (and to no other activity)?

Reproducible: Always
Comment 1 Ivan Čukić 2016-02-11 07:26:53 UTC
What music player do you use?

Does it stay in the task-bar, or it shows an icon in the system tray.

BTW, a bit unrelated, if you are using android or blackberry, you can install kde connect which will automatically stop the music when you answer your phone.
Comment 2 Christian 2016-02-11 09:27:48 UTC
I used "gmusicbrowser". It shows as a minimized window in the taskbar, and there is also a symbol in the status bar.

I'm wondering if this is a good place to suggest additional functionality in the settings of the Activities.  For me, the following two configuration options would make it more useful:

1. Option whether stopping an activity should close all the windows associated with only this activity. (A bit like when you log out and all the windows close, but for just that activity.)
2. Possibility to associate programs with activities - e.g., when I start the "Music" activity, the music player window should be opened even if it is not running.
Comment 3 Ivan Čukić 2016-02-11 13:24:03 UTC
gmusicbrowser seems not to implement x session management properly. (I've just tested it)

I have also tested cantata and it shuts down and restarts properly on activity stop/start.

This is unfortunately not something that we can force on applications.

> Option whether stopping an activity should close all the windows associated with only this activity

All windows get the request to save their state and quit.

 > Possibility to associate programs with activities - e.g., when I start the "Music"

This is possible until a few releases ago, it is just not exposed in the UI, and not yet documented since I'm still tweaking the behaviour.

If you create ~/.local/share/kactivitymanagerd/activities/ACTIVITY_ID/started directory, and put a .desktop file in it, that .desktop file will be executed when activity is started.

I'm marking this as 'invalid' since we can not do anything to applications that do not want to behave (in general, gnome apps do not care much about session management), but we can continue the discussion.
Comment 4 Christian 2016-02-11 14:25:06 UTC
Hej Ivan!  Thank you, very much appreciated!  I didn't know that the applications also have to implement the activity framework - I thought it would work with all windowed applications... Oh well, software is always more complicated than it seems to the casual user!

Another question that occurred to me - but I'm guessing that this is also impossible in general, is: When I associate an activity to a window, and somehow I've closed the window. Can I then make it so that, when I restart the application, it also restarts that activity? (At least for some activities.) But I am imagining that this would also have to be implemented by the application and wouldn't work in general, right?
Is it possible to modify the KDE menu shortcuts (I mean the things I click on to start programs) so that clicking on it also starts a particular activity?
Comment 5 Ivan Čukić 2016-02-22 22:08:04 UTC
Sorry for the slow response.

> applications also have to implement the activity framework

The sad part is that it is not about the activities framework, but something that existed in X11 for a decade, and so many applications ignore it. Basically, the session protocol sends the application save-state-and-close-event, and then tells it to start with the saved state the next time.

If an application ignores this, it will have problems with activities.

You can create a small script that switches the activity, and starts the desired application. Basically, this is not really a supported feature, but more than a few people do it.

This will return IDs of activities you have on your system:
qdbus org.kde.ActivityManager /ActivityManager/Activities ListActivities

You can also open .config/kactivitymanagerdrc - you'll have the IDs along with the names in the [activities] section.

Then you can create a script

#!/bin/bash
qdbus org.kde.ActivityManager /ActivityManager/Activities SetCurrentActivity ID_OF_AN_ACTIVITY
application_you_want_to_start & >/dev/null &
Comment 6 Christian 2016-02-23 06:05:08 UTC
Thank you Ivan! Wow that's a useful script. It would be nice if the properties window of the program shortcuts would include a setting for that. But good to know that it's possible to do this manually using a script.
Comment 7 Ivan Čukić 2016-02-23 06:46:56 UTC
You can set specific application to show on a specific activity always (Alt+F3 -> More actions -> Special Window (or Application) Settings -> Size & Position -> Activity) but it will not automatically switch to that activity when you start the program.

And you can a program to run when the activity is started by placing its .desktop file in ~/.local/share/kactivitymanagerd/activities/ID_OF_AN_ACTIVITY/started/
Comment 8 Christian 2016-02-23 11:40:25 UTC
Great, thanks. Would be great if these hints could be added to the documentation. I tried to find the "official" documentation for Activities - is this it? https://docs.kde.org/stable5/en/kde-workspace/plasma-desktop/zooming-user-interface.html
It hardly explains anything...
Comment 9 Ivan Čukić 2016-02-23 12:24:16 UTC
Adding these to docs would make them official, and I don't want that.

Maybe somewhere I could find the place for it. We'll see. 

As for docs.kde.org... it is written in the 100BC, so it is quite outdated :)

We will need some new activities documentation.