You are not logged in.

#1 2012-01-29 23:17:48

quasifilmie
Member
Registered: 2011-10-27
Posts: 296

[SOLVED] Where should I put this sound script?

I found a sound script so that when my tv outputs hdmi sound also does so automatically. Where do I put?

#!/bin/sh
if [[ $1 ]]
then
  xrandr --output HDMI1 --off
  pactl set-card-profile 0 output:analog-stereo
else
  xrandr --output HDMI1 --mode 1920x1080 --right-of LVDS1
  pactl set-card-profile 0 output:hdmi-stereo

Last edited by quasifilmie (2012-01-30 00:56:33)

Offline

#2 2012-01-29 23:32:16

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,700

Re: [SOLVED] Where should I put this sound script?

Do you want to  do this system wide, or for an individual user?

I think it will work system wide if you invoke it from /etc/rc.local


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#3 2012-01-30 00:07:28

quasifilmie
Member
Registered: 2011-10-27
Posts: 296

Re: [SOLVED] Where should I put this sound script?

I prefer system-wide but perhaps it could be a problem. I pasted the script in rc.local and I get failed to open display connection refused when I startup. Could the script be getting invoked to soon? Where would I put this for a single-user?

Offline

#4 2012-01-30 00:12:16

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,700

Re: [SOLVED] Where should I put this sound script?

Yeah, I was afraid of that. 
How do you start your window manager, and which window manager / desktop environment are you using?

If you are using startx, you could invoke it from your ~/.xinitrc.  You might create a second scipt, launch it in the background, and put a sleep at the beginning to ensure X is ready.
KDE, Openbox and Xfce4 allow you to run scripts at start up.  Gnome might, I would not know.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#5 2012-01-30 00:34:07

quasifilmie
Member
Registered: 2011-10-27
Posts: 296

Re: [SOLVED] Where should I put this sound script?

I am using gnome 3. I have gdm as a daemon in rc.conf.

For gnome-session-properties, would I make a .sh file and add that in gnome-session properties.

Offline

#6 2012-01-30 00:43:11

quasifilmie
Member
Registered: 2011-10-27
Posts: 296

Re: [SOLVED] Where should I put this sound script?

Tried to execute the sh file and it did not work. I get command not found. Sorry, I am a complete noob with bash.

Offline

#7 2012-01-30 00:44:26

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,680

Re: [SOLVED] Where should I put this sound script?

Make sure the script is executable

chmod a+x <path to script>

Offline

#8 2012-01-30 00:56:11

quasifilmie
Member
Registered: 2011-10-27
Posts: 296

Re: [SOLVED] Where should I put this sound script?

Im just going to mark as solved as the script does not actually do the intended purpose.  @skunktrader I did get the script to execute though.

Offline

Board footer

Powered by FluxBB