From 51d13af58bd939af696c5658d09f305582779440 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Sun, 6 Mar 2016 15:16:40 +1300 Subject: Add basic session detection and selection --- LICENSE | 6 ++++++ bg.jpg | Bin 156967 -> 230938 bytes drop-down.svg | 4 ++++ index.html | 3 ++- petrichor.css | 23 +++++++++++++++++++---- petrichor.js | 55 ++++++++++++++++++++++++++++++++++++------------------- 6 files changed, 67 insertions(+), 24 deletions(-) create mode 100644 drop-down.svg diff --git a/LICENSE b/LICENSE index f1b6c62..171e2d3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,9 @@ +iec5009.svg: released by its original author into the public domain. +bg.jpg: derivative work of a file in the public domain. +drop-down.svg: property of Google Inc. + +All remaining files licensed under the following terms: + Copyright © 2016 David Phillips. All Rights Reserved. Redistribution and use in source and binary forms, with or without diff --git a/bg.jpg b/bg.jpg index 38a07ff..5ad178e 100644 Binary files a/bg.jpg and b/bg.jpg differ diff --git a/drop-down.svg b/drop-down.svg new file mode 100644 index 0000000..9dafd13 --- /dev/null +++ b/drop-down.svg @@ -0,0 +1,4 @@ + + + + diff --git a/index.html b/index.html index f424466..9f04ffa 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,7 @@ start(); - +
@@ -20,6 +20,7 @@
+ diff --git a/petrichor.css b/petrichor.css index f7f10fa..8ad5d38 100644 --- a/petrichor.css +++ b/petrichor.css @@ -15,12 +15,12 @@ body,html #shutdown { - cursor: pointer; - opacity: 0.5; - width: 96px; position: absolute; right: 50px; bottom: 50px; + cursor: pointer; + opacity: 0.5; + width: 96px; transition: opacity ease 0.3s; } @@ -85,7 +85,7 @@ a.user { color: #333; opacity: inherit; - background-color: rgba(255,255,255,255,0.2); + background-color: #FFF; padding: 0.2em; border: 1px solid #DDD; border-radius: 5px; @@ -134,3 +134,18 @@ a.user margin-right: 30px; font-size: 240px; } + +#session_list +{ + position: absolute; + top: 50px; + left: 50px; + border: 1px solid #DDD; + border-radius: 5px; + padding: 0.2em; + color: #333; + padding-right: 2em; + background: url('drop-down.svg') no-repeat right #FFF; + -webkit-appearance: none; + -moz-appearance: none; /* only for when testing */ +} 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(' 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 += ""; + } +} + function update_time() { var days = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]; @@ -123,28 +135,33 @@ function update_time() function start() { - document.write('
'); - for (i in lightdm.users) - { - user = lightdm.users[i]; + document.write('
'); + 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(''); - document.write(''+user.display_name+''); + document.write(''); + document.write(''+user.display_name+''); - if (user.name == lightdm.autologin_user && lightdm.autologin_timeout > 0) - document.write(''); + if (user.name == lightdm.autologin_user && lightdm.autologin_timeout > 0) + document.write(''); - document.write(''); - } - document.write('
'); + document.write(''); + } + document.write('
'); + 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(); } -- cgit v1.1