mirror of
https://github.com/khadas/fenix.git
synced 2025-08-17 21:38:35 +00:00
54 lines
1023 B
Bash
Executable File
54 lines
1023 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
USER="$(who | grep :0\) | cut -f 1 -d ' ')"
|
|
export XAUTHORITY=/home/$USER/.Xauthority
|
|
export DISPLAY=:0
|
|
|
|
if [ -z "$USER" ]; then
|
|
if dpkg -l | grep lightdm > /dev/null; then
|
|
systemctl restart lightdm
|
|
fi
|
|
|
|
exit 0
|
|
fi
|
|
|
|
########### Settings ###########
|
|
|
|
# Use 'xrandr' to find these
|
|
DP="DP-1"
|
|
VGA="VGA-1"
|
|
HDMI="HDMI-1"
|
|
INTERNAL_DISPLAY="LVDS-1"
|
|
|
|
# Check /sys/class/drm for the exact location
|
|
DP_STATUS="$(cat /sys/class/drm/card0-DP-1/status)"
|
|
VGA_STATUS="$(cat /sys/class/drm/card0-VGA-1/status)"
|
|
HDMI_STATUS="$(cat /sys/class/drm/card0-HDMI-A-1/status)"
|
|
|
|
# Do no change!
|
|
EXTERNAL_DISPLAY=""
|
|
|
|
# Check to see if the external display is connected
|
|
if [ "${DP_STATUS}" = connected ]; then
|
|
xrandr
|
|
xrandr --output $DP --auto
|
|
else
|
|
xrandr --output $DP --off
|
|
fi
|
|
|
|
if [ "${VGA_STATUS}" = connected ]; then
|
|
xrandr
|
|
xrandr --output $VGA --auto
|
|
else
|
|
xrandr --output $VGA --off
|
|
fi
|
|
|
|
if [ "${HDMI_STATUS}" = connected ]; then
|
|
xrandr
|
|
xrandr --output $HDMI --auto
|
|
else
|
|
xrandr --output $HDMI --off
|
|
fi
|
|
|
|
exit 0
|