Last active
August 29, 2015 14:18
-
-
Save frafra/babfe4c32478923687ea to your computer and use it in GitHub Desktop.
Disable ghosts video outputs on Linux
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 -e | |
# | |
# How to run this script: | |
# $ (source <(curl https://gist.githubusercontent.com/frafra/babfe4c32478923687ea/raw)) | |
DIR=/sys/class/drm | |
REGEX="(card[0-9]+-(.+))" | |
OUTPUTS=($(for f in $DIR/* | |
do [[ $f =~ $REGEX ]] && echo ${BASH_REMATCH[1]} || true | |
done)) | |
echo "Video outputs:" | |
i=1 | |
for output in ${OUTPUTS[@]} | |
do | |
echo "$i) $output " $(cat $DIR/$output/{status,enabled}) | |
let i++ | |
done | column -t | |
read -p "Select video output [1-${#OUTPUTS[@]}]: " id | |
[[ $id -ge 1 && $id -le ${#OUTPUTS[@]} ]] || exit 1 | |
let id-- | |
[[ ${OUTPUTS[$id]} =~ $REGEX ]] || exit 1 | |
pkexec sed -ri 's/(GRUB_CMDLINE_LINUX=)"(.*)"/\1"\2 video='${BASH_REMATCH[2]}':d"/' /etc/sysconfig/grub | |
for f in /boot/{grub2,efi/EFI/fedora}/grub.cfg | |
do [ -f $f ] && pkexec grub2-mkconfig -o $f | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment