4 * Copyright (c) Tuomo Valkonen 2004-2007.
6 * Ion is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
15 #include <libtu/misc.h>
16 #include <libtu/parser.h>
17 #include <libtu/tokenizer.h>
18 #include <libtu/util.h>
20 #include <ioncore/common.h>
21 #include <ioncore/global.h>
22 #include <ioncore/clientwin.h>
23 #include <ioncore/saveload.h>
24 #include <ioncore/property.h>
25 #include <libextl/readconfig.h>
26 #include <ioncore/manage.h>
27 #include <ioncore/ioncore.h>
28 #include <ioncore/exec.h>
29 #include "sm_matchwin.h"
30 #include "sm_session.h"
34 /*{{{ Module information */
37 #include "../version.h"
39 char mod_sm_ion_api_version[]=ION_API_VERSION;
45 /*{{{ Manage callback */
48 static bool sm_do_manage(WClientWin *cwin, const WManageParams *param)
50 int transient_mode=TRANSIENT_MODE_OFF;
57 ph=mod_sm_match_cwin_to_saved(cwin);
61 ret=pholder_attach(ph, 0, (WRegion*)cwin);
63 destroy_obj((Obj*)ph);
75 static void mod_sm_set_sessiondir()
77 const char *smdir=NULL, *id=NULL;
81 smdir=getenv("SM_SAVE_DIR");
82 id=getenv("GNOME_DESKTOP_SESSION_ID");
84 /* Running under SM, try to use a directory specific
88 tmp=scat3(smdir, "/", libtu_progbasename());
90 tmp=scat("gnome-session-", id);
94 p=strpbrk(p, "/ :?*");
102 tmp=scopy("default-session-sm");
106 ok=extl_set_sessiondir(tmp);
111 warn(TR("Failed to set session directory."));
118 ioncore_set_smhook(NULL);
120 hook_remove(clientwin_do_manage_alt, (WHookDummy*)sm_do_manage);
122 ioncore_set_sm_callbacks(NULL, NULL);
124 mod_sm_unregister_exports();
132 if(ioncore_g.sm_client_id!=NULL)
133 mod_sm_set_ion_id(ioncore_g.sm_client_id);
135 if(!mod_sm_init_session())
138 if(extl_sessiondir()==NULL)
139 mod_sm_set_sessiondir();
141 if(!mod_sm_register_exports())
144 ioncore_set_sm_callbacks(mod_sm_add_match, mod_sm_get_configuration);
146 hook_add(clientwin_do_manage_alt, (WHookDummy*)sm_do_manage);
148 ioncore_set_smhook(mod_sm_smhook);