3N4N
3N4N

Reputation: 619

How to work on a project that needs sudo privilege

I am trying to add image support to slock, a screen lock utility from suckless.org. But slock needs root privilege to run. I didn't have problem with it when I was using it because I just did make && sudo make install. But now that I constantly need to edit, build and check, I can't figure out how to work on this project.

My workflow has been like

make
sudo chown root:root ./slock
sudo chmod u+s ./slock
./slock

I don't know how else to go about doing this. Any help?

Upvotes: 0

Views: 66

Answers (1)

Dario
Dario

Reputation: 2723

You can add a test recipe to your Makefile

test: ./slock
    sudo chown root:root $<
    sudo chmod u+s $<
    $<

You might even want to make it the default target which is executed when you call make with no target arguments. Your workflow would simply become

 make
 make
 make
 ...

until you are satisfied with the result

Upvotes: 1

Related Questions