Part of a script won't run at login [SOLVED]

Questions about other topics - please check if your question fits better in another category before posting here
Forum rules
Before you post please read how to get help
Post Reply
jerkins
Level 1
Level 1
Posts: 44
Joined: Mon Jun 01, 2009 3:55 pm

Part of a script won't run at login [SOLVED]

Post by jerkins » Mon Aug 15, 2016 7:54 am

After upgrading to Mint 18 Mate 64-bit I was left with 2 trivial but annoying issues: unwanted screen blanking, and headphones not working until I unmuted them. I have solved both of these with simple scripts (with help from people on this forum) but I'm having problems implementing them as a startup script.
This is the whole thing, such as it is:

Code: Select all

#!/bin/bash

# unmute the headphones at startup
amixer set "Headphone" unmute

# stop the unwanted screen blanking
xset s off
xset -dpms

exit 0
The xset commands work perfectly, which indicates that the script is running as a "startup application". The problem is with the amixer command, which doesn't work at startup - but does work if I run the script again any time after my login is complete.

I can't work out why the command won't work at startup time, but will work afterwards. Is it a matter of timing (amixer not ready to use the command) or permissions? Anyone got any ideas?
Last edited by jerkins on Mon Aug 15, 2016 3:42 pm, edited 1 time in total.

Habitual
Level 13
Level 13
Posts: 4870
Joined: Sun Nov 21, 2010 8:31 pm
Location: 0.0.0.0

Re: Part of a script won't run at login

Post by Habitual » Mon Aug 15, 2016 7:59 am

Code: Select all

/path/to/amixer set "Headphone" unmute
from

Code: Select all

whereis amixer
output

jerkins
Level 1
Level 1
Posts: 44
Joined: Mon Jun 01, 2009 3:55 pm

Re: Part of a script won't run at login

Post by jerkins » Mon Aug 15, 2016 10:01 am

Hmm - tried that - still no success. I understand what you're suggesting though.
Now the script is:

Code: Select all

#!/bin/bash

# unmute the headphones at startup
/usr/bin/amixer set "Headphone" unmute

# stop the unwanted screen blanking
xset s off
xset -dpms

exit 0
It's almost as if amixer isn't ready at the time that "startup applications" are run.

User avatar
chrisuk
Level 5
Level 5
Posts: 593
Joined: Thu Jun 12, 2008 6:16 am

Re: Part of a script won't run at login

Post by chrisuk » Mon Aug 15, 2016 10:26 am

If it's not ready, maybe try delaying it - so sleep 10 && /usr/bin/amixer set "Headphone" unmute

Only a guess mind... wait for a proper expert to reply ;)
Chris

Manjaro MATE - MX Linux - LMDE MATE

jerkins
Level 1
Level 1
Posts: 44
Joined: Mon Jun 01, 2009 3:55 pm

Re: Part of a script won't run at login

Post by jerkins » Mon Aug 15, 2016 10:36 am

I have tried delays in the past, but the only difference is that it takes longer to log in! :)

At the moment, it looks like the command in my script IS running, but somehow alsamixer is over-writing it with its own preferences... but that's only a guess. I'm currently looking at the alsa config files to see if anything can be changed to suit my needs. It's complicated scripting in there though!
Last edited by jerkins on Tue Aug 16, 2016 6:15 am, edited 1 time in total.

User avatar
Flemur
Level 17
Level 17
Posts: 7227
Joined: Mon Aug 20, 2012 9:41 pm
Location: Potemkin Village

Re: Part of a script won't run at login

Post by Flemur » Mon Aug 15, 2016 12:40 pm

At the moment, it looks like the command in my script IS running, but somehow alsamixer is over-writing it with its own preferences... but that's only a guess.
Sounds like a good guess. I run very similar commands, but with fluxbox's "startup" file. I'm not sure what the diff is between starting there and in your "startup", but here's an idea: Make your startup script run a different script that has the time delay,
e.g. startup script does:

Code: Select all

/home/username/bin/fix-headphones &
with the "&" so it's in background, and ~/bin/fix-headphones is

Code: Select all

sleep 10 && /usr/bin/amixer set "Headphone" unmute
Please edit your original post title to include [SOLVED] if/when it is solved!
Your data and OS are backed up....right?
Mint 19.1 Xfce/fluxbox
Manjaro openbox/fluxbox

jerkins
Level 1
Level 1
Posts: 44
Joined: Mon Jun 01, 2009 3:55 pm

Re: Part of a script won't run at login

Post by jerkins » Mon Aug 15, 2016 3:20 pm

Interesting proposal - I'll try this a little later.

UPDATE: That worked! It's an obvious solution when you think about it - except I missed it first time around... ;)

Thanks :)

Post Reply

Return to “Other topics”