Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm experimenting with the webkit greeter for lightdm. Ubuntu 13.10 64 bits. I want to learn to create my own themes. I noticed that the default theme does not show a language select button or a session type select button. With the unity-greeter I can choose to start Unity or Gnome 3. Recently I started to prefer Gnome 3, that means that the webkit greeter is unusable to me right now as I'm forced to start with Unity when I want Gnome 3.

Is It possible to add a session type button to a webkit-greeter theme? How? Must I edit the default theme files to show the button?

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

If you look at lightdm-webkit-greeter.c in the source code, there are all sorts of interesting values we can get at from webkit. For a quick and dirty method to add a session selection dropdown to the default theme I did the following (this could definitely be expanded and improved upon):

In the default index.html, right above the line that writes the user list to the greeter:

document.write('<table id="user_table" style="margin: auto;">');

I added some code to write out the session selector:

document.write('<select id="session_list">');
for (i in lightdm.sessions)
{
  session = lightdm.sessions[i];
  if (session.key == lightdm.default_session)
    document.write('<option selected="selected" value="' + session.key + '">' + session.name + '</option>');
  else
    document.write('<option value="' + session.key + '">' + session.name + '</option>');
}
document.write('</select>');

The value attributes aren't really necessary in this code, I was going to use them to select the session, but decided to use the index instead. The other change is to the authentication_complete() function. In the default code we have:

if (lightdm.is_authenticated)
  lightdm.login (lightdm.authentication_user, lightdm.default_session);

So it always uses the default_session key. We want to instead use the selected session, so we can do something like:

if (lightdm.is_authenticated)
{
  session_list = document.getElementById('session_list');
  session = lightdm.sessions[session_list.selectedIndex];
  lightdm.login (lightdm.authentication_user, session.key);
}
share|improve this answer
    
Thank you for that code. I learned a lot about how the greeter works. If I understand correctly that code, the session list will be placed right above the user list, and its starting value will be always the default_session at each system boot, and its last selected value will be maintained for the next user except when explicitly changed. Depending of what I can get from the lightdm namespace/object I will try to get a behavior similar to the unity-greeter that remembers the last session chosen by each user. –  Hatoru Hansou Feb 2 at 17:45
1  
@HatoruHansou That is partially correct. The default value will actually always be the default-session key in /etc/lightdm/lightdm.conf, however the user's session choice is updated correctly. I thought I'd start with something simple, but it shouldn't be too hard to extend it to have per-user sessions. You should be able to get the session key from the user object as user.session, and use that to compare instead of lightdm.default_session. –  Jason Conti Feb 2 at 17:57
    
Thank you for clarify. And user.session is definitely what I'm after. –  Hatoru Hansou Feb 2 at 18:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.