You are not logged in.

#1 2021-08-06 19:44:06

alpindale
Member
Registered: 2021-08-06
Posts: 9

How do I blacklist a certain command from being executed?

Hi. As the title says, I'm trying to blacklist one certain command from being executed in the terminal. For various reason, I'm using xrandr to manage my screen brightness, but I want to avoid accidentally setting the brightness to 0. So what I'm essentially trying to do is render the command "xrandr --output LVDS-1 --brightness 0" ineffective. What should I do?

Last edited by alpindale (2021-08-06 19:44:26)

Offline

#2 2021-08-06 20:01:10

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,500
Website

Re: How do I blacklist a certain command from being executed?

Ah ... not type that command.  If you don't want to run that command, why would you type it then hit enter?  Nothing else is running that command behind the scenes.  Any other approach would be ... well, not very bright.

You could make a xrandr wrapper script that effectively blocked that command and passed on all others, but if you are fighting against your own anti-brightness-addiction, you'd be able to circumvent your own intervention by calling /bin/xrandr directly.

I suspect, though, that this is an X-Y question.  Do you really have some script to adjust brightness and you want to prevent it from getting all the way to zero?  If so, there are much better ways of acheiving that - if this is the case, please post your current script.

Last edited by Trilby (2021-08-06 20:30:00)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2021-08-06 21:01:33

alpindale
Member
Registered: 2021-08-06
Posts: 9

Re: How do I blacklist a certain command from being executed?

Trilby wrote:

Ah ... not type that command.  If you don't want to run that command, why would you type it then hit enter?  Nothing else is running that command behind the scenes.  Any other approach would be ... well, not very bright.

You could make a xrandr wrapper script that effectively blocked that command and passed on all others, but if you are fighting against your own anti-brightness-addiction, you'd be able to circumvent your own intervention by calling /bin/xrandr directly.

I suspect, though, that this is an X-Y question.  Do you really have some script to adjust brightness and you want to prevent it from getting all the way to zero?  If so, there are much better ways of acheiving that - if this is the case, please post your current script.

Ah well, since the maximum value is 1, my input values are between 0.1 and 1, and I did accidentally hit enter when it was still "0." one time, which resulted in my screen going completely black. What I'm doing is preventing that from happening ever again, since it's gonna be a bother to fix it.

Offline

#4 2021-08-06 21:08:01

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

Re: How do I blacklist a certain command from being executed?

alpindale wrote:

since it's gonna be a bother to fix it.

No bother at all. Just press the up arrow to recall the previous command then hit 1[ENTER]


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

#5 2021-08-06 21:10:04

Skunky
Member
Registered: 2018-01-25
Posts: 231

Re: How do I blacklist a certain command from being executed?

alias "xrandr --output LVDS-1 --brightness 0" to "xrandr --output LVDS-1 --brightness 1"?

Last edited by Skunky (2021-08-06 21:10:17)

Offline

#6 2021-08-06 21:26:13

alpindale
Member
Registered: 2021-08-06
Posts: 9

Re: How do I blacklist a certain command from being executed?

Skunky wrote:

alias "xrandr --output LVDS-1 --brightness 0" to "xrandr --output LVDS-1 --brightness 1"?

Whoa that's actually quite brilliant. Thanks.

Offline

#7 2021-08-06 22:03:50

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,500
Website

Re: How do I blacklist a certain command from being executed?

How often are you even entering that command?  Why not make a script / keybinding / etc?


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#8 2021-08-07 06:42:12

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,365

Re: How do I blacklist a certain command from being executed?

since the maximum value is 1, my input values are between 0.1 and 1, and I did accidentally hit enter when it was still "0."

That's incorrect, randr brightness manipulates the gamma ramps (it doesn't alter the backlight and you'll not save energy this way) and therefore easily allows values > 1 (turning the output brighter)

alias "xrandr --output LVDS-1 --brightness 0" to "xrandr --output LVDS-1 --brightness 1"

my input values are between 0.1 and 1


Did you try the alias tongue

Follow Trilby's advice and make a shell function or script.
Make it simpler, so you don't have to type so much (eg. shorter command find all connected displays and alter them equally, make the value range 0-100 and guard against toolow™ values)

Also you can switch to a different VT (eg. crtl+alt+f3) and fix the value from there (again: no impact on the actual backlight)

Offline

Board footer

Powered by FluxBB