diff options
author | David Phillips <dbphillipsnz@gmail.com> | 2016-03-06 15:16:40 +1300 |
---|---|---|
committer | David Phillips <dbphillipsnz@gmail.com> | 2016-03-06 15:16:40 +1300 |
commit | 51d13af58bd939af696c5658d09f305582779440 (patch) | |
tree | e2e9b12f4aab2b1333b19b12fa465f88f9561ef8 /petrichor.js | |
parent | 2f4e27402be28e4404bfe8ef782c7911ae5dcc93 (diff) | |
download | petrichor-51d13af58bd939af696c5658d09f305582779440.tar.xz |
Add basic session detection and selection
Diffstat (limited to 'petrichor.js')
-rw-r--r-- | petrichor.js | 55 |
1 files changed, 36 insertions, 19 deletions
diff --git a/petrichor.js b/petrichor.js index db05a99..f56d450 100644 --- a/petrichor.js +++ b/petrichor.js @@ -66,8 +66,10 @@ function reset() function authentication_complete() { + sel = document.getElementById('session_list'); + session = sel.options[sel.selectedIndex].getAttribute('data-sid'); if (lightdm.is_authenticated) - lightdm.start_session_sync(lightdm.authentication_user, lightdm.default_session); + lightdm.start_session_sync(lightdm.authentication_user, session); else show_message('<span class="error-icon">⚠</span> Authentication Failed'); @@ -104,6 +106,16 @@ function countdown() setTimeout('countdown()', 1000); } +function build_session_list() +{ + slist = document.getElementById('session_list'); + slist.innerHTML = ""; + for (session of lightdm.sessions) + { + slist.innerHTML += "<option data-sid="+session.key+">"+session.name+"</option>"; + } +} + function update_time() { var days = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]; @@ -123,28 +135,33 @@ function update_time() function start() { - document.write('<div id="users">'); - for (i in lightdm.users) - { - user = lightdm.users[i]; + document.write('<div id="users">'); + for (i in lightdm.users) + { + user = lightdm.users[i]; - if (user.image.match(/\.face$/)) - image = '/usr/share/icons/Adwaita/256x256/emotes/face-laugh.png'; - else - image = user.image; + if (user.image.match(/\.face$/)) + image = '/usr/share/icons/Adwaita/256x256/emotes/face-laugh.png'; + else + image = user.image; - document.write('<a href="#" class="user" id="user_' + user.name +'" onclick="start_authentication(\'' + user.name + '\')">'); - document.write('<img class="avatar" src="file:///' + image + '" /><span class="name">'+user.display_name+'</span>'); + document.write('<a href="#" class="user" id="user_' + user.name +'" onclick="start_authentication(\'' + user.name + '\')">'); + document.write('<img class="avatar" src="file:///' + image + '" /><span class="name">'+user.display_name+'</span>'); - if (user.name == lightdm.autologin_user && lightdm.autologin_timeout > 0) - document.write('<span id="countdown_label"></span>'); + if (user.name == lightdm.autologin_user && lightdm.autologin_timeout > 0) + document.write('<span id="countdown_label"></span>'); - document.write('</a>'); - } - document.write('</div>'); + document.write('</a>'); + } + document.write('</div>'); + time_remaining = lightdm.autologin_timeout; + if (time_remaining > 0) + countdown(); +} - time_remaining = lightdm.autologin_timeout; - if (time_remaining > 0) - countdown(); +function load() +{ + update_time(); + build_session_list(); } |