[Solved] Sudo Shell on startup: Fluxbox 8

Forum rules
Before you post please read how to get help

[Solved] Sudo Shell on startup: Fluxbox 8

Postby Notna888 on Sat Jun 12, 2010 1:38 am

Hey,

Firstly I'd just like to say I've searched and searched and I couldn't find a solution I could follow anywhere,

Basically, I want to automatically run the code
Code: Select all
 sudo xgamma -gamma 1.6

when I log in to lighten up my screen (and yes, I have got the settings on the monitor as bright as it will go)

The main problem I'm having is getting the sudo bit to work, I've already tried creating a bash script but that came to no avail, even if someone has found a link to one that will work with fluxbox it would be much appreciated

Thanks in advance

p.s. Keep up the good work linux mint team
Last edited by Notna888 on Sun Jun 13, 2010 1:59 am, edited 3 times in total.
User avatar
Notna888
Level 1
Level 1
 
Posts: 24
Joined: Mon May 03, 2010 6:43 am
Location: Busselton Western Australia

Linux Mint is funded by ads and donations.
 

Re: Sudo Shell on startup: Fluxbox 8

Postby vincent on Sat Jun 12, 2010 1:45 am

I put everything that I want to run on startup into the /etc/rc.local file, which runs with root privileges, so it should work for you as well.
Debian Testing x64/LM9 Main x64/Windows 7 x64 - LG R580 laptop w/ Intel Core 2 Duo T6500 2.1 GHz, 4 GB DDR2 RAM, Nvidia Geforce G 105M, Ralink rt2860 802.11n, 300 GB WD HD 5400 rpm
vincent
Level 8
Level 8
 
Posts: 2220
Joined: Tue Feb 09, 2010 4:10 am

Re: Sudo Shell on startup: Fluxbox 8

Postby Notna888 on Sat Jun 12, 2010 2:10 am

Thank you for your suggestion, but unfortunately, it didn't work for me, any other ideas by chance?
User avatar
Notna888
Level 1
Level 1
 
Posts: 24
Joined: Mon May 03, 2010 6:43 am
Location: Busselton Western Australia

Re: Sudo Shell on startup: Fluxbox 8

Postby vincent on Sat Jun 12, 2010 2:15 am

Perhaps you can try making a cron job and setting it to run at reboot? Use /etc/crontab for this, e.g. (this is only an example):

Code: Select all
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user   command
17 *   * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6   * * *   root   test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6   * * 7   root   test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6   1 * *   root   test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
@reboot        root   sudo xgamma -gamma 1.6
Debian Testing x64/LM9 Main x64/Windows 7 x64 - LG R580 laptop w/ Intel Core 2 Duo T6500 2.1 GHz, 4 GB DDR2 RAM, Nvidia Geforce G 105M, Ralink rt2860 802.11n, 300 GB WD HD 5400 rpm
vincent
Level 8
Level 8
 
Posts: 2220
Joined: Tue Feb 09, 2010 4:10 am

Re: Sudo Shell on startup: Fluxbox 8

Postby Notna888 on Sat Jun 12, 2010 2:33 am

Again no luck, I might try making a stand alone batch and doing that whole chmod thing (which to be honest I don't really understand yet, but oh well, I'll stumble my way through it) sound like it might just work?
User avatar
Notna888
Level 1
Level 1
 
Posts: 24
Joined: Mon May 03, 2010 6:43 am
Location: Busselton Western Australia

Re: Sudo Shell on startup: Fluxbox 8

Postby Notna888 on Sat Jun 12, 2010 2:41 am

No luck with that either, oh well, I'll just keep trying to nut it out then
User avatar
Notna888
Level 1
Level 1
 
Posts: 24
Joined: Mon May 03, 2010 6:43 am
Location: Busselton Western Australia

Re: Sudo Shell on startup: Fluxbox 8

Postby Notna888 on Sat Jun 12, 2010 2:56 am

Well, what do you know? the very next thing I try works.

first I had to create a small document in my home folder which I called "gamma_adjust_code.sh" witch only has
Code: Select all
pause 5
xgamma -gamma 1.6


then I opened up the terminal and used the line

Code: Select all
sudo chmod 777 gamma_adjust_code.sh

to make it readable, writable and executable,

then (with hidden files on show) I navigated to the "/home/account name/.fluxbox" folder then opened the file in there called "startup" (with root privileges [right click, open folder as root] you have no idea how many times I've forgotten that)
then within the file I found the bit that said:
#-----------------------------------------------------------------
# ADD APPLICATIONS YOU WISH TO LAUNCH AT LOGIN IN THIS SECTION
# MAKE SURE TO ADD THE "&" SYMBOL TO THE END OF EACH COMMAND
#-----------------------------------------------------------------

to below that I added
Code: Select all
#what I have added
/home/account name/gamma_adjust_code.sh &
#what's normally there


and there you go, log out and back in and it automatically adjusts your gamma to 1.6
I knew I'd get it eventually :)

Thank you vincent for your suggestions

*Edit Sorry, I didn't get it -.-' I didn't realize as I was editing it I actually put root privileges on, it does work if you log in, use something that requires you enter your password to do a root task, then log out and back in again, but I may as well just open a terminal each time, Ah well, any more suggestions people?

**2nd edit, All in working order now :D
Last edited by Notna888 on Sun Jun 13, 2010 2:00 am, edited 2 times in total.
User avatar
Notna888
Level 1
Level 1
 
Posts: 24
Joined: Mon May 03, 2010 6:43 am
Location: Busselton Western Australia

Re: Sudo Shell on startup: Fluxbox 8

Postby shengchieh on Sat Jun 12, 2010 10:30 pm

vincent wrote:I put everything that I want to run on startup into the /etc/rc.local file, which runs with root privileges, so it should work for you as well.


I wonder if the problem is due to another process being not ready. Try once using the pause command. I.e. in /etc/rc.local

pause 5 # pause 5 seconds
sudo xgamma -gamma 1.6

Sheng-Chieh
shengchieh
Level 4
Level 4
 
Posts: 259
Joined: Sat Mar 01, 2008 1:25 am

Re: (Half Solved)* Sudo Shell on startup: Fluxbox 8

Postby Kendall on Sat Jun 12, 2010 11:26 pm

Why do you need to run it with root privileges? You should be able to add it to the autostart without "sudo" and have it work just fine. If you need to, use a sleep command like is used for the printer configuration.
User avatar
Kendall
Level 7
Level 7
 
Posts: 1580
Joined: Mon Nov 16, 2009 12:20 pm
Location: Asheville, NC, USA

Re: (Half Solved)* Sudo Shell on startup: Fluxbox 8

Postby Notna888 on Sun Jun 13, 2010 1:37 am

@Kendall, you're right, sorry people, I swear last time I tried using xgamma it told that error message about privileges, and well from that I just assumed that it needed it, not once did I go back and check that, My Apologies, but oh well this can now be used as a general guide for someone trying to get a sudo command to work
and
@shengchieh That might just be my problem, I will try it :)
User avatar
Notna888
Level 1
Level 1
 
Posts: 24
Joined: Mon May 03, 2010 6:43 am
Location: Busselton Western Australia

Re: (Half Solved)* Sudo Shell on startup: Fluxbox 8

Postby Notna888 on Sun Jun 13, 2010 1:57 am

Well, just so the instructions I set out aren't useless, I'm going to edit them and that will be how I ended up getting it to work,
in short I took what both Kendall and shengchieh said, I simply changed my code in my user documents to read
Code: Select all
pause 5
xgamma -gamma 1.6


I'm not sure if the pause has anything to do with it, but well it works for me and that's all good for me, Thank you all again for all your help :)
User avatar
Notna888
Level 1
Level 1
 
Posts: 24
Joined: Mon May 03, 2010 6:43 am
Location: Busselton Western Australia

Linux Mint is funded by ads and donations.
 

Return to Others

Who is online

Users browsing this forum: No registered users and 1 guest