[Solved] Sudo Shell on startup: Fluxbox 8

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Notna888

[Solved] Sudo Shell on startup: Fluxbox 8

Post by Notna888 »

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 LockBot on Wed Dec 28, 2022 7:16 am, edited 4 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
vincent

Re: Sudo Shell on startup: Fluxbox 8

Post by vincent »

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.
Notna888

Re: Sudo Shell on startup: Fluxbox 8

Post by Notna888 »

Thank you for your suggestion, but unfortunately, it didn't work for me, any other ideas by chance?
vincent

Re: Sudo Shell on startup: Fluxbox 8

Post by vincent »

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
Notna888

Re: Sudo Shell on startup: Fluxbox 8

Post by Notna888 »

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?
Notna888

Re: Sudo Shell on startup: Fluxbox 8

Post by Notna888 »

No luck with that either, oh well, I'll just keep trying to nut it out then
Notna888

Re: Sudo Shell on startup: Fluxbox 8

Post by Notna888 »

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.
shengchieh

Re: Sudo Shell on startup: Fluxbox 8

Post by shengchieh »

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
Kendall

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

Post by Kendall »

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.
Notna888

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

Post by Notna888 »

@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 :)
Notna888

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

Post by Notna888 »

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 :)
Locked

Return to “Software & Applications”