Forked from RyanMillerC/set-primary-monitor-pantheon-greeter
Created
July 17, 2019 14:26
-
-
Save chroming/7b1202ec0a0890a9739a3544c332e033 to your computer and use it in GitHub Desktop.
Set correct primary monitor for login screen when lightdm greeter starts up on Elementary OS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Created: 2017-07-02 16:20 | |
# Updated: 2018-02-09 12:23 | |
# Creator: Ryan Miller | |
# Website: http://devopsmachine.com/ | |
# File: /usr/local/bin/set-primary-monitor-pantheon-greeter | |
# | |
# Set correct primary monitor for login screen when lightdm greeter starts up on Elementary OS. | |
# | |
# Make sure to add the following line into /usr/share/lightdm/lightdm.conf.d/40-pantheon-greeter.conf (without the #) | |
# greeter-setup-script=/usr/local/bin/set-primary-monitor-pantheon-greeter | |
# | |
# Change this variable to your primary display (Run 'xrandr -q' to see available displays) | |
PRIMARY_DISPLAY='HDMI-0' | |
# Get list of connected monitors | |
x_out=$(xrandr -q | grep -e '\( \)connected' | awk -F' ' '{ print $1 }') | |
# Safety - Check if PRIMARY_DISPLAY is connected; if not, bail out of script | |
[[ $(grep ${PRIMARY_DISPLAY} <<< ${x_out}) ]] || exit 0 | |
# Iterate over x_out and disable all monitors except for PRIMARY_DISPLAY | |
for monitor in ${x_out[@]} ; do | |
if [[ ${monitor} = ${PRIMARY_DISPLAY} ]] ; then | |
xrandr --output ${monitor} --primary | |
else | |
xrandr --output ${monitor} --off | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment