When I right click on an app in the taskbar and select close all, I want the app to be killed rather than close windows individually, since that allows Zen Browser to restore all the windows properly. I made another post asking how to do this but didn’t get answers, so it looks like I’m gonna have to make edit the taskmanager plasmoid!
This is the context menu option code, found in /usr/share/plasma/plasmoids/org.kde.plasma.taskmanager/contents/ui/:
PlasmaExtras.MenuItem {
id: closeWindowItem
visible: (visualParent && !get(atm.IsLauncher) && !get(atm.IsStartup))
enabled: visualParent && get(atm.IsClosable)
text: get(atm.IsGroupParent) ? i18nc("@item:inmenu", "&Close All") : i18n("&Close")
icon: "window-close"
onClicked: {
if (tasks.groupDialog !== null && tasks.groupDialog.visualParent === visualParent) {
tasks.groupDialog.visible = false;
}
tasksModel.requestClose(modelIndex);
}
}
I just tried asking LLMs how to do it and they gave wrong answers (obviously), and searched through the API documentation: https://api.kde.org/legacy/plasma/plasma-workspace/html/, but there doesn’t seem to be a way to do so.
did you know if you use grouping in the task manager, the close button applies to all open windows of the app?
i’ve never had any issues with that feature closing out the app entirely, and i just tried it with Zen and it works the same as will all my other apps.
If you have multiple windows with tabs open, and close zen via context menu then reopen it, does it restore all the windows?
it does, but for some reason i get two windows with the exact same set of tabs open that were open in zen before it was closed…not sure why i’m getting two windows tho
since it’s not my regular browser, i’m not super motivated to dig into it.
How familiar are you with plasmoids? Any APIs for killing the apps or should I call my own shell script?
sorry, can’t help you with that, just wanted to point out the grouping behavior in case you missed it.
but i can report that clearing all the open tab, history, cookies, site data… etc has fixed the double window issue for me, at least for now.
in zen there is a setting for open site in new tab or new window that may help you manage things.
Was trying to add an “End task” button (which is helpful to have since the regular close button sends a close request instead of actually killing the app) to this custom plasmoid I found for a version of the “Icons-Only Task Manager” and found this post, I ended up with this solution:
onClicked: {
const pid = get(atm.AppPid);
if (pid > 0) {
const exec = Qt.createQmlObject(`
import QtQuick
import org.kde.plasma.plasma5support as Plasma5Support
Plasma5Support.DataSource {
engine: "executable"
connectedSources: []
onNewData: function(sourceName, data) {
disconnectSource(sourceName);
destroy();
}
function exec(cmd) {
connectSource(cmd);
}
}
`, menu);
if (exec) {
exec.exec("kill -9 " + pid);
}
}
// Always clean up the taskbar entry regardless
tasksModel.requestClose(modelIndex);
}
A bit ugly but it works. You essentially use an old Plasma 5 compatibility layer (plasma5support) to run a command, you could use this approach in a loop to close all instances of zen