Skip to content

Instantly share code, notes, and snippets.

@RyanMillerC
Last active November 7, 2020 13:29
Show Gist options
  • Save RyanMillerC/c48d9f63f8fe386b22a7da18cf6913d2 to your computer and use it in GitHub Desktop.
Save RyanMillerC/c48d9f63f8fe386b22a7da18cf6913d2 to your computer and use it in GitHub Desktop.

Revisions

  1. Ryan Miller revised this gist Feb 10, 2018. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions set-primary-monitor-pantheon-greeter
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,15 @@
    #!/bin/bash
    #
    # { 2017-07-02 16:20 }
    # { Ryan Miller | [email protected] }
    # { /usr/local/bin/set-primary-monitor-pantheon-greeter }
    # 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/correct-screen-pantheon-greeter
    # 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)
    @@ -17,7 +19,7 @@ PRIMARY_DISPLAY='HDMI-0'
    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 1
    [[ $(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
  2. Ryan Miller renamed this gist Jul 18, 2017. 1 changed file with 4 additions and 4 deletions.
    Original file line number Diff line number Diff line change
    @@ -2,21 +2,21 @@
    #
    # { 2017-07-02 16:20 }
    # { Ryan Miller | [email protected] }
    # { /usr/local/bin/correct-screen-pantheon-greeter }
    # { /usr/local/bin/set-primary-monitor-pantheon-greeter }
    #
    # Set correct primary monitor for login when lightdm greeter starts up on Elementary OS.
    # 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/correct-screen-pantheon-greeter
    #

    # Run 'xrandr -q' to see available displays; insert the one you want as primary
    # 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 }')

    # Check if PRIMARY_DISPLAY is connected; if not, bail out of script
    # Safety - Check if PRIMARY_DISPLAY is connected; if not, bail out of script
    [[ $(grep ${PRIMARY_DISPLAY} <<< ${x_out}) ]] || exit 1

    # Iterate over x_out and disable all monitors except for PRIMARY_DISPLAY
  3. Ryan Miller created this gist Jul 3, 2017.
    29 changes: 29 additions & 0 deletions correct-screen-pantheon-greeter
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    #!/bin/bash
    #
    # { 2017-07-02 16:20 }
    # { Ryan Miller | [email protected] }
    # { /usr/local/bin/correct-screen-pantheon-greeter }
    #
    # Set correct primary monitor for login 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/correct-screen-pantheon-greeter
    #

    # Run 'xrandr -q' to see available displays; insert the one you want as primary
    PRIMARY_DISPLAY='HDMI-0'

    # Get list of connected monitors
    x_out=$(xrandr -q | grep -e '\( \)connected' | awk -F' ' '{ print $1 }')

    # Check if PRIMARY_DISPLAY is connected; if not, bail out of script
    [[ $(grep ${PRIMARY_DISPLAY} <<< ${x_out}) ]] || exit 1

    # 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