scripts

shell scripts
git clone git://git.bitsmanent.org/scripts
Log | Files | Refs | README

commit 41040d71f7aeecec23d148907e48acefb412d82e
parent f5c2db25fcd58b8aa9322f1df1936ba663e4ad89
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Sun, 20 Mar 2016 19:25:17 +0100

Add setmon.

Diffstat:
MREADME.md | 6++++++
Asrc/setmon | 21+++++++++++++++++++++
2 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -260,3 +260,9 @@ mkbkp only supports backup of files, directories and git repositories. Though it easy to add support for virtually anything. Just declare a function in your configuration file and add its name into the $SUPPORT variable. See bkp_names and bkp_gitrepos in [mkbkp](src/mkbkp) to learn more. + +setmon +------ +Detects connected screens and set proper video and audio output. It uses xrandr +and pulseaudio. I wrote it to easily switch forth and back from my HDMI TV. +Change it to fit your needs. diff --git a/src/setmon b/src/setmon @@ -0,0 +1,21 @@ +#!/bin/sh + +PULSE_SERVER="unix:/run/user/$(id -u)/pulse/native" + +main() { + dev="$(xrandr |awk '/ connected/ {print $1}' |sort |head -1)" + + case $dev in + HDMI*) audio="hdmi";; + LVDS*) audio="analog";; + esac + + sudo -u $(id -un) pactl --server $PULSE_SERVER \ + set-card-profile 0 \ + output:${audio}-stereo+input:analog-stereo + xrandr --output $dev --auto + + echo "$dev w/ $audio audio." +} + +main "$@"