Automatically log off inactive users in Windows 10

Although I use Linux on my own machines, the family PC in my lounge runs Windows 10. It has five user accounts and the other members of my family never bother to log out (‘sign out’ in Windows 10 parlance), usually leaving a browser window open. If I logged in to my account and clicked on my icon in the top left corner of the Start Menu, ‘Signed in’ was shown below any of the other users who had not bothered to log out. I found this behaviour somewhat frustrating and resolved to configure the PC to log out a user after a specified period of inactivity by that user. Although it is generally not recommended to forcibly logout someone in case e.g. they have a document open, in my family’s case it would be unlikely to cause a problem and is preferable to leaving several accounts unnecessarily active (albeit requiring each user to re-enter their password in order to access the account, as the default setting for ‘Require a password on wake-up’ is ‘Yes’). Below I explain how I configured Windows 10 to log out each user automatically after a period of inactivity.

First I downloaded the application idlelogoff.exe using the following link:

http://www.intelliadmin.com/idlelogoff.exe

See the Web page Automatically log off inactive users for details of that application.

I used the Windows 10 File Explorer to copy the file to the root directory C:\ and then I created a batch file IDLELOGOFF.BAT by right-clicking on the Windows 10 Start Menu icon, selecting ‘Command Prompt (Admin)’ and entering the following commands in the Command Prompt window:

cd C:\
notepad IDLELOGOFF.BAT

I made the contents of the batch file IDLELOGOFF.BAT the following, so that a user would be logged out automatically after 900 seconds of inactivity in their session:

start /min C:\idlelogoff.exe 900 logoff

and I changed the owner of the batch file to Users by right-clicking on it in File Explorer and then clicking ‘Properties’ > ‘Security’ > ‘Advanced’ > ‘Owner: Change’ and specifying ‘Users’.

Then I created a standard shortcut to the batch file for each user by getting each user in turn to log in to their account and following the instructions on the Web page Windows 10 – How to Run Program Automatically at Startup. Basically, you press the Windows Key and the R key simultaneously and enter ‘shell:startup‘ to open the user’s Start-up folder, and from there you right-click and select ‘New’ > ‘Shortcut’.

After that, the application idlelogoff.exe should be started automatically the next time a user logs in. You can check by pressing Ctrl-Alt-Delete in each user’s session, selecting ‘Task Manager’, clicking on the ‘Processes’ tab and idlelogoff.exe should be in the list of background processes. If you then log in to your own account and click on your account icon in the top left corner of the Start Menu, you’ll notice ‘Signed in’ is shown below the other user’s icon. If you check again after fifteen minutes, you’ll see that the ‘Signed in’ has gone, indicating that the user has been forcibly logged off.

SDDM keyboard layout

I am using Plasma 5 in Gentoo Linux ~amd64 with OpenRC on my Compal NBLB2 laptop. The Display Manager I am using is SDDM, and the log-in screen was using the US keyboard layout, the only keyboard layout available in the log-in screen’s keyboard menu. Searching the Web told me that SDDM uses the keyboard layout specified in the file /etc/X11/xorg.conf.d/00-keyboard.conf. The trouble is, it doesn’t (at least not in my case). The file already existed in my installation, and its contents are listed below:

Section "InputClass"
    Identifier "keyboard"
    MatchIsKeyboard "yes"
    Option "XkbLayout" "gb,us,br,es"
    Option "XkbVariant" ""
    Option "XkbOptions" "grp:alt_shift_toggle"
EndSection

The X.Org keyboard layouts specified in the file are available once I have logged in to the Plasma 5 Desktop, but none of the four keyboards (gb, us, br and es) were displayed by SDDM in its log-in screen menu. Eventually I discovered it is possible to specify the keyboard layouts in the file /usr/share/sddm/scripts/Xsetup which, by default, contains only the following:

#!/bin/sh
# Xsetup - run as root before the login dialog appears

I edited the file to contain the list of keyboards I wanted SDDM to allow me to choose from on the log-in screen:

#!/bin/sh
# Xsetup - run as root before the login dialog appears
setxkbmap gb,us,br,es

Now the SDDM log-in screen displays the national flags of those four keyboard languages in its keyboard menu, and I can select which keyboard layout to use for typing my password to log in to the Plasma 5 Desktop.

ADDENDUM (October 23, 2016): If you are fed up with upgrades overwriting the change you made to the file /usr/share/sddm/scripts/Xsetup, add the Bash script 30sddm_Xsetup.start in the directory /etc/local.d/, containing the following:

#!/bin/bash
# Make sure the keyboards that I use are selectable on the SDDM greeter screen.
if ! grep setxkbmap /usr/share/sddm/scripts/Xsetup 1> /dev/null
then
    echo "setxkbmap gb,us,br,es" >> /usr/share/sddm/scripts/Xsetup
fi