Last active
September 21, 2016 17:46
-
-
Save floreo/faa695ad1ad82d5db84538434fc63f04 to your computer and use it in GitHub Desktop.
Switch screen && sound && color temperature using xrandr/pactl/redshift
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 | |
# Switch screen && sound && color temperature using xrandr/pactl/redshift | |
## CONFIGURATION | |
_USB_SINK="$( pactl list short sinks | grep 'usb' | awk '{ print $1 }' )" | |
_HDMI_SINK="$( pactl list short sinks | grep 'hdmi' | awk '{ print $1 }' )" | |
## FUNCTION | |
# Change current audio sink and moves all current streams to it | |
function setAudio () { | |
local _sink_id="${1}" | |
pactl set-default-sink "${_sink_id}" | |
pactl list short sink-inputs | awk '{ print $1 }' | while read _sik; | |
do | |
pactl move-sink-input ${_sik} ${_sink_id}; | |
done | |
return 0 | |
} | |
## MAIN | |
case "$1" in | |
# case TV | |
"flim") | |
# Turn off two screens && turn on TV | |
xrandr --output DVI-I-1 --off \ | |
--output VGA-0 --off \ | |
--output HDMI-0 --primary --mode 1920x1080 && \ | |
# Set default to TV && move current streams | |
setAudio ${_HDMI_SINK} && \ | |
# Kill all redshit and reset screen color | |
killall redshift && \ | |
redshift -x | |
;; | |
# Desktop 2 screens | |
*) | |
# Turn off TV && turn on desktop screens | |
xrandr --output HDMI-0 --off \ | |
--output VGA-0 --primary --mode 1920x1080 \ | |
--output DVI-I-1 --mode 1920x1080 --right-of VGA-0 && \ | |
# Set default to USB sound card && move current streams | |
setAudio ${_USB_SINK} && \ | |
# Restart redshift | |
redshift -r & | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TV SAMSUNG > Select HDMI2/DVI as source, then MENU > Source List > Change name > Select HDMI2/DVI and set it as PC