You are not logged in.

#1 2021-01-22 02:29:06

millus
Member
Registered: 2019-07-21
Posts: 244

[SOLVED] Can scripts in /usr/local/bin execute sudo commands as user?

I have a script in /usr/local/bin that echoes a value into the display brightness node, changing it.
This echo requires sudo.

Can I somehow make it so as user I can just run the script without needing to sudo-run it, and it can still sudo-echo the brightness value, so I don't need to be sudo just to change the display brightness as a user?

I only have a very convoluted idea to make this work, which is to have a root-script running in a loop checking for some temp file eg in /tmp/brightpoll.tmp, and the /usr/local/bin/setbright.sh user script writing to said file (which is user-owned), so the command gets sort of 'piped' through that. Seems not very elegant tho =p

Last edited by millus (2024-03-30 12:26:13)

Offline

#2 2021-01-22 02:45:35

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [SOLVED] Can scripts in /usr/local/bin execute sudo commands as user?

Create a relevant entry in your sudoers so that just that command can be run with sudo without needing a password.
https://wiki.archlinux.org/index.php/Sudo#Configuration


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2021-01-22 14:05:47

saf1
Member
Registered: 2011-04-04
Posts: 28

Re: [SOLVED] Can scripts in /usr/local/bin execute sudo commands as user?

or change the permission of the file that you are trying to echo to, using an udev role: https://bbs.archlinux.org/viewtopic.php?id=260428

Last edited by saf1 (2021-01-22 14:07:52)

Offline

#4 2021-01-22 14:25:52

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,097

Re: [SOLVED] Can scripts in /usr/local/bin execute sudo commands as user?

Or consider using some existing tool like bright.

Last edited by Mr.Elendig (2021-01-22 14:26:36)


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#5 2021-01-22 17:55:00

millus
Member
Registered: 2019-07-21
Posts: 244

Re: [SOLVED] Can scripts in /usr/local/bin execute sudo commands as user?

saf1 wrote:

or change the permission of the file that you are trying to echo to, using an udev role: https://bbs.archlinux.org/viewtopic.php?id=260428

Ohh perfect, solution, I choose you!
Thanks to everyone else too smile.

Offline

Board footer

Powered by FluxBB