Saturday, January 7, 2017

LightDM with multiple monitors

I've come across a small annoyance with LightDM. I'm not sure if this problem exists with others, such as GDM, but it would probably fix that too, if it does. After a time, which can be set by the user, the screen goes black and locks as it should. However, when using more than one monitor, the lock screen can seem to appear at random on any screen. Actually, it's not random. It shows up on the screen where the mouse was when it locked. If you wish that it stayed on the same monitor all the time, then here's the solution. It requires the xdotool to be installed. It may even come with your distribution, but usually isn't installed by default. Next add the simple script below to your path. Add it as an autorun application and your done! Your login screen will always show up on the left most monitor (and so will your mouse).
#!/bin/sh
# TITLE: Move Mouse
# DATE:  03 DEC 2016
#
# DESCRIPTION: This simple script moves the mouse to the to the left side of
#    the screen for the purpose of keeping the login window on
#   the left monitor
#
dbus-monitor --session "type='signal',interface='org.mate.ScreenSaver'" |  \
while read x 
  do 
    case "$x" in  
      *"boolean true"*) xdotool mousemove 100 200
    esac 
done &

How the script works
The script tells dbus to let it know when then screen saver goes active. At that time it executes the xdotool command that moves the mouse to location 100 by 200 pixels. If you wish it to display on another monitor you will have to move the mouse to a value larger than the width of the left most monitor (or two if you have three or more). 'interface' is the dbus name for your action you are monitoring. In this example the mate screensaver. If you have another screensaver running you will have to change it to the appropriate name.

No comments:

Post a Comment