/*
         * It appears that getlastlogxbyname only works if you have elevated permissions
         * but it also doesn't distinguish between user login into the system and user opening a new login terminal
         */
        static DateTimeOffset GetLoginTime()
        {
            LastLogX ll = new LastLogX();

            if (IntPtr.Zero == getlastlogxbyname(Environment.UserName, ref ll))
            {
                // getlastlogxbyname doesn't work if SIP is disabled
                return(DateTimeOffset.MinValue);
            }

            var dt = DateTimeOffset.FromUnixTimeSeconds(ll.ll_tv_tv_sec);

            return(dt);
        }
 extern static IntPtr getlastlogxbyname(string name, ref LastLogX ll);