LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Run Daemon on start-up ? (https://www.linuxquestions.org/questions/linux-software-2/run-daemon-on-start-up-4175444291/)

steak1987 01-05-2013 02:52 PM

Run Daemon on start-up ?
 
Hey, the process im trying to run is "tpb" its an OSD for think pad buttons on linux.

http://www.thinkwiki.org/wiki/Tpb

https://wiki.archlinux.org/index.php/ThinkPad_OSD

http://rc98.net/x31install

However, all those guides are old and are not for linux mint (13).


Im trying to make the program Run on my PC so I get an OSD whenever I change my volume (which doesnt happen for some reason)

However, it doesnt work unless I sudo it.


http://i.imgur.com/n3nYm.png


Code:

XXXX@XXXX-ThinkPad-X60 ~ $ tpb
Unable to open device /dev/nvram: Permission denied
XXXX@XXXX-ThinkPad-X60 ~ $ sudo tpb
[sudo] password for XXXX:
This process is currently running setuid or setgid.
GTK+ does not allow this therefore Qt cannot use the GTK+ integration.
Try launching your app using 'gksudo', 'kdesudo' or a similar tool.

See http://www.gtk.org/setuid.html for more information.

The OSD remains after closing the terminal window and only vanishes after a reboot. Im afraid of following the above guides because I'm afraid of mucking up my kernels. What are my options ?

Snark1994 01-06-2013 06:15 AM

Which part did you think might muck up your kernel? ArchWiki is generally very well maintained (and indeed up-to-date!), and nor does its article mention altering the kernel...

However, if 'sudo tpb' works as you want it to, then you don't even need to do the nvram part of the setup.

As for starting tpb, I believe Linux Mint uses Upstart, in which case you want to put the following into /etc/init/tpb.conf

Code:

description    "ThinkPad OSD"
author          "Snark1994 on LinuxQuestions"

start on stopped load-modules
stop on starting shutdown

exec /usr/bin/tpb -d
respawn

This is completely untested. I don't have Linux Mint, tpb, or upstart, so I claim no responsibility for anything that goes wrong :D

I used https://wiki.frugalware.org/index.php/Upstart_Job_HOWTO and http://upstart.ubuntu.com/cookbook/, which both seem to be good sources if you're interested in how things work.

Hope this helps,

steak1987 01-06-2013 10:04 AM

The guide which got me paranoid about messing about with my kernel after setting up tpb was:

http://rc98.net/x31install

I tried following your comment, but the file at
Code:

/etc/init/tpb.conf
doesnt exist.

---------EDIT: I mentioned that the file doesnt exist, should I make the file, with the sole contents being what youve got quoted ? -------------

Is there any script or command that I can run, using the "Startup Applications Preferences" screen ? Either by an terminal command, or by pointing to a script which runs "sudo tpb" ?

http://i.imgur.com/ZKDZr.png?1

Thanks for your prompt reply though.

Snark1994 01-07-2013 04:51 AM

I meant to make the file, but if there's a "Startup Applications Preferences" screen then that's probably an easier way to do it. What you'll need to do is click "Add" and then I'm guessing it will let you enter a command - choose "sudo tpb". You'll then need to allow yourself to run "sudo tpb" without entering your password, so add the following to you sudoers file:

Code:

steak1987 ALL= NOPASSWD: /bin/tpb
replacing "steak1987" with your local username and "/bin/tpb" with the actual location of "tpb" (use the full path). Afterwards just check that you can run "sudo tpb" in your terminal without entering your password. Also, consider using something like visudo to avoid messing up your sudoers file :)

Hope this helps,

alieblice 01-07-2013 06:58 AM

maybe this way is easier :
put your command in /etc/rc.local
you don't need to put "sudo" on that file because command in there execute as root.
and put your command before "exit 0" line.
https://wiki.archlinux.org/index.php...etc.2Frc.local

you can also using your gui to do it . if you're using gnome theres "startup application" in its system setting that let you do this.

steak1987 01-07-2013 08:49 AM

Quote:

Originally Posted by alieblice (Post 4864524)
maybe this way is easier :
put your command in /etc/rc.local
you don't need to put "sudo" on that file because command in there execute as root.
and put your command before "exit 0" line.
https://wiki.archlinux.org/index.php...etc.2Frc.local

you can also using your gui to do it . if you're using gnome theres "startup application" in its system setting that let you do this.

I did the modification you suggested using a text editor:

Code:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

tpb


exit 0


Unfortunately, upon reboot, nothing happened. To avoid any issues and out of paranoia, I reverted back to the original file after that.


_________________

Quote:

Originally Posted by Snark1994 (Post 4864444)
I meant to make the file, but if there's a "Startup Applications Preferences" screen then that's ........ sudoers file :)

Hope this helps,

Im fairly new to linux, so forgive me for my ineptitude or if I missed anything. Using google, I came upon the following guides:

http://www.linuxscrew.com/2007/08/29...ry-is-located/
http://www.garron.me/linux/visudo-co...lt-editor.html

Code:

XXXXXX@XXXXXX-ThinkPad-X60 ~ $ visudo
visudo: /etc/sudoers: Permission denied
visudo: /etc/sudoers: Permission denied
XXXXXX@XXXXXX-ThinkPad-X60 ~ $ whereis tpb
tpb: /usr/bin/tpb /usr/bin/X11/tpb /usr/share/man/man1/tpb.1.gz
XXXXXX@XXXXXX-ThinkPad-X60 ~ $ type tpb
tpb is /usr/bin/tpb
XXXXXX@XXXXXX-ThinkPad-X60 ~ $

So .... Now im stuck. I cant edit the sudoers file using visudo. Should I try opening it with gedit ?

---------EDIT:

Apparently, I need to run visudo as root. So I need to sudo visudo. Anyways, doing that opened up an text editor in terminal (which I would need to figure out how to work, doesnt seem too hard). Now the issue remains, what program location do I need to use ?

alieblice 01-07-2013 10:22 AM

put sudo before 'visudo'.
$ sudo visudo


try putting its full path in rc.local:
/usr/bin/tpb

steak1987 01-07-2013 12:38 PM

Cheers, it all works perfectly now.

I used Snark1994's method, and I derived the full path from your post (even though I didnt use the rc.local method). So thanks to both of you, for helping me out.

Snark1994 01-08-2013 04:57 AM

Glad you got it sorted :) as you guessed, you need 'sudo' to run 'visudo'. Also:

Code:

$ whereis tpb
tpb: /usr/bin/tpb /usr/bin/X11/tpb /usr/share/man/man1/tpb.1.gz

tells you all the locations where source, binary and man pages are located for 'foo'. In this case, you wanted only the first path it printed out, which you can find by using

Code:

$ which tpb
/usr/bin/tpb

Regards,


All times are GMT -5. The time now is 09:59 AM.