Last active
February 5, 2017 15:44
-
-
Save h3ct0rjs/81c0381b8d880ca7949688f42a211631 to your computer and use it in GitHub Desktop.
Adaptation from Anachron's original block to my computer laptop acer aspire one.
This file contains hidden or 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 | |
xrandrOut=$(xrandr) | |
vgaName=$(echo "${xrandrOut}" | grep -i 'VGA' | awk '{print $1}') | |
lvdsName=$(echo "${xrandrOut}" | grep -i 'LVDS' |2 awk '{print $1}') | |
activeDisplays=$(echo "${xrandrOut}" | grep " connected" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/" | tr -s '\n' ' ') | |
displayFile='/tmp/.displays' | |
if [[ -f "${displayFile}" ]]; then | |
oldDisplays=$(cat "${displayFile}") | |
else | |
oldDisplays="" | |
fi | |
if [[ "${oldDisplays}" != "${activeDisplays}" ]]; then | |
change="yes" | |
else | |
change="no" | |
fi | |
# External, HDMI + VGA | |
if [[ "$activeDisplays" =~ "${vgaName}" ]]; then | |
if [[ "${change}" = "yes" ]]; then | |
$(xrandr --output "${lvdsName}" --primary --auto) | |
$(xrandr --output "${vgaName}" --auto --left-of "${lvdsName}") | |
$(feh --randomize --bg-fill /home/user/.wallpapaers/*) #set different wallpapers to vga and lvds1. | |
#checking if is there any option to enable just one wallpaper to both displays. | |
fi | |
echo "VGA" | |
echo "VGA" | |
echo "" | |
# Only one internal | |
elif [[ "$activeDisplays" =~ "${lvsdName}" ]]; then | |
if [[ "${change}" = "yes" ]]; then | |
$(xrandr --output "${lvdsName}" --primary --auto) | |
$(xrandr --output "${vgaName}" --off) | |
fi | |
echo "LVDS" | |
echo "LVDS" | |
echo "" | |
fi | |
if [[ "${change}" = "yes" ]]; then | |
echo "${activeDisplays}" > "${displayFile}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment