• How to make lightdm-webkit2 theme?


    Since I don’t particularly like the default Antergos theme, I’ve decided to make my own. After two days of googling how to javascript this and javascript that (and determining which code is necessary and which isn’t in the themes I used for reference), I’ve had something that still looks fairly ugly but that in theory should work. In practice, of course it doesn’t (or else I wouldn’t be asking).


    My understanding of lightdm-webkit/lightdm-webkit2:

    From what I gathered between the default lightdm-webkit theme, lightdm-webkit2-antergos and a blog discussing lightdm in more general way, this is pretty much all you need to have for login to happen on the javascript side of things:

    1. We need to run this command:

      lightdm.start_authentication(username);
      

    This command is run after a user is selected from the user list. ‘username’ is the name said user would use to login via tty, or lightdm.users[i].name (where ‘i’ is the number of the user who wants to login in lightdm.users[] array).

    1. We need this callback function:

      function show_prompt(text)
      

    You don’t really have to do anything in that callback function. If the password field is invisible, then you have to make it visible. If your password field is always visible, you’re pretty much set since before that function was even called. This callback happens immediately after the previous command finish executing.

    1. Enter password and once you’re done, submit password with:

      entry = document.getElementById('password_entry');
      lightdm.provide_secret(entry.value);`
      
    2. Wait for the authentication_complete() callback. This callback then logs you in, i.e. does this:

      if (lightdm.is_authenticated) {    
          lightdm.login(lightdm.authentication_user, selected_session);
      }
      else {
          //your password was probably wrong, try that again
      }
      

    Tada! Your session should start. There’s a few other pesky details you need to worry about (two more callbacks and don’t forget to cancel authentication when switching users), and then there’s some extra javascript you need for manipulating with HTML, and if you want timed autologin you need some more scripts — but the four steps above seem to be the only interaction with lightdm object you need to have if you don’t care for the more fancy features.


    Where it goes wrong

    I don’t seem to get authentication_complete() callback. I submit password and nothing happens. User is selected just fine, lightdm.authentication_user contains my username. Function in which lightdm.provide_secret(password) is executed gets executed. But I can’t get the authentication_complete() callback, I only get some moans to /var/log/lightdm/x-0-greeter.log instead:

    ** (WebKitWebProcess:10379): CRITICAL **: lightdm_greeter_respond: assertion 'priv->n_responses_waiting > 0' failed
    

    One for each password submission that failed. How the hell does Antergos theme avoid this shit?


    Can I see the relevant javascript?
    Sure: http://pastebin.com/j1XQj7at


    Edit: spelling and grammar, for the most part. And a few minor clarifications. And some edits to improve readability because I can’t proofread before posting.

  • Okay, turns out there’s been a minor oversight on my part.

    selected_session was lightdm.default_session, which is by default set to whatever the user-session line /etc/lightdm/lightdm.conf says the default is (unless chosen otherwise).

    I’ve edited the line to say ‘plasma’ early on, but I’ve also jumped to sddm and back again in the mean time and forgot to re-apply this change. This means the user-session was default. Since default isn’t actually a valid key to any DE, login didn’t happen.

    Lessons learned:

    selected_session = lightdm.default_session; 
    

    Is one of the most retarded lines of code you could write for your lightdm-webkit greeter, because lightdm.default_session can contain a value that’s invalid which has a disability. The foolproof lazy way to keep a lightdm-webkit theme working is to determine default DE using something that will never be wrong/invalid:

    selected_session = lightdm.sessions[0].key;
    

    (The less lazy way would be to write a quick for loop that checks if lightdm.default_session contains a valid value ? lightdm.default_session : lightdm.sessions[0].key)

lightdm89 theme29 lightdm-webkit28 Posts 2Views 1236
Log in to reply