complex command with exec

asked 2015-09-23 17:11:19 +0000

anonymous user

Anonymous

I'm trying to understand why the following command does not work with i3:

bindsym plus           exec xrandr --output LVDS1 --brightness "$(xrandr --current --verbose | grep brightness | awk -F: '{if($2>0.9){print(1.0)}else{print($2+0.1)}}')"

My i3 version is latest: 4.10.4

I've also tried

bindsym plus exec "xrandr --output LVDS1 --brightness $(xrandr --current --verbose | grep brightness | awk -F: '{if($2>0.9){print(1.0)}else{print($2+0.1)}}')"

As per @airblader's suggestion, I also extracted the command into a separate script: /home/me/.i3/bi.sh

#!/bin/bash
xrandr --output LVDS1 --brightness $(xrandr --current --verbose | grep brightness | awk -F: '{if($2>0.9){print(1.0)}else{print($2+0.1)}}')

and have the following line in my .i3/config:

bindsym plus           exec /home/me/.i3/bi.sh

but no luck still. Can anyone tell me what I'm doing wrong?

edit retag flag offensive close merge delete

Comments

1

a) Does binding another command ("exec i3-nagbar") work for "bindsym plus"? b) Does the script work if you call it from the command line?

Airblader gravatar imageAirblader ( 2015-09-23 19:26:52 +0000 )edit

I feel stupid but it appears that i3 runs exec in bash -c, where aliases don't work. (I had `alias grep=grep -i`). `exec xrandr --output LVDS1 --brightness $(xrandr --current --verbose | grep Brightness | awk -F: '{if($2>0.9){print(1.0)}else{print($2+0.1)}}')` works fine (brigthness->Brigthness).

YetAnotherAccount gravatar imageYetAnotherAccount ( 2015-09-24 03:52:24 +0000 )edit

Good to hear you figured it out. exec just passes the command to /bin/sh, by the way. :)

Airblader gravatar imageAirblader ( 2015-09-24 09:05:35 +0000 )edit

ah I see. Well I'm beginning to think that I'm not my brightness is not as much as I used to think..

YetAnotherAccount gravatar imageYetAnotherAccount ( 2015-10-01 08:19:59 +0000 )edit