Every time I log out and log back into the system, there is always an invisible GJS process that occupies one workspace. Even after I kill it in the command line, it gets started again by this script and creates a new workspace for it.
so i use chatgpt to help me for this problem.
// function handleWindowClose(act) {
// let win = act.meta_window;
// let name = win.get_id();
// if (_old_workspaces[name] !== undefined) {
// win.get_display().get_workspace_manager().get_workspace_by_index(_old_workspaces[name]).activate(global.get_current_time());
// }
// };
function handleWindowClose(act) {
let win = act.meta_window;
let name = win.get_id();
if (_old_workspaces[name] !== undefined && name !== 'gjs') { // 避免激活 "GJS" 窗口所在的工作区
win.get_display().get_workspace_manager().get_workspace_by_index(_old_workspaces[name]).activate(global.get_current_time());
}
}
it seems work well for now.