1/* 2 * Copyright 2011 Julien Lavergne <gilir@ubuntu.com> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 17 * MA 02110-1301, USA. 18 */ 19 20/* TODO Replace other utlity in the start script */ 21 22namespace Lxsession 23{ 24 public class Option: GLib.Object 25 { 26 public string command; 27 28 public Option (LxsessionConfig config) 29 { 30 31 } 32 33 public void activate() 34 { 35 switch (command) 36 { 37 case null: 38 break; 39 case "": 40 break; 41 case " ": 42 break; 43 default: 44 message ("Options - Launch command %s",command); 45 lxsession_spawn_command_line_async(command); 46 break; 47 } 48 } 49 } 50 51 public class KeymapOption: Option 52 { 53 public KeymapOption (LxsessionConfig config) 54 { 55 base (config); 56 if (config.get_item_string("Keymap", "mode", null) == "user") 57 { 58 command = create_user_mode_command(config); 59 } 60 } 61 public string create_user_mode_command(LxsessionConfig config) 62 { 63 var builder = new StringBuilder (); 64 builder.append("setxkbmap "); 65 if (config.get_item_string("Keymap", "model", null) != null) 66 { 67 builder.append("-model "); 68 builder.append(config.get_item_string("Keymap", "model", null)); 69 builder.append(" "); 70 } 71 if (config.get_item_string("Keymap", "layout", null) != null) 72 { 73 builder.append("-layout "); 74 builder.append(config.get_item_string("Keymap", "layout", null)); 75 builder.append(" "); 76 } 77 if (config.get_item_string("Keymap", "variant", null) != null) 78 { 79 builder.append("-variant "); 80 message ("Show keymap variant : %s", config.get_item_string("Keymap", "variant", null)); 81 builder.append(config.get_item_string("Keymap", "variant", null)); 82 builder.append(" "); 83 } 84 if (config.get_item_string("Keymap", "options", null) != null) 85 { 86 builder.append("-options "); 87 message ("Show keymap options : %s", config.get_item_string("Keymap", "options", null)); 88 builder.append(config.get_item_string("Keymap", "options", null)); 89 builder.append(" "); 90 } 91 92 command = (builder.str); 93 message ("Keymap options - return user command %s", command); 94 return command; 95 } 96 } 97 98 public class ClipboardOption: Option 99 { 100 public ClipboardOption (LxsessionConfig config) 101 { 102 base (config); 103 switch (config.get_item_string("Session", "clipboard", "command")) 104 { 105 case "lxclipboard": 106#if BUILDIN_CLIPBOARD 107 message("Create build-in Clipboard"); 108 clipboard_start (); 109#else 110 message("Create Option Clipboard"); 111 command = "lxclipboard"; 112#endif 113 break; 114 } 115 } 116 public void desactivate() 117 { 118#if BUILDIN_CLIPBOARD 119 clipboard_stop (); 120#endif 121 } 122 } 123 124 public class UpstartUserSessionOption: Option 125 { 126 private string command1; 127 128 public UpstartUserSessionOption (LxsessionConfig config) 129 { 130 base (config); 131 if (config.get_item_string("Session", "upstart_user_session", null) == "true") 132 { 133 command1 = "init --user"; 134 } 135 } 136 public new void activate() 137 { 138 lxsession_spawn_command_line_async(command1); 139 } 140 } 141 142 public class XSettingsOption: GLib.Object 143 { 144 private string command; 145 146 public XSettingsOption () 147 { 148 149 } 150 151 public new void activate () 152 { 153 command = global_settings.get_item_string("Session", "xsettings_manager", "command"); 154 155 switch (command) 156 { 157 case null: 158 break; 159 case "": 160 break; 161 case " ": 162 break; 163 case "build-in": 164 message("Activate xsettings_manager build-in"); 165 settings_daemon_start(load_keyfile (get_config_path ("desktop.conf"))); 166 break; 167 case "gnome": 168 lxsession_spawn_command_line_async("gnome-settings-daemon"); 169 break; 170 case "xfce": 171 lxsession_spawn_command_line_async("xfsettingsd"); 172 break; 173 default: 174 lxsession_spawn_command_line_async(command); 175 break; 176 } 177 } 178 179 public void reload () 180 { 181 command = global_settings.get_item_string("Session", "xsettings_manager", "command"); 182 183 switch (command) 184 { 185 case "build-in": 186 message("Reload xsettings_manager build-in"); 187 settings_daemon_reload(load_keyfile (get_config_path ("desktop.conf"))); 188 break; 189 default: 190 message("Reload xsettings_manager default"); 191 this.activate(); 192 break; 193 } 194 } 195 } 196} 197